Changeset: 108a4f6c62d2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=108a4f6c62d2
Modified Files:
        sql/server/rel_select.c
        sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.stable.out
        sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.err
        sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.out
Branch: Oct2020
Log Message:

small fix for old view issue # 7023


diffs (101 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -5221,9 +5221,12 @@ rel_table_exp(sql_query *query, sql_rel 
                }
 
                if (project->op == op_project && project->l && project == *rel 
&& !tname && !rel_is_ref(project) && !need_distinct(project) && single_exp) {
-                       rel_remove_internal_exp(*rel);
-                       exps = project->exps;
-                       *rel = project->l;
+                       sql_rel *l = project->l;
+                       if (!l || !is_project(l->op) || 
list_length(project->exps) == list_length(l->exps)) {
+                               rel_remove_internal_exp(*rel);
+                               exps = project->exps;
+                               *rel = project->l;
+                       }
                }
                if ((exps || (exps = rel_table_projections(sql, project, tname, 
0)) != NULL) && !list_empty(exps)) {
                        if (groupby) {
diff --git a/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.stable.out 
b/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.stable.out
--- a/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.stable.out
+++ b/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.stable.out
@@ -59,26 +59,28 @@ stdout of test 'merge_project.Bug-3955` 
 % .plan # table_name
 % rel # name
 % clob # type
-% 105 # length
+% 107 # length
 project (
-| crossproduct (
-| | table(sys.v) [ "v"."a1", "v"."a2" ] COUNT ,
-| | project (
-| | | crossproduct (
-| | | | project (
-| | | | | select (
-| | | | | | table(sys.input_double) [ "input_double"."a1", "input_double"."a2" 
] COUNT 
-| | | | | ) [ "input_double"."a1" = clob "latitude" ]
-| | | | ) [ "input_double"."a2" as "tmp_2"."a2" ],
-| | | | project (
-| | | | | select (
-| | | | | | table(sys.input_double) [ "input_double"."a1", "input_double"."a2" 
] COUNT 
-| | | | | ) [ "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" ]
-| ) [  ]
-) [ "v"."a1" as "r"."a1", sys.st_distance("v"."a2" as "tmp"."a2", "p"."a1" as 
"tmp"."a3") as "r"."prob" ]
+| project (
+| | crossproduct (
+| | | table(sys.v) [ "v"."a1", "v"."a2" ] COUNT ,
+| | | project (
+| | | | crossproduct (
+| | | | | project (
+| | | | | | select (
+| | | | | | | table(sys.input_double) [ "input_double"."a1", 
"input_double"."a2" ] COUNT 
+| | | | | | ) [ "input_double"."a1" = clob "latitude" ]
+| | | | | ) [ "input_double"."a2" as "tmp_2"."a2" ],
+| | | | | project (
+| | | | | | select (
+| | | | | | | table(sys.input_double) [ "input_double"."a1", 
"input_double"."a2" ] COUNT 
+| | | | | | ) [ "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" ]
+| | ) [  ]
+| ) [ "v"."a1" as "r"."a1", sys.st_distance("v"."a2" as "tmp"."a2", "p"."a1" 
as "tmp"."a3") as "r"."prob" ]
+) [ "r"."a1", "r"."prob" ]
 
 # 14:00:10 >  
 # 14:00:10 >  "Done."
diff --git 
a/sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.err 
b/sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.err
--- a/sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.err
+++ b/sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.err
@@ -5,12 +5,8 @@ stderr of test 'view_with_aggr_column.Bu
 # 15:22:56 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-177928" "--port=37553"
 # 15:22:56 >  
 
-MAPI  = (monetdb) /var/tmp/mtest-177928/.s.monetdb.37553
-QUERY = select * from v1;
-
-CODE  = 42000
 
-# 15:22:56 >  
-# 15:22:56 >  "Done."
-# 15:22:56 >  
+# 16:13:27 >  
+# 16:13:27 >  "Done."
+# 16:13:27 >  
 
diff --git 
a/sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.out 
b/sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.out
--- a/sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.out
+++ b/sql/test/BugTracker-2020/Tests/view_with_aggr_column.Bug-7023.stable.out
@@ -14,7 +14,7 @@ stdout of test 'view_with_aggr_column.Bu
 % 1 # length
 #create view v1 as select max(k) from tst group by name;
 #select * from v1;
-% sys.%1 # table_name
+% sys.v1 # table_name
 % %1 # name
 % int # type
 % 1 # length
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to