Changeset: aea2d5422943 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/aea2d5422943
Modified Files:
        sql/server/rel_dump.c
        sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
        
sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.test
        sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test
        sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
        sql/test/SQLancer/Tests/sqlancer19.SQL.py
        sql/test/analytics/Tests/analytics00.test
        sql/test/bugs/Tests/rtrim_bug.test
        sql/test/miscellaneous/Tests/simple_plans.test
        sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
        sql/test/sys-schema/Tests/webExamplesLogicalFunctionsOperators.test
        sql/test/sys-schema/Tests/webExamplesMathematicalFunctionsOperators.test
Branch: default
Log Message:

Don't print aliases at inner expressions


diffs (truncated from 438 to 300 lines):

diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -134,19 +134,22 @@ exp_print(mvc *sql, stream *fout, sql_ex
                } else if (e->flag & PSM_WHILE) {
                        mnstr_printf(fout, "while ");
                        exp_print(sql, fout, e->l, depth, refs, 0, 0);
-                       exps_print(sql, fout, e->r, depth, refs, alias, 0);
+                       exps_print(sql, fout, e->r, depth, refs, 0, 0);
+                       alias = 0;
                } else if (e->flag & PSM_IF) {
                        mnstr_printf(fout, "if ");
                        exp_print(sql, fout, e->l, depth, refs, 0, 0);
-                       exps_print(sql, fout, e->r, depth, refs, alias, 0);
+                       exps_print(sql, fout, e->r, depth, refs, 0, 0);
                        if (e->f)
-                               exps_print(sql, fout, e->f, depth, refs, alias, 
0);
+                               exps_print(sql, fout, e->f, depth, refs, 0, 0);
+                       alias = 0;
                } else if (e->flag & PSM_REL) {
                        rel_print_(sql, fout, e->l, depth+10, refs, 1);
                } else if (e->flag & PSM_EXCEPTION) {
                        mnstr_printf(fout, "except ");
                        exp_print(sql, fout, e->l, depth, refs, 0, 0);
                        mnstr_printf(fout, " error %s", (const char *) e->r);
+                       alias = 0;
                }
                break;
        }
@@ -198,11 +201,11 @@ exp_print(mvc *sql, stream *fout, sql_ex
                mnstr_printf(fout, "\"%s\".\"%s\"",
                                f->func->s?dump_escape_ident(sql->ta, 
f->func->s->base.name):"sys",
                                dump_escape_ident(sql->ta, f->func->base.name));
-               exps_print(sql, fout, e->l, depth, refs, alias, 1);
+               exps_print(sql, fout, e->l, depth, refs, 0, 1);
                if (e->r) { /* list of optional lists */
                        list *l = e->r;
                        for(node *n = l->h; n; n = n->next)
-                               exps_print(sql, fout, n->data, depth, refs, 
alias, 1);
+                               exps_print(sql, fout, n->data, depth, refs, 0, 
1);
                }
                if (e->flag && is_compare_func(f))
                        mnstr_printf(fout, " %s", e->flag==1?"ANY":"ALL");
@@ -219,7 +222,7 @@ exp_print(mvc *sql, stream *fout, sql_ex
                if (zero_if_empty(e))
                        mnstr_printf(fout, " zero if empty ");
                if (e->l)
-                       exps_print(sql, fout, e->l, depth, refs, alias, 1);
+                       exps_print(sql, fout, e->l, depth, refs, 0, 1);
                else
                        mnstr_printf(fout, "()");
        }       break;
@@ -238,25 +241,25 @@ exp_print(mvc *sql, stream *fout, sql_ex
                break;
        case e_cmp:
                if (e->flag == cmp_in || e->flag == cmp_notin) {
-                       exp_print(sql, fout, e->l, depth, refs, 0, alias);
+                       exp_print(sql, fout, e->l, depth, refs, 0, 0);
                        if (is_anti(e))
                                mnstr_printf(fout, " !");
                        cmp_print(sql, fout, e->flag);
-                       exps_print(sql, fout, e->r, depth, refs, alias, 1);
+                       exps_print(sql, fout, e->r, depth, refs, 0, 1);
                } else if (e->flag == cmp_or) {
-                       exps_print(sql, fout, e->l, depth, refs, alias, 1);
+                       exps_print(sql, fout, e->l, depth, refs, 0, 1);
                        if (is_anti(e))
                                mnstr_printf(fout, " !");
                        cmp_print(sql, fout, e->flag);
-                       exps_print(sql, fout, e->r, depth, refs, alias, 1);
+                       exps_print(sql, fout, e->r, depth, refs, 0, 1);
                } else if (e->flag == cmp_filter) {
                        sql_subfunc *f = e->f;
 
-                       exps_print(sql, fout, e->l, depth, refs, alias, 1);
+                       exps_print(sql, fout, e->l, depth, refs, 0, 1);
                        if (is_anti(e))
                                mnstr_printf(fout, " !");
                        mnstr_printf(fout, " FILTER \"%s\" ", 
dump_escape_ident(sql->ta, f->func->base.name));
-                       exps_print(sql, fout, e->r, depth, refs, alias, 1);
+                       exps_print(sql, fout, e->r, depth, refs, 0, 1);
                } else if (e->f) {
                        exp_print(sql, fout, e->r, depth+1, refs, 0, 0);
                        if (is_anti(e))
diff --git a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test 
b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
--- a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
+++ b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
@@ -15,7 +15,7 @@ project (
 | group by (
 | | table("sys"."dbg") [ "dbg"."a", "dbg"."b" ]
 | ) [ "dbg"."a" as "d" ] [ "d", "sys"."min" no nil ("dbg"."b") as "%1"."%1" ]
-) [ "d", "%1"."%1", "sys"."sql_mul"("sys"."sql_div"("%1"."%1", tinyint "2" as 
"%2"."%2"), tinyint "2") as "f" ]
+) [ "d", "%1"."%1", "sys"."sql_mul"("sys"."sql_div"("%1"."%1", tinyint "2"), 
tinyint "2") as "f" ]
 
 statement ok
 set optimizer = 'sequential_pipe'
@@ -50,7 +50,7 @@ project (
 | group by (
 | | table("sys"."dbg") [ "dbg"."a", "dbg"."b" ]
 | ) [ "dbg"."a" as "d" ] [ "d", "sys"."min" no nil ("dbg"."b") as "%1"."%1" ]
-) [ "d", "%1"."%1" as "e", "sys"."sql_mul"("sys"."sql_div"("%1"."%1", tinyint 
"2" as "%2"."%2"), tinyint "2") as "f" ]
+) [ "d", "%1"."%1" as "e", "sys"."sql_mul"("sys"."sql_div"("%1"."%1", tinyint 
"2"), tinyint "2") as "f" ]
 
 statement ok
 set optimizer = 'sequential_pipe'
diff --git 
a/sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.test 
b/sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.test
--- a/sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.test
+++ b/sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.test
@@ -12,7 +12,7 @@ project (
 | | project (
 | | | table("sys"."x") [ "x"."y" ]
 | | ) [ "x"."y", double "0" as "%2"."%2" ]
-| ) [  ] [ "sys"."quantile" no nil (decimal(18,3)["x"."y"] as "x"."y", 
"%2"."%2" NOT NULL) as "%1"."%1" ]
+| ) [  ] [ "sys"."quantile" no nil (decimal(18,3)["x"."y"], "%2"."%2" NOT 
NULL) as "%1"."%1" ]
 ) [ "%1"."%1" ]
 
 query T nosort
@@ -23,7 +23,7 @@ project (
 | | project (
 | | | table("sys"."x") [ "x"."y" ]
 | | ) [ "x"."y", double "0" as "%2"."%2" ]
-| ) [  ] [ "sys"."quantile" no nil (decimal(18,3)["x"."y"] as "x"."y", 
"%2"."%2" NOT NULL) as "%1"."%1" ]
+| ) [  ] [ "sys"."quantile" no nil (decimal(18,3)["x"."y"], "%2"."%2" NOT 
NULL) as "%1"."%1" ]
 ) [ "%1"."%1" ]
 
 statement ok
diff --git a/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test 
b/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test
--- a/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test
+++ b/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test
@@ -60,9 +60,9 @@ project (
 | | | | | | ) [ "input_double"."a1" = clob "longitude" ]
 | | | | | ) [ "input_double"."a2" as "tmp_3"."a2" ]
 | | | | ) [  ]
-| | | ) [ "sys"."st_point"("tmp_2"."a2" as "tmp"."a1", "tmp_3"."a2" as 
"tmp"."a2") as "p"."a1" ]
+| | | ) [ "sys"."st_point"("tmp_2"."a2", "tmp_3"."a2") as "p"."a1" ]
 | | ) [  ]
-| ) [ "v"."a1" as "r"."a1", "sys"."st_distance"("v"."a2" as "tmp"."a2", 
"p"."a1" as "tmp"."a3") as "r"."prob" ]
+| ) [ "v"."a1" as "r"."a1", "sys"."st_distance"("v"."a2", "p"."a1") as 
"r"."prob" ]
 ) [ "r"."a1", "r"."prob" ]
 
 statement ok
diff --git a/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test 
b/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
--- a/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
+++ b/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
@@ -58,14 +58,14 @@ project (
 | | | | | | select (
 | | | | | | | table("sys"."plantest0") [ "plantest0"."id" ]
 | | | | | | ) [ "plantest0"."id" >= bigint "150000000" ]
-| | | | | ) [ "sys"."sql_div"("plantest0"."id" as "v"."id", int "10000000") as 
"t"."id_r" ]
+| | | | | ) [ "sys"."sql_div"("plantest0"."id", int "10000000") as "t"."id_r" ]
 | | | | ) [ "t"."id_r" ] [ "t"."id_r", "sys"."count" no nil ("t"."id_r") NOT 
NULL as "%6"."%6" ],
 | | | | group by (
 | | | | | project (
 | | | | | | select (
 | | | | | | | table("sys"."plantest1") [ "plantest1"."id" ]
 | | | | | | ) [ "plantest1"."id" >= bigint "150000000" ]
-| | | | | ) [ "sys"."sql_div"("plantest1"."id" as "v"."id", int "10000000") as 
"t"."id_r" ]
+| | | | | ) [ "sys"."sql_div"("plantest1"."id", int "10000000") as "t"."id_r" ]
 | | | | ) [ "t"."id_r" ] [ "t"."id_r", "sys"."count" no nil ("t"."id_r") NOT 
NULL as "%6"."%6" ]
 | | | ) [ "t"."id_r", "%6"."%6" ]
 | | ) [ "t"."id_r" ] [ "t"."id_r", "sys"."sum" no nil ("%6"."%6") as "%6"."%6" 
]
@@ -118,7 +118,7 @@ project (
 | | | | | | | select (
 | | | | | | | | table("sys"."plantest0") [ "plantest0"."id" ]
 | | | | | | | ) [ "plantest0"."id" >= bigint "150000000" ]
-| | | | | | ) [ "sys"."sql_div"("plantest0"."id" as "v"."id", int "10000000") 
as "v"."id_div" ]
+| | | | | | ) [ "sys"."sql_div"("plantest0"."id", int "10000000") as 
"v"."id_div" ]
 | | | | | ) [ "v"."id_div" as "t"."id_r" ]
 | | | | ) [ "t"."id_r" ] [ "t"."id_r", "sys"."count" no nil ("t"."id_r") NOT 
NULL as "%6"."%6" ],
 | | | | group by (
@@ -127,7 +127,7 @@ project (
 | | | | | | | select (
 | | | | | | | | table("sys"."plantest1") [ "plantest1"."id" ]
 | | | | | | | ) [ "plantest1"."id" >= bigint "150000000" ]
-| | | | | | ) [ "sys"."sql_div"("plantest1"."id" as "v"."id", int "10000000") 
as "v"."id_div" ]
+| | | | | | ) [ "sys"."sql_div"("plantest1"."id", int "10000000") as 
"v"."id_div" ]
 | | | | | ) [ "v"."id_div" as "t"."id_r" ]
 | | | | ) [ "t"."id_r" ] [ "t"."id_r", "sys"."count" no nil ("t"."id_r") NOT 
NULL as "%6"."%6" ]
 | | | ) [ "t"."id_r", "%6"."%6" ]
diff --git a/sql/test/SQLancer/Tests/sqlancer19.SQL.py 
b/sql/test/SQLancer/Tests/sqlancer19.SQL.py
--- a/sql/test/SQLancer/Tests/sqlancer19.SQL.py
+++ b/sql/test/SQLancer/Tests/sqlancer19.SQL.py
@@ -95,6 +95,10 @@ with SQLTestCase() as cli:
         .assertSucceeded().assertDataResultMatch([(Decimal('0.02000'),)])
     cli.execute("SELECT CAST(2 AS DECIMAL) * 0.010 FROM rt3 where rt3.c0 = 
1;") \
         .assertSucceeded().assertDataResultMatch([(Decimal('0.02000'),)])
+    cli.execute("SELECT t3.c0 FROM t3 where (t3.c0) NOT IN (0.07564294, 211.0, 
1, 2) ORDER BY t3.c0;") \
+        .assertSucceeded().assertDataResultMatch([(5,),(5,),(7,)])
+    cli.execute("SELECT rt3.c0 FROM rt3 where (rt3.c0) NOT IN (0.07564294, 
211.0, 1, 2) ORDER BY rt3.c0;") \
+        .assertSucceeded().assertDataResultMatch([(5,),(5,),(7,)])
     cli.execute("SELECT t3.c0 FROM t3 INNER JOIN t3 myx ON t3.c0 = myx.c0 
ORDER BY t3.c0;") \
         
.assertSucceeded().assertDataResultMatch([(1,),(2,),(2,),(2,),(2,),(5,),(5,),(5,),(5,),(7,)])
     cli.execute("SELECT rt3.c0 FROM rt3 INNER JOIN rt3 myx ON rt3.c0 = myx.c0 
ORDER BY rt3.c0;") \
diff --git a/sql/test/analytics/Tests/analytics00.test 
b/sql/test/analytics/Tests/analytics00.test
--- a/sql/test/analytics/Tests/analytics00.test
+++ b/sql/test/analytics/Tests/analytics00.test
@@ -1872,7 +1872,7 @@ project (
 | | | | table("sys"."myorders") [ "myorders"."o_custkey" NOT NULL, 
"myorders"."o_totalprice" NOT NULL, "myorders"."o_orderdate" NOT NULL ]
 | | | ) [ "myorders"."o_custkey" NOT NULL, "myorders"."o_totalprice" NOT NULL, 
"sys"."month"("myorders"."o_orderdate" NOT NULL) NOT NULL as "%1"."%1" ]
 | | ) [ "myorders"."o_custkey" NOT NULL, "myorders"."o_totalprice" NOT NULL, 
"%1"."%1" NOT NULL ] [ "myorders"."o_custkey" ASC NOT NULL, "%1"."%1" ASC NOT 
NULL ]
-| ) [ "%1"."%1" NOT NULL, "sys"."diff"("myorders"."o_custkey" NOT NULL) as 
"%2"."%2", "sys"."diff"("%1"."%1" NOT NULL) as "%3"."%3", 
"sys"."min"("myorders"."o_totalprice" NOT NULL, "%2"."%2", 
"sys"."diff"("%1"."%1" NOT NULL) as "%3"."%3", int "0", 
"sys"."window_bound"("%2"."%2", "%3"."%3", int "0", int "0", int "0", bigint 
"9223372036854775807"), "sys"."window_bound"("%2"."%2", "%3"."%3", int "0", int 
"5", int "0", bigint "0")) as "%4"."%4" ]
+| ) [ "%1"."%1" NOT NULL, "sys"."diff"("myorders"."o_custkey" NOT NULL) as 
"%2"."%2", "sys"."diff"("%1"."%1" NOT NULL) as "%3"."%3", 
"sys"."min"("myorders"."o_totalprice" NOT NULL, "%2"."%2", 
"sys"."diff"("%1"."%1" NOT NULL), int "0", "sys"."window_bound"("%2"."%2", 
"%3"."%3", int "0", int "0", int "0", bigint "9223372036854775807"), 
"sys"."window_bound"("%2"."%2", "%3"."%3", int "0", int "5", int "0", bigint 
"0")) as "%4"."%4" ]
 ) [ "%4"."%4" ]
 
 query R rowsort
@@ -1910,7 +1910,7 @@ project (
 | | | | table("sys"."myorders") [ "myorders"."o_totalprice" NOT NULL, 
"myorders"."o_orderdate" NOT NULL ]
 | | | ) [ "myorders"."o_totalprice" NOT NULL, 
"sys"."year"("myorders"."o_orderdate" NOT NULL) NOT NULL as "%1"."%1" ]
 | | ) [ "myorders"."o_totalprice" NOT NULL, "%1"."%1" NOT NULL ] [ "%1"."%1" 
ASC NOT NULL ]
-| ) [ "%1"."%1" NOT NULL, boolean "false" as "%2"."%2", "sys"."diff"("%1"."%1" 
NOT NULL) as "%3"."%3", "sys"."count"("myorders"."o_totalprice" NOT NULL, 
boolean "true", "%2"."%2" NOT NULL, "sys"."diff"("%1"."%1" NOT NULL) as 
"%3"."%3", int "2", "sys"."window_bound"("%3"."%3", int "2", int "0", int "0", 
tinyint "2"), "sys"."window_bound"("%3"."%3", int "2", int "3", int "0", bigint 
"9223372036854775807")) as "%4"."%4" ]
+| ) [ "%1"."%1" NOT NULL, boolean "false" as "%2"."%2", "sys"."diff"("%1"."%1" 
NOT NULL) as "%3"."%3", "sys"."count"("myorders"."o_totalprice" NOT NULL, 
boolean "true", "%2"."%2" NOT NULL, "sys"."diff"("%1"."%1" NOT NULL), int "2", 
"sys"."window_bound"("%3"."%3", int "2", int "0", int "0", tinyint "2"), 
"sys"."window_bound"("%3"."%3", int "2", int "3", int "0", bigint 
"9223372036854775807")) as "%4"."%4" ]
 ) [ "%4"."%4" ]
 
 query I rowsort
diff --git a/sql/test/bugs/Tests/rtrim_bug.test 
b/sql/test/bugs/Tests/rtrim_bug.test
--- a/sql/test/bugs/Tests/rtrim_bug.test
+++ b/sql/test/bugs/Tests/rtrim_bug.test
@@ -55,7 +55,7 @@ project (
 | | | ) [ "sys"."rtrim"("t1"."m" NOT NULL) NOT NULL as "%1"."%1" ]
 | | ) [ "%1"."%1" NOT NULL as "%4"."%4" ]
 | ) [ "%5"."%5" NOT NULL any = "%4"."%4" NOT NULL ]
-) [ "sys"."length"("t1"."m" NOT NULL as "v2"."m") NOT NULL as "data_length", 
"t1"."m" NOT NULL as "data_value" ]
+) [ "sys"."length"("t1"."m" NOT NULL) NOT NULL as "data_length", "t1"."m" NOT 
NULL as "data_value" ]
 
 statement ok
 set optimizer = 'sequential_pipe'
diff --git a/sql/test/miscellaneous/Tests/simple_plans.test 
b/sql/test/miscellaneous/Tests/simple_plans.test
--- a/sql/test/miscellaneous/Tests/simple_plans.test
+++ b/sql/test/miscellaneous/Tests/simple_plans.test
@@ -23,7 +23,7 @@ project (
 | group by (
 | | project (
 | | | table("sys"."myy") [ "myy"."col1", "myy"."col2" ]
-| | ) [ "sys"."sql_add"(bigint["myy"."col1"] as "myy"."col1", 
bigint["myy"."col2"] as "myy"."col2") as "%1"."%1" ]
+| | ) [ "sys"."sql_add"(bigint["myy"."col1"], bigint["myy"."col2"]) as 
"%1"."%1" ]
 | ) [ "%1"."%1" ] [ "%1"."%1" ]
 ) [ "%1"."%1" ] [ "%1"."%1" ASC ]
 
diff --git 
a/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test 
b/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
--- a/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
+++ b/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
@@ -712,47 +712,47 @@ select CASE WHEN 9 = 9 THEN NULL ELSE 9 
 ----
 NULL
 
-query T rowsort
+query T nosort
 plan select nullif(null, null)
 ----
-) [ "sys"."nullif"(smallint "NULL", smallint "NULL") ]
 project (
 |  [ boolean "true" ]
+) [ "sys"."nullif"(smallint "NULL", smallint "NULL") ]
 
-query T rowsort
+query T nosort
 plan select CASE WHEN null = null THEN NULL ELSE null END
 ----
-) [ "sys"."case"(boolean "NULL", smallint "NULL", smallint "NULL") ]
 project (
 |  [ boolean "true" ]
+) [ "sys"."case"(boolean "NULL", smallint "NULL", smallint "NULL") ]
 
-query T rowsort
+query T nosort
 plan select nullif('ac', 'ac')
 ----
-) [ "sys"."nullif"(char(2) "ac", char(2) "ac") ]
 project (
 |  [ boolean "true" ]
+) [ "sys"."nullif"(char(2) "ac", char(2) "ac") ]
 
-query T rowsort
+query T nosort
 plan select CASE WHEN 'ac' = 'ac' THEN NULL ELSE 'ac' END
 ----
-) [ "sys"."case"("sys"."="(char(2) "ac", char(2) "ac") NOT NULL, char "NULL", 
char "ac") ]
 project (
 |  [ boolean "true" ]
+) [ "sys"."case"("sys"."="(char(2) "ac", char(2) "ac") NOT NULL, char "NULL", 
char "ac") ]
 
-query T rowsort
+query T nosort
 plan select nullif(9, 9)
 ----
-) [ "sys"."nullif"(tinyint "9", tinyint "9") ]
 project (
 |  [ boolean "true" ]
+) [ "sys"."nullif"(tinyint "9", tinyint "9") ]
 
-query T rowsort
+query T nosort
 plan select CASE WHEN 9 = 9 THEN NULL ELSE 9 END
 ----
-) [ "sys"."case"("sys"."="(tinyint "9", tinyint "9") NOT NULL, tinyint "NULL", 
tinyint "9") ]
 project (
 |  [ boolean "true" ]
+) [ "sys"."case"("sys"."="(tinyint "9", tinyint "9") NOT NULL, tinyint "NULL", 
tinyint "9") ]
 
 query T rowsort
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to