Changeset: ac62b69878aa for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ac62b69878aa Modified Files: sql/common/sql_types.c sql/server/rel_select.c sql/test/SQLancer/Tests/sqlancer07.sql sql/test/SQLancer/Tests/sqlancer07.stable.out Branch: Oct2020 Log Message:
Making SQLancer happy. Look for parameters when binding an ANY type function and set accodingly (ie use the other parameter type if it's the case) diffs (70 lines): 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 @@ -579,11 +579,12 @@ sql_dup_subfunc(sql_allocator *sa, sql_f if (ops) for (tn = ops->h, m = f->ops->h; tn; tn = tn->next, m = m->next) { sql_arg *s = m->data; + sql_subtype *opt = tn->data; if (s->type.type->eclass == EC_ANY) { if (!st || st->type->eclass == EC_ANY) /* if input parameter is ANY, skip validation */ st = tn->data; - else if (subtype_cmp(st, tn->data)) + else if (opt && subtype_cmp(st, opt)) return NULL; } } 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 @@ -2810,10 +2810,18 @@ rel_binop_(mvc *sql, sql_rel *rel, sql_e if (!t1 || !t2) { f = sql_resolve_function_with_undefined_parameters(sql->sa, s, fname, list_append(list_append(sa_list(sql->sa), t1), t2), type); if (f) { /* add types using f */ - if (!t1) - rel_set_type_param(sql, arg_type(f->func->ops->h->data), rel, l, 1); - if (!t2) - rel_set_type_param(sql, arg_type(f->func->ops->h->next->data), rel, r, 1); + if (!t1) { + sql_subtype *t = arg_type(f->func->ops->h->data); + if (t->type->eclass == EC_ANY && t2) + t = t2; + rel_set_type_param(sql, t, rel, l, 1); + } + if (!t2) { + sql_subtype *t = arg_type(f->func->ops->h->next->data); + if (t->type->eclass == EC_ANY && t1) + t = t1; + rel_set_type_param(sql, t, rel, r, 1); + } f = NULL; if (!exp_subtype(l) || !exp_subtype(r)) diff --git a/sql/test/SQLancer/Tests/sqlancer07.sql b/sql/test/SQLancer/Tests/sqlancer07.sql --- a/sql/test/SQLancer/Tests/sqlancer07.sql +++ b/sql/test/SQLancer/Tests/sqlancer07.sql @@ -159,3 +159,6 @@ DROP TABLE t2; SELECT 1 WHERE (SELECT 1 WHERE FALSE) IS NULL; -- 1 + +PREPARE SELECT 1 WHERE greatest(true, ?); + -- ? should be set to true diff --git a/sql/test/SQLancer/Tests/sqlancer07.stable.out b/sql/test/SQLancer/Tests/sqlancer07.stable.out --- a/sql/test/SQLancer/Tests/sqlancer07.stable.out +++ b/sql/test/SQLancer/Tests/sqlancer07.stable.out @@ -225,6 +225,13 @@ stdout of test 'sqlancer07` in directory % tinyint # type % 1 # length [ 1 ] +#PREPARE SELECT 1 WHERE greatest(true, ?); +% .prepare, .prepare, .prepare, .prepare, .prepare, .prepare # table_name +% type, digits, scale, schema, table, column # name +% varchar, int, int, str, str, str # type +% 7, 1, 1, 0, 2, 2 # length +[ "tinyint", 1, 0, "", "%2", "%2" ] +[ "boolean", 1, 0, NULL, NULL, NULL ] # 10:16:14 > # 10:16:14 > "Done." _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list