Changeset: bc942e85e007 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bc942e85e007
Modified Files:
        sql/server/rel_optimize_proj.c
        sql/test/miscellaneous/Tests/simple_plans.test
Branch: default
Log Message:

Use right pointer


diffs (35 lines):

diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -1471,13 +1471,10 @@ rel_simplify_sum(visitor *v, sql_rel *re
                                                                add_col = false;
                                                        }
                                                }
-                                               /* 'col' is not in the under 
relation, so add it */
-                                               if (add_col) {
-                                                       ocol = exp_ref(v->sql, 
ocol);
-                                                       exp_label(v->sql->sa, 
ocol, ++v->sql->label);
-                                               }
-
                                                colref = exp_ref(v->sql, ocol);
+                                               if (add_col) /* if 'col' will 
be added, then make sure it has an unique label */
+                                                       exp_label(v->sql->sa, 
colref, ++v->sql->label);
+
                                                /* 'oexp' contains the type for 
the input for the 'sum' aggregate */
                                                if (!(colref = 
exp_check_type(v->sql, exp_subtype(oexp), groupby, colref, type_equal))) {
                                                        v->sql->session->status 
= 0;
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
@@ -693,3 +693,11 @@ project (
 | | ) [  ] [ "sys"."sum" no nil ("%11"."%11") as "%14"."%14", "sys"."count"() 
NOT NULL as "%12"."%12" ]
 | ) [ "sys"."sql_add"("%14"."%14", "sys"."sql_mul"(smallint(9) "2", 
"%12"."%12" NOT NULL) NOT NULL) as "%7"."%7" ]
 ) [ "%7"."%7" ]
+
+query I nosort
+SELECT sum(CASE x.x WHEN 1 THEN 1 END + 2) FROM (select distinct 1) x(x)
+UNION ALL
+SELECT sum(CASE x.x WHEN 1 THEN 1 END + 2) FROM (select distinct 1) x(x)
+----
+3
+3
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to