Changeset: ca9824e7f56a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ca9824e7f56a
Added Files:
        sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.sql
        sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.stable.err
        sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.stable.out
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/test/BugTracker-2020/Tests/All
Branch: Oct2020
Log Message:

fixed bug 7001
(improved checks for when to run a binary join)


diffs (117 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2177,11 +2177,11 @@ split_join_exps(sql_rel *rel, list *join
                                                        left_reference = 
right_reference = 1;
                                                }
                                        } else {
-                                               if (l->card != CARD_ATOM) {
+                                               if (l->card != CARD_ATOM || 
!exp_is_atom(l)) {
                                                        left_reference += 
rel_find_exp(rel->l, l) != NULL;
                                                        right_reference += 
rel_find_exp(rel->r, l) != NULL;
                                                }
-                                               if (r->card != CARD_ATOM) {
+                                               if (r->card != CARD_ATOM || 
!exp_is_atom(r)) {
                                                        left_reference += 
rel_find_exp(rel->l, r) != NULL;
                                                        right_reference += 
rel_find_exp(rel->r, r) != NULL;
                                                }
@@ -2192,7 +2192,7 @@ split_join_exps(sql_rel *rel, list *join
                                        for (node *n = l->h ; n ; n = n->next) {
                                                sql_exp *ee = n->data;
 
-                                               if (ee->card != CARD_ATOM) {
+                                               if (ee->card != CARD_ATOM || 
!exp_is_atom(ee)) {
                                                        left_reference += 
rel_find_exp(rel->l, ee) != NULL;
                                                        right_reference += 
rel_find_exp(rel->r, ee) != NULL;
                                                }
@@ -2200,7 +2200,7 @@ split_join_exps(sql_rel *rel, list *join
                                        for (node *n = r->h ; n ; n = n->next) {
                                                sql_exp *ee = n->data;
 
-                                               if (ee->card != CARD_ATOM) {
+                                               if (ee->card != CARD_ATOM || 
!exp_is_atom(ee)) {
                                                        left_reference += 
rel_find_exp(rel->l, ee) != NULL;
                                                        right_reference += 
rel_find_exp(rel->r, ee) != NULL;
                                                }
diff --git a/sql/test/BugTracker-2020/Tests/All 
b/sql/test/BugTracker-2020/Tests/All
--- a/sql/test/BugTracker-2020/Tests/All
+++ b/sql/test/BugTracker-2020/Tests/All
@@ -26,3 +26,4 @@ table-udf-column-descriptor.Bug-6964
 table-udf-distinct.Bug-6965
 HAVE_PYMONETDB?table-udf-on-remote.Bug-6971
 integers-intervals.Bug-6979
+semijoin.Bug-7001
diff --git a/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.sql 
b/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.sql
@@ -0,0 +1,16 @@
+create procedure profiler.starttrace() external name profiler."starttrace";
+create procedure profiler.stoptrace() external name profiler.stoptrace;
+
+create table i as select * from (VALUES (1),(2),(3)) as x(n);
+
+call profiler."starttrace"();
+
+with
+t as (select 1 as r, * from sys.functions where name in ('sum', 'prod'))
+select distinct name from t where r in (select n from i);
+
+call profiler.stoptrace();
+-- no crossproducts
+select count(*) from sys.tracelog() where stmt like '%cross%';
+
+drop table i;
diff --git a/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.stable.err 
b/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.stable.err
@@ -0,0 +1,12 @@
+stderr of test 'semijoin.Bug-7001` in directory 'sql/test/BugTracker-2020` 
itself:
+
+
+# 16:35:34 >  
+# 16:35:34 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-593559" "--port=39764"
+# 16:35:34 >  
+
+
+# 16:35:34 >  
+# 16:35:34 >  "Done."
+# 16:35:34 >  
+
diff --git a/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.stable.out 
b/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2020/Tests/semijoin.Bug-7001.stable.out
@@ -0,0 +1,31 @@
+stdout of test 'semijoin.Bug-7001` in directory 'sql/test/BugTracker-2020` 
itself:
+
+
+# 16:35:34 >  
+# 16:35:34 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-593559" "--port=39764"
+# 16:35:34 >  
+
+#create procedure profiler.starttrace() external name profiler."starttrace";
+#create procedure profiler.stoptrace() external name profiler.stoptrace;
+#create table i as select * from (VALUES (1),(2),(3)) as x(n);
+#with
+#t as (select 1 as r, * from sys.functions where name in ('sum', 'prod'))
+#select distinct name from t where r in (select n from i);
+% sys.t # table_name
+% name # name
+% varchar # type
+% 4 # length
+[ "sum"        ]
+[ "prod"       ]
+#select count(*) from sys.tracelog() where stmt like '%cross%';
+% .%2 # table_name
+% %2 # name
+% bigint # type
+% 1 # length
+[ 0    ]
+#drop table i;
+
+# 16:35:34 >  
+# 16:35:34 >  "Done."
+# 16:35:34 >  
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to