Changeset: cb65d5c6c0b6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cb65d5c6c0b6 Modified Files: sql/server/rel_optimizer.c sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.sql sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out.int128 sql/test/leaks/Tests/check4.stable.out sql/test/leaks/Tests/check4.stable.out.int128 Branch: Jul2017 Log Message:
approved output of test 3947 (IS null/constant bug fix) fixed problem with distinct and order by over columns not in the result projection. diffs (187 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 @@ -2238,6 +2238,20 @@ rel_distinct_project2groupby(int *change list *exps = new_exp_list(sql->sa), *gbe = new_exp_list(sql->sa); list *obe = rel->r; /* we need to readd the ordering later */ + if (obe) { + int fnd = 0; + + for(n = obe->h; n && !fnd; n = n->next) { + sql_exp *e = n->data; + + if (e->type != e_column) + fnd = 1; + else if (exps_bind_column2(rel->exps, e->l, e->r) == 0) + fnd = 1; + } + if (fnd) + return rel; + } rel->l = rel_project(sql->sa, rel->l, rel->exps); for (n = rel->exps->h; n; n = n->next) { diff --git a/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.sql b/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.sql --- a/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.sql +++ b/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.sql @@ -33,6 +33,7 @@ SELECT * FROM (SELECT cast(null as char( SELECT cast(null as char(1)) AS "CAT", a AS "A", c AS "C" FROM t_alias WHERE "CAT" IS NULL or "CAT" = NULL; -- SELECT: identifier 'CAT' unknown SELECT * FROM (SELECT cast(null as char(1)) AS "CAT", a AS "A", c AS "C" FROM t_alias) T1 WHERE "CAT" IS NULL or "CAT" = NULL; +SELECT * FROM (SELECT cast(null as char(1)) AS "CAT", a AS "A", c AS "C" FROM t_alias) T1 WHERE "CAT" IS NULL and "CAT" = NULL; -- column aliases can be used in ORDER BY and GROUP BY clauses SELECT a AS "A", b AS "B", c AS "C" FROM t_alias ORDER BY "C", "A", "B"; diff --git a/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out b/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out --- a/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out +++ b/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out @@ -123,7 +123,9 @@ Ready. % .t1, sys.t1, sys.t1 # table_name % CAT, A, C # name % char, int, varchar # type -% 1, 1, 0 # length +% 1, 2, 4 # length +[ NULL, 1, "tien" ] +[ NULL, 11, "elf" ] #SELECT * FROM (SELECT cast(null as char(1)) AS "CAT", a AS "A", c AS "C" FROM t_alias) T1 WHERE "CAT" IS NULL or "CAT" = NULL; % .t1, sys.t1, sys.t1 # table_name % CAT, A, C # name @@ -131,6 +133,11 @@ Ready. % 1, 2, 4 # length [ NULL, 1, "tien" ] [ NULL, 11, "elf" ] +#SELECT * FROM (SELECT cast(null as char(1)) AS "CAT", a AS "A", c AS "C" FROM t_alias) T1 WHERE "CAT" IS NULL and "CAT" = NULL; +% .t1, sys.t1, sys.t1 # table_name +% CAT, A, C # name +% char, int, varchar # type +% 1, 1, 0 # length #SELECT a AS "A", b AS "B", c AS "C" FROM t_alias ORDER BY "C", "A", "B"; % sys.L2, sys.L4, sys.L6 # table_name % A, B, C # name diff --git a/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out.int128 b/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out.int128 --- a/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out.int128 +++ b/sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out.int128 @@ -127,7 +127,9 @@ Ready. % .t1, sys.t1, sys.t1 # table_name % CAT, A, C # name % char, int, varchar # type -% 1, 1, 0 # length +% 1, 2, 4 # length +[ NULL, 1, "tien" ] +[ NULL, 11, "elf" ] #SELECT * FROM (SELECT cast(null as char(1)) AS "CAT", a AS "A", c AS "C" FROM t_alias) T1 WHERE "CAT" IS NULL or "CAT" = NULL; % .t1, sys.t1, sys.t1 # table_name % CAT, A, C # name @@ -135,6 +137,11 @@ Ready. % 1, 2, 4 # length [ NULL, 1, "tien" ] [ NULL, 11, "elf" ] +#SELECT * FROM (SELECT cast(null as char(1)) AS "CAT", a AS "A", c AS "C" FROM t_alias) T1 WHERE "CAT" IS NULL and "CAT" = NULL; +% .t1, sys.t1, sys.t1 # table_name +% CAT, A, C # name +% char, int, varchar # type +% 1, 1, 0 # length #SELECT a AS "A", b AS "B", c AS "C" FROM t_alias ORDER BY "C", "A", "B"; % sys.L2, sys.L4, sys.L6 # table_name % A, B, C # name diff --git a/sql/test/leaks/Tests/check4.stable.out b/sql/test/leaks/Tests/check4.stable.out --- a/sql/test/leaks/Tests/check4.stable.out +++ b/sql/test/leaks/Tests/check4.stable.out @@ -205,8 +205,8 @@ Ready. [ "oid", 0 ] [ "oid", 0 ] [ "oid", 0 ] -[ "oid", 2 ] -[ "oid", 4 ] +[ "oid", 0 ] +[ "oid", 0 ] [ "oid", 6 ] [ "sht", 0 ] [ "sht", 0 ] diff --git a/sql/test/leaks/Tests/check4.stable.out.int128 b/sql/test/leaks/Tests/check4.stable.out.int128 --- a/sql/test/leaks/Tests/check4.stable.out.int128 +++ b/sql/test/leaks/Tests/check4.stable.out.int128 @@ -41,8 +41,8 @@ Ready. [ "bit", 0 ] [ "bit", 0 ] [ "bit", 5 ] -[ "bit", 62 ] -[ "bit", 389 ] +[ "bit", 60 ] +[ "bit", 385 ] [ "bit", 1743 ] [ "bit", 1743 ] [ "bit", 1743 ] @@ -101,19 +101,19 @@ Ready. [ "int", 36 ] [ "int", 52 ] [ "int", 52 ] -[ "int", 62 ] -[ "int", 62 ] +[ "int", 60 ] +[ "int", 60 ] [ "int", 278 ] [ "int", 300 ] [ "int", 300 ] [ "int", 300 ] [ "int", 300 ] [ "int", 300 ] -[ "int", 389 ] -[ "int", 389 ] -[ "int", 389 ] -[ "int", 389 ] -[ "int", 389 ] +[ "int", 385 ] +[ "int", 385 ] +[ "int", 385 ] +[ "int", 385 ] +[ "int", 385 ] [ "int", 389 ] [ "int", 389 ] [ "int", 1743 ] @@ -205,8 +205,8 @@ Ready. [ "oid", 0 ] [ "oid", 0 ] [ "oid", 0 ] -[ "oid", 2 ] -[ "oid", 4 ] +[ "oid", 0 ] +[ "oid", 0 ] [ "oid", 6 ] [ "sht", 0 ] [ "sht", 0 ] @@ -220,9 +220,9 @@ Ready. [ "sht", 10 ] [ "sht", 10 ] [ "sht", 15 ] -[ "sht", 62 ] -[ "sht", 62 ] -[ "sht", 62 ] +[ "sht", 60 ] +[ "sht", 60 ] +[ "sht", 60 ] [ "sht", 389 ] [ "str", 0 ] [ "str", 0 ] @@ -293,14 +293,14 @@ Ready. [ "str", 36 ] [ "str", 36 ] [ "str", 52 ] -[ "str", 62 ] -[ "str", 62 ] +[ "str", 60 ] +[ "str", 60 ] [ "str", 218 ] [ "str", 278 ] -[ "str", 389 ] -[ "str", 389 ] -[ "str", 389 ] -[ "str", 389 ] +[ "str", 385 ] +[ "str", 385 ] +[ "str", 385 ] +[ "str", 385 ] [ "str", 1743 ] [ "str", 1743 ] [ "str", 1743 ] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list