Changeset: 2462c472670a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2462c472670a Added Files: sql/test/BugTracker-2017/Tests/function-resolution.Bug-6436.sql sql/test/BugTracker-2017/Tests/function-resolution.Bug-6436.stable.err sql/test/BugTracker-2017/Tests/function-resolution.Bug-6436.stable.out sql/test/BugTracker-2017/Tests/generate-resolution.Bug-6471.sql sql/test/BugTracker-2017/Tests/generate-resolution.Bug-6471.stable.err sql/test/BugTracker-2017/Tests/generate-resolution.Bug-6471.stable.out Modified Files: sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out.int128 sql/benchmarks/tpch/LOCKED/Tests/22.stable.out.int128 sql/benchmarks/tpch/Tests/01-22.stable.out sql/benchmarks/tpch/Tests/01-22.stable.out.int128 sql/benchmarks/tpch/Tests/22.stable.out.int128 sql/common/sql_types.c sql/common/sql_types.h sql/server/rel_optimizer.c sql/server/rel_select.c sql/test/BugDay_2005-10-06_2.9.3/Tests/variable_arg_substring.SF_942981.stable.out sql/test/BugTracker-2010/Tests/substring_display_width.Bug-2683.stable.out sql/test/BugTracker-2015/Tests/string_split.Bug-3564.stable.out sql/test/BugTracker-2017/Tests/All sql/test/BugTracker-2017/Tests/splitpart.Bug-6194.stable.out sql/test/Tests/string.stable.out sql/test/pg_regress/Tests/strings.stable.out Branch: default Log Message:
Merge with Jul2017 branch. diffs (truncated from 1095 to 300 lines): diff --git a/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out b/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out --- a/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out +++ b/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out @@ -610,7 +610,7 @@ Ready. # and l_shipdate < l_commitdate # and l_receiptdate >= date '1994-01-01' # and l_receiptdate < date '1994-01-01' + interval '1' year -% sys.lineitem, sys.L4, sys.L7 # table_name +% sys.lineitem, sys.L6, sys.L11 # table_name % l_shipmode, high_line_count, low_line_count # name % char, bigint, bigint # type % 10, 2, 2 # length @@ -743,7 +743,7 @@ Ready. # p_brand, # p_type, # p_size; -% sys.part, sys.part, sys.part, sys.L15 # table_name +% sys.part, sys.part, sys.part, sys.L13 # table_name % p_brand, p_type, p_size, supplier_cnt # name % char, varchar, int, bigint # type % 10, 25, 2, 1 # length @@ -1108,8 +1108,8 @@ Ready. # o_totalprice desc, # o_orderdate #limit 100; -% sys.customer, sys.customer, sys.orders, sys.orders, sys.orders, sys.L22 # table_name -% c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, L21 # name +% sys.customer, sys.customer, sys.orders, sys.orders, sys.orders, sys.L17 # table_name +% c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, L16 # name % varchar, int, int, date, decimal, decimal # type % 18, 3, 5, 10, 17, 20 # length [ "Customer#000000667", 667, 29158, 1995-10-21, 439687.23, 305.00 ] @@ -1140,7 +1140,7 @@ Ready. # and p_brand = 'Brand#23' # and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') # and l_quantity >= 10 and l_quantity <= 10 + 10 -% sys.L4 # table_name +% sys.L33 # table_name % revenue # name % decimal # type % 20 # length diff --git a/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out.int128 b/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out.int128 --- a/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out.int128 +++ b/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out.int128 @@ -610,7 +610,7 @@ Ready. # and l_shipdate < l_commitdate # and l_receiptdate >= date '1994-01-01' # and l_receiptdate < date '1994-01-01' + interval '1' year -% sys.lineitem, sys.L4, sys.L7 # table_name +% sys.lineitem, sys.L6, sys.L11 # table_name % l_shipmode, high_line_count, low_line_count # name % char, hugeint, hugeint # type % 10, 2, 2 # length @@ -743,7 +743,7 @@ Ready. # p_brand, # p_type, # p_size; -% sys.part, sys.part, sys.part, sys.L15 # table_name +% sys.part, sys.part, sys.part, sys.L13 # table_name % p_brand, p_type, p_size, supplier_cnt # name % char, varchar, int, bigint # type % 10, 25, 2, 1 # length @@ -1108,8 +1108,8 @@ Ready. # o_totalprice desc, # o_orderdate #limit 100; -% sys.customer, sys.customer, sys.orders, sys.orders, sys.orders, sys.L22 # table_name -% c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, L21 # name +% sys.customer, sys.customer, sys.orders, sys.orders, sys.orders, sys.L17 # table_name +% c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, L16 # name % varchar, int, int, date, decimal, decimal # type % 18, 3, 5, 10, 17, 40 # length [ "Customer#000000667", 667, 29158, 1995-10-21, 439687.23, 305.00 ] @@ -1140,7 +1140,7 @@ Ready. # and p_brand = 'Brand#23' # and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') # and l_quantity >= 10 and l_quantity <= 10 + 10 -% sys.L4 # table_name +% sys.L33 # table_name % revenue # name % decimal # type % 40 # length @@ -1263,10 +1263,10 @@ Ready. # select # * # from -% sys.custsale, sys.L17, sys.L22 # table_name +% sys.custsale, sys.L21, sys.L24 # table_name % cntrycode, numcust, totacctbal # name -% char, bigint, decimal # type -% 15, 2, 40 # length +% clob, bigint, decimal # type +% 2, 2, 40 # length [ "13", 10, 75359.29 ] [ "17", 8, 62288.98 ] [ "18", 14, 111072.45 ] diff --git a/sql/benchmarks/tpch/LOCKED/Tests/22.stable.out.int128 b/sql/benchmarks/tpch/LOCKED/Tests/22.stable.out.int128 --- a/sql/benchmarks/tpch/LOCKED/Tests/22.stable.out.int128 +++ b/sql/benchmarks/tpch/LOCKED/Tests/22.stable.out.int128 @@ -55,10 +55,10 @@ Ready. # select # * # from -% sys.custsale, sys.L17, sys.L22 # table_name +% sys.custsale, sys.L21, sys.L24 # table_name % cntrycode, numcust, totacctbal # name -% char, bigint, decimal # type -% 15, 2, 40 # length +% clob, bigint, decimal # type +% 2, 2, 40 # length [ "13", 10, 75359.29 ] [ "17", 8, 62288.98 ] [ "18", 14, 111072.45 ] diff --git a/sql/benchmarks/tpch/Tests/01-22.stable.out b/sql/benchmarks/tpch/Tests/01-22.stable.out --- a/sql/benchmarks/tpch/Tests/01-22.stable.out +++ b/sql/benchmarks/tpch/Tests/01-22.stable.out @@ -610,7 +610,7 @@ Ready. # and l_shipdate < l_commitdate # and l_receiptdate >= date '1994-01-01' # and l_receiptdate < date '1994-01-01' + interval '1' year -% sys.lineitem, sys.L4, sys.L7 # table_name +% sys.lineitem, sys.L6, sys.L11 # table_name % l_shipmode, high_line_count, low_line_count # name % char, bigint, bigint # type % 10, 2, 2 # length @@ -739,7 +739,7 @@ Ready. # p_brand, # p_type, # p_size; -% sys.part, sys.part, sys.part, sys.L15 # table_name +% sys.part, sys.part, sys.part, sys.L13 # table_name % p_brand, p_type, p_size, supplier_cnt # name % char, varchar, int, bigint # type % 10, 25, 2, 1 # length @@ -1104,8 +1104,8 @@ Ready. # o_totalprice desc, # o_orderdate #limit 100; -% sys.customer, sys.customer, sys.orders, sys.orders, sys.orders, sys.L22 # table_name -% c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, L21 # name +% sys.customer, sys.customer, sys.orders, sys.orders, sys.orders, sys.L17 # table_name +% c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, L16 # name % varchar, int, int, date, decimal, decimal # type % 18, 3, 5, 10, 17, 20 # length [ "Customer#000000667", 667, 29158, 1995-10-21, 439687.23, 305.00 ] @@ -1136,7 +1136,7 @@ Ready. # and p_brand = 'Brand#23' # and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') # and l_quantity >= 10 and l_quantity <= 10 + 10 -% sys.L4 # table_name +% sys.L33 # table_name % revenue # name % decimal # type % 20 # length diff --git a/sql/benchmarks/tpch/Tests/01-22.stable.out.int128 b/sql/benchmarks/tpch/Tests/01-22.stable.out.int128 --- a/sql/benchmarks/tpch/Tests/01-22.stable.out.int128 +++ b/sql/benchmarks/tpch/Tests/01-22.stable.out.int128 @@ -610,7 +610,7 @@ Ready. # and l_shipdate < l_commitdate # and l_receiptdate >= date '1994-01-01' # and l_receiptdate < date '1994-01-01' + interval '1' year -% sys.lineitem, sys.L4, sys.L7 # table_name +% sys.lineitem, sys.L6, sys.L11 # table_name % l_shipmode, high_line_count, low_line_count # name % char, hugeint, hugeint # type % 10, 2, 2 # length @@ -743,7 +743,7 @@ Ready. # p_brand, # p_type, # p_size; -% sys.part, sys.part, sys.part, sys.L15 # table_name +% sys.part, sys.part, sys.part, sys.L13 # table_name % p_brand, p_type, p_size, supplier_cnt # name % char, varchar, int, bigint # type % 10, 25, 2, 1 # length @@ -1108,8 +1108,8 @@ Ready. # o_totalprice desc, # o_orderdate #limit 100; -% sys.customer, sys.customer, sys.orders, sys.orders, sys.orders, sys.L22 # table_name -% c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, L21 # name +% sys.customer, sys.customer, sys.orders, sys.orders, sys.orders, sys.L17 # table_name +% c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, L16 # name % varchar, int, int, date, decimal, decimal # type % 18, 3, 5, 10, 17, 40 # length [ "Customer#000000667", 667, 29158, 1995-10-21, 439687.23, 305.00 ] @@ -1140,7 +1140,7 @@ Ready. # and p_brand = 'Brand#23' # and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') # and l_quantity >= 10 and l_quantity <= 10 + 10 -% sys.L4 # table_name +% sys.L33 # table_name % revenue # name % decimal # type % 40 # length @@ -1225,10 +1225,10 @@ Ready. # select # * # from -% sys.custsale, sys.L17, sys.L22 # table_name +% sys.custsale, sys.L21, sys.L24 # table_name % cntrycode, numcust, totacctbal # name -% char, bigint, decimal # type -% 15, 2, 40 # length +% clob, bigint, decimal # type +% 2, 2, 40 # length [ "13", 10, 75359.29 ] [ "17", 8, 62288.98 ] [ "18", 14, 111072.45 ] diff --git a/sql/benchmarks/tpch/Tests/22.stable.out.int128 b/sql/benchmarks/tpch/Tests/22.stable.out.int128 --- a/sql/benchmarks/tpch/Tests/22.stable.out.int128 +++ b/sql/benchmarks/tpch/Tests/22.stable.out.int128 @@ -55,10 +55,10 @@ Ready. # select # * # from -% sys.custsale, sys.L17, sys.L22 # table_name +% sys.custsale, sys.L21, sys.L24 # table_name % cntrycode, numcust, totacctbal # name -% char, bigint, decimal # type -% 15, 2, 40 # length +% clob, bigint, decimal # type +% 2, 2, 40 # length [ "13", 10, 75359.29 ] [ "17", 8, 62288.98 ] [ "18", 14, 111072.45 ] diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c --- a/sql/common/sql_types.c +++ b/sql/common/sql_types.c @@ -666,13 +666,20 @@ sql_dup_subfunc(sql_allocator *sa, sql_f if (!member) { node *m; + sql_arg *ma = NULL; if (ops) for (tn = ops->h, m = f->ops->h; tn; tn = tn->next, m = m->next) { sql_arg *s = m->data; - if (s->type.type->eclass == EC_ANY) { + if (!member && s->type.type->eclass == EC_ANY) { member = tn->data; - break; + ma = s; + } + /* largest type */ + if (member && s->type.type->eclass == EC_ANY && + s->type.type->localtype > ma->type.type->localtype ) { + member = tn->data; + ma = s; } } } @@ -817,6 +824,59 @@ sql_find_func(sql_allocator *sa, sql_sch return NULL; } +list * +sql_find_funcs(sql_allocator *sa, sql_schema *s, const char *sqlfname, int nrargs, int type) +{ + sql_subfunc *fres; + int key = hash_key(sqlfname); + sql_hash_e *he; + int filt = (type == F_FUNC)?F_FILT:type; + list *res = sa_list(sa); + + assert(nrargs); + MT_lock_set(&funcs->ht_lock); + he = funcs->ht->buckets[key&(funcs->ht->size-1)]; + for (; he; he = he->chain) { + sql_func *f = he->value; + + if (f->type != type && f->type != filt) + continue; + if ((fres = func_cmp(sa, f, sqlfname, nrargs )) != NULL) + list_append(res, fres); + } + MT_lock_unset(&funcs->ht_lock); + if (s) { + node *n; + + if (s->funcs.set) { + MT_lock_set(&s->funcs.set->ht_lock); + if (s->funcs.set->ht) { + he = s->funcs.set->ht->buckets[key&(s->funcs.set->ht->size-1)]; + for (; he; he = he->chain) { + sql_func *f = he->value; + + if (f->type != type && f->type != filt) + continue; + if ((fres = func_cmp(sa, f, sqlfname, nrargs )) != NULL) + list_append(res, fres); + } + } else { + n = s->funcs.set->h; + for (; n; n = n->next) { + sql_func *f = n->data; + + if (f->type != type && f->type != filt) + continue; + if ((fres = func_cmp(sa, f, sqlfname, nrargs )) != NULL) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list