Changeset: 24363863fa47 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=24363863fa47
Modified Files:
        sql/backends/monet5/rel_bin.c
Branch: default
Log Message:

fix exp2bin_casewhen handling, ie keeping various candidates in sync.


diffs (48 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
@@ -785,6 +785,11 @@ exp2bin_casewhen(backend *be, sql_exp *f
                if (!l)
                        l = bin_first_column(be, left);
                case_when = stmt_const(be, l, case_when);
+               if (case_when)
+                       case_when->cand = isel;
+       }
+       if (!single_value && isel && !case_when->cand) {
+               case_when = stmt_project(be, isel, case_when);
                case_when->cand = isel;
        }
 
@@ -811,11 +816,27 @@ exp2bin_casewhen(backend *be, sql_exp *f
                        return NULL;
                if (next_cond) {
                        stmt *l = case_when;
-                       assert(!es->cand || !l->cand || es->cand == l->cand);
-                       if (es->cand && !l->cand)
-                               l = stmt_project(be, es->cand, case_when);
-                       else if (l->cand && !es->cand)
-                               es = stmt_project(be, l->cand, es);
+                       if (!single_value) {
+                               if (rsel && isel) {
+                                       assert(l->cand == isel);
+                                       l = stmt_project(be, rsel, l);
+                                       l->cand = nsel;
+                               }
+
+                               if (es->cand && !l->cand) {
+                                       assert(es->cand == rsel);
+                                       l = stmt_project(be, es->cand, l);
+                                       l->cand = es->cand;
+                               } else if (nsel && !es->cand) {
+                                       es = stmt_project(be, nsel, es);
+                                       es->cand = nsel;
+                                       if (!l->cand) {
+                                               l = stmt_project(be, nsel, l);
+                                               l->cand = nsel;
+                                       }
+                               }
+                               assert(l->cand == es->cand);
+                       }
                        es = stmt_binop(be, l, es, NULL, cmp);
                }
                if (!single_value) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to