Changeset: 8098126e5f80 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8098126e5f80 Modified Files: sql/server/rel_optimizer.c sql/test/SQLancer/Tests/sqlancer08.sql sql/test/SQLancer/Tests/sqlancer08.stable.out Branch: octbugs Log Message:
Making SQLancer happy. Look for null values when trying to simplify a like select diffs (81 lines): diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -7531,7 +7531,7 @@ rel_simplify_like_select(visitor *v, sql list *r = e->r; sql_exp *fmt = r->h->data; sql_exp *esc = (r->h->next)?r->h->next->data:NULL; - int rewrite = 0; + int rewrite = 0, isnull = 0; if (fmt->type == e_convert) fmt = fmt->l; @@ -7541,27 +7541,33 @@ rel_simplify_like_select(visitor *v, sql if (fmt->l) fa = fmt->l; - if (fa && fa->data.vtype == TYPE_str && + if (fa && fa->isnull) + isnull = 1; + else if (fa && fa->data.vtype == TYPE_str && !strchr(fa->data.val.sval, '%') && !strchr(fa->data.val.sval, '_')) rewrite = 1; } - if (rewrite && esc && is_atom(esc->type)) { + if (rewrite && !isnull && esc && is_atom(esc->type)) { atom *ea = NULL; if (esc->l) ea = esc->l; - if (ea && (ea->data.vtype != TYPE_str || + if (ea && ea->isnull) + isnull = 1; + else if (ea && (ea->data.vtype != TYPE_str || strlen(ea->data.val.sval) != 0)) rewrite = 0; } - if (rewrite) { /* rewrite to cmp_equal ! */ + if (isnull) { + list_append(exps, exp_null(v->sql->sa, sql_bind_localtype("bit"))); + v->changes++; + } else if (rewrite) { /* rewrite to cmp_equal ! */ list *l = e->l; list *r = e->r; sql_exp *ne = exp_compare(v->sql->sa, l->h->data, r->h->data, cmp_equal); if (is_anti(e)) set_anti(ne); - /* if rewritten don't cache this query */ list_append(exps, ne); v->changes++; } else { diff --git a/sql/test/SQLancer/Tests/sqlancer08.sql b/sql/test/SQLancer/Tests/sqlancer08.sql --- a/sql/test/SQLancer/Tests/sqlancer08.sql +++ b/sql/test/SQLancer/Tests/sqlancer08.sql @@ -197,3 +197,8 @@ create view v3(vc0) as (values (cast(((a SELECT CAST(SUM(count) AS BIGINT) FROM (SELECT CAST(FALSE AS INT) as count FROM t2, t1, v2 FULL OUTER JOIN t0 ON "isauuid"(r'2A') NATURAL JOIN v1 NATURAL JOIN v3) as res; ROLLBACK; + +START TRANSACTION; +create view v7(vc0, vc1) as (select all 56, replace(r'0.0074401190660642325', "insert"(r'0.9471086251830542', null, 1872651914, r'(Ga_'), r'2]vK') where not (not (false))) with check option; +select 1 from v7 where not (((cast(scale_up(4751, -1823537248) as string(86)))not like(v7.vc1))); +ROLLBACK; diff --git a/sql/test/SQLancer/Tests/sqlancer08.stable.out b/sql/test/SQLancer/Tests/sqlancer08.stable.out --- a/sql/test/SQLancer/Tests/sqlancer08.stable.out +++ b/sql/test/SQLancer/Tests/sqlancer08.stable.out @@ -267,6 +267,14 @@ stdout of test 'sqlancer08` in directory % 1 # length [ NULL ] #ROLLBACK; +#START TRANSACTION; +#create view v7(vc0, vc1) as (select all 56, replace(r'0.0074401190660642325', "insert"(r'0.9471086251830542', null, 1872651914, r'(Ga_'), r'2]vK') where not (not (false))) with check option; +#select 1 from v7 where not (((cast(scale_up(4751, -1823537248) as string(86)))not like(v7.vc1))); +% .%3 # table_name +% %3 # name +% tinyint # type +% 1 # length +#ROLLBACK; # 11:38:36 > # 11:38:36 > "Done." _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list