Changeset: b25399891430 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b25399891430
Modified Files:
sql/server/rel_unnest.c
sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out
sql/test/BugTracker-2019/Tests/subselect.Bug-6700.stable.out
Branch: default
Log Message:
fixed bug 6700 (is handle count(1) with outer ref like count(*))
approved output
diffs (210 lines):
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -469,6 +469,18 @@ push_up_select(mvc *sql, sql_rel *rel)
return rel;
}
+static int
+exps_is_constant( list *exps )
+{
+ sql_exp *e;
+
+ if (!exps || list_empty(exps))
+ return 1;
+ if (list_length(exps) > 1)
+ return 0;
+ e = exps->h->data;
+ return exp_is_atom(e);
+}
static sql_rel *
push_up_groupby(mvc *sql, sql_rel *rel)
@@ -487,8 +499,8 @@ push_up_groupby(mvc *sql, sql_rel *rel)
for (n = r->exps->h; n; n = n->next ) {
sql_exp *e = n->data;
- /* count_nil(*) -> count(t.TID) */
- if (e->type == e_aggr && strcmp(((sql_subaggr
*)e->f)->aggr->base.name, "count") == 0 && !e->l) {
+ /* count_nil(* or constant) -> count(t.TID) */
+ if (e->type == e_aggr && strcmp(((sql_subaggr
*)e->f)->aggr->base.name, "count") == 0 && (!e->l || exps_is_constant(e->l))) {
sql_exp *col;
sql_rel *p = r->l; /* ugh */
diff --git
a/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out
b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out
--- a/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out
+++ b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out
@@ -20,11 +20,9 @@ stdout of test 'alter_table_set_schema.B
# MonetDB/Python2 module loaded
# MonetDB/R module loaded
-Ready.
-
-# 19:03:57 >
-# 19:03:57 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-21054" "--port=38092"
-# 19:03:57 >
+# 10:51:21 >
+# 10:51:21 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-4922" "--port=33370"
+# 10:51:21 >
#SELECT * FROM sys.columns WHERE table_id NOT IN (SELECT id FROM sys.tables);
% .columns, .columns, .columns, .columns, .columns,
.columns, .columns, .columns, .columns, .columns #
table_name
@@ -69,13 +67,13 @@ Ready.
% 1 # length
[ 1 ]
#select count(*) as count_rows from keys where table_id in (select id from
tables where name = 'test2');
-% sys.L103 # table_name
+% sys.L44 # table_name
% count_rows # name
% bigint # type
% 1 # length
[ 1 ]
#select count(*) as count_rows from objects where id in (select id from keys
where table_id in (select id from tables where name = 'test2'));
-% sys.L205 # table_name
+% sys.L46 # table_name
% count_rows # name
% bigint # type
% 1 # length
@@ -88,13 +86,13 @@ Ready.
% 1 # length
[ 1 ]
#select count(*) as count_rows from keys where table_id in (select id from
tables where name = 'test2');
-% sys.L103 # table_name
+% sys.L44 # table_name
% count_rows # name
% bigint # type
% 1 # length
[ 1 ]
#select count(*) as count_rows from objects where id in (select id from keys
where table_id in (select id from tables where name = 'test2'));
-% sys.L205 # table_name
+% sys.L46 # table_name
% count_rows # name
% bigint # type
% 1 # length
@@ -107,13 +105,13 @@ Ready.
% 1 # length
[ 1 ]
#select count(*) as count_rows from keys where table_id in (select id from
tables where name = 'test2');
-% sys.L103 # table_name
+% sys.L44 # table_name
% count_rows # name
% bigint # type
% 1 # length
[ 1 ]
#select count(*) as count_rows from objects where id in (select id from keys
where table_id in (select id from tables where name = 'test2'));
-% sys.L205 # table_name
+% sys.L46 # table_name
% count_rows # name
% bigint # type
% 1 # length
@@ -126,13 +124,13 @@ Ready.
% 1 # length
[ 1 ]
#select count(*) as count_rows from keys where table_id in (select id from
tables where name = 'test2');
-% sys.L103 # table_name
+% sys.L44 # table_name
% count_rows # name
% bigint # type
% 1 # length
[ 1 ]
#select count(*) as count_rows from objects where id in (select id from keys
where table_id in (select id from tables where name = 'test2'));
-% sys.L205 # table_name
+% sys.L46 # table_name
% count_rows # name
% bigint # type
% 1 # length
diff --git a/sql/test/BugTracker-2019/Tests/subselect.Bug-6700.stable.out
b/sql/test/BugTracker-2019/Tests/subselect.Bug-6700.stable.out
--- a/sql/test/BugTracker-2019/Tests/subselect.Bug-6700.stable.out
+++ b/sql/test/BugTracker-2019/Tests/subselect.Bug-6700.stable.out
@@ -60,11 +60,9 @@ stdout of test 'subselect.Bug-6700` in d
# MonetDB/Python2 module loaded
# MonetDB/R module loaded
-Ready.
-
-# 09:38:47 >
-# 09:38:47 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-26939" "--port=36777"
-# 09:38:47 >
+# 10:51:20 >
+# 10:51:20 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-4922" "--port=33370"
+# 10:51:20 >
#start transaction;
#create table "testTable1" (
@@ -94,8 +92,8 @@ Ready.
# from "testTable1" "inner"
# where ("inner"."B" = "outer"."A")
#) from "testTable1" "outer";
-% .outer, .outer, .L7 # table_name
-% A, B, L7 # name
+% sys.outer, sys.outer, .L6 # table_name
+% A, B, L6 # name
% varchar, varchar, bigint # type
% 4, 4, 1 # length
[ "Cat1", "Cat1", 2 ]
@@ -106,8 +104,8 @@ Ready.
# from "testTable1" "inner"
# where ("inner"."B" = "outer"."A")
#) from "testTable1" "outer";
-% .outer, .outer, .L7 # table_name
-% A, B, L7 # name
+% sys.outer, sys.outer, .L6 # table_name
+% A, B, L6 # name
% varchar, varchar, bigint # type
% 4, 4, 1 # length
[ "Cat1", "Cat1", 2 ]
@@ -118,8 +116,8 @@ Ready.
# from "testTable1" "inner"
# where ("inner"."B" = "outer"."A") and ("outer"."A" is not null)
#) from "testTable1" "outer";
-% .outer, .outer, .L7 # table_name
-% A, B, L7 # name
+% sys.outer, sys.outer, .L6 # table_name
+% A, B, L6 # name
% varchar, varchar, bigint # type
% 4, 4, 1 # length
[ "Cat1", "Cat1", 2 ]
@@ -130,8 +128,8 @@ Ready.
# from "testTable1" "inner"
# where ("inner"."B" = "outer"."A") and ("outer"."A" is not null)
#) from "testTable1" "outer";
-% .outer, .outer, .L7 # table_name
-% A, B, L7 # name
+% sys.outer, sys.outer, .L6 # table_name
+% A, B, L6 # name
% varchar, varchar, bigint # type
% 4, 4, 1 # length
[ "Cat1", "Cat1", 2 ]
@@ -145,8 +143,8 @@ Ready.
# ("inner"."A" is null and "outer"."A" is null)
# )
#) from "testTable2" "outer";
-% .outer, .outer, .L7 # table_name
-% A, B, L7 # name
+% sys.outer, sys.outer, .L6 # table_name
+% A, B, L6 # name
% varchar, double, double # type
% 4, 24, 24 # length
[ "Cat1", 2, 2 ]
@@ -161,8 +159,8 @@ Ready.
# ("inner"."A" is null and "outer"."A" is null)
# ) and ("A" = 'Cat7')
#) from "testTable2" "outer";
-% .outer, .outer, .L7 # table_name
-% A, B, L7 # name
+% sys.outer, sys.outer, .L6 # table_name
+% A, B, L6 # name
% varchar, double, double # type
% 4, 24, 24 # length
[ "Cat1", 2, NULL ]
@@ -177,8 +175,8 @@ Ready.
# ("inner"."A" is null and "outer"."A" is null)
# ) and (true = false)
#) from "testTable2" "outer";
-% .outer, .outer, sys.L7 # table_name
-% A, B, L7 # name
+% sys.outer, sys.outer, .L6 # table_name
+% A, B, L6 # name
% varchar, double, double # type
% 4, 24, 24 # length
[ "Cat1", 2, NULL ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list