Changeset: 57ed941c7ec8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=57ed941c7ec8
Modified Files:
        sql/server/rel_select.c
        sql/test/miscellaneous/Tests/simple_selects.sql
        sql/test/miscellaneous/Tests/simple_selects.stable.out
Branch: Oct2020
Log Message:

Clean largest type finding for n-ary functions


diffs (66 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -450,7 +450,6 @@ check_arguments_and_find_largest_any_typ
 {
        list *nexps = new_exp_list(sql->sa);
        sql_subtype *atp = NULL;
-       sql_arg *aa = NULL;
 
        /* find largest any type argument */
        for (node *n = exps->h, *m = sf->func->ops->h; n && m; n = n->next, m = 
m->next) {
@@ -458,14 +457,9 @@ check_arguments_and_find_largest_any_typ
                sql_exp *e = n->data;
                sql_subtype *t = exp_subtype(e);
 
-               if (!aa && a->type.type->eclass == EC_ANY) {
+               if (a->type.type->eclass == EC_ANY && t &&
+                       (!atp || (t->type->localtype > atp->type->localtype || 
(t->type->localtype == atp->type->localtype && t->digits > atp->digits))))
                        atp = t;
-                       aa = a;
-               }
-               if (aa && a->type.type->eclass == EC_ANY && t && atp && 
t->type->localtype > atp->type->localtype) {
-                       atp = t;
-                       aa = a;
-               }
        }
        for (node *n = exps->h, *m = sf->func->ops->h; n && m; n = n->next, m = 
m->next) {
                sql_arg *a = m->data;
@@ -483,7 +477,7 @@ check_arguments_and_find_largest_any_typ
                append(nexps, e);
        }
        /* dirty hack */
-       if (sf->func->type != F_PROC && sf->func->type != F_UNION && 
sf->func->type != F_LOADER && sf->res && aa && atp)
+       if (sf->func->type != F_PROC && sf->func->type != F_UNION && 
sf->func->type != F_LOADER && sf->res && atp)
                sf->res->h->data = sql_create_subtype(sql->sa, atp->type, 
atp->digits, atp->scale);
        return nexps;
 }
diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql 
b/sql/test/miscellaneous/Tests/simple_selects.sql
--- a/sql/test/miscellaneous/Tests/simple_selects.sql
+++ b/sql/test/miscellaneous/Tests/simple_selects.sql
@@ -234,6 +234,9 @@ select 1, null except select 1, null;
 select 1, null intersect select 1, null;
        -- 1 NULL
 
+select ifthenelse(false, 'abc', 'abcd');
+       -- abcd
+
 start transaction;
 create or replace function ups() returns int begin if null > 1 then return 1; 
else return 2; end if; end;
 select ups();
diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.out 
b/sql/test/miscellaneous/Tests/simple_selects.stable.out
--- a/sql/test/miscellaneous/Tests/simple_selects.stable.out
+++ b/sql/test/miscellaneous/Tests/simple_selects.stable.out
@@ -441,6 +441,12 @@ project (
 % tinyint,     char # type
 % 1,   0 # length
 [ 1,   NULL    ]
+#select ifthenelse(false, 'abc', 'abcd');
+% .%2 # table_name
+% %2 # name
+% char # type
+% 4 # length
+[ "abcd"       ]
 #start transaction;
 #create or replace function ups() returns int begin if null > 1 then return 1; 
else return 2; end if; end;
 #select ups();
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to