Changeset: af7844b43f51 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/af7844b43f51
Modified Files:
        sql/backends/monet5/sql_statement.c
Branch: default
Log Message:

merged with Dec2025


diffs (87 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
@@ -1930,7 +1930,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                }
                                if (!s)
                                        return s;
-                               if (s->nrcols == 0 && first && left)
+                               if (s->nrcols == 0 && first && left && 
left->nrcols)
                                        s = stmt_const(be, 
bin_find_smallest_column(be, swapped?right:left), s);
                                list_append(ops, s);
                                first = 0;
@@ -4708,6 +4708,7 @@ rel2bin_project(backend *be, sql_rel *re
        psub = stmt_list(be, pl);
        if (psub == NULL)
                return NULL;
+       int nrcols = 0;
        for (en = rel->exps->h; en; en = en->next) {
                sql_exp *exp = en->data;
                int oldvtop = be->mb->vtop, oldstop = be->mb->stop;
@@ -4724,6 +4725,8 @@ rel2bin_project(backend *be, sql_rel *re
                        s = const_column(be, s);
                else if (sub && sub->nrcols >= 1 && s->nrcols == 0)
                        s = stmt_const(be, bin_find_smallest_column(be, sub), 
s);
+               else if (nrcols && s->nrcols == 0)
+                       s = stmt_const(be, pl->h->data, s);
 
                if (!exp_name(exp))
                        exp_label(sql->sa, exp, ++sql->label);
@@ -4731,6 +4734,11 @@ rel2bin_project(backend *be, sql_rel *re
                        s = stmt_rename(be, exp, s);
                        s->label = exp->alias.label;
                }
+               if (!nrcols && s->nrcols && !list_empty(pl)) {
+                       for (node *n = pl->h; n; n=n->next)
+                               n->data = stmt_const(be, s, n->data);
+               }
+               nrcols = s->nrcols;
                list_append(pl, s);
        }
        stmt_set_nrcols(psub);
diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -3282,13 +3282,11 @@ stmt_catalog(backend *be, int type, stmt
 void
 stmt_set_nrcols(stmt *s)
 {
-       unsigned nrcols = 0;
-       int key = 1;
-       node *n;
-       list *l = s->op4.lval;
+       unsigned int nrcols = 0;
+       unsigned int key = 1;
 
        assert(s->type == st_list);
-       for (n = l->h; n; n = n->next) {
+       for (node *n = s->op4.lval->h; n; n = n->next) {
                stmt *f = n->data;
 
                if (!f)
@@ -3308,9 +3306,8 @@ stmt_list(backend *be, list *l)
        if (l == NULL)
                return NULL;
        stmt *s = stmt_create(be->mvc->sa, st_list);
-       if(!s) {
+       if(!s)
                return NULL;
-       }
        s->op4.lval = l;
        stmt_set_nrcols(s);
        return s;
diff --git a/sql/test/BugTracker-2025/Tests/7753-like-in-projection.test 
b/sql/test/BugTracker-2025/Tests/7753-like-in-projection.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2025/Tests/7753-like-in-projection.test
@@ -0,0 +1,2 @@
+statement ok
+select 'Salvador' like '%alva%', 1
diff --git a/sql/test/BugTracker-2025/Tests/All 
b/sql/test/BugTracker-2025/Tests/All
--- a/sql/test/BugTracker-2025/Tests/All
+++ b/sql/test/BugTracker-2025/Tests/All
@@ -74,3 +74,4 @@ 7736-scale-reduction-crash
 7737-join-order
 7744_opt_null_in_where
 KNOWNFAIL?7748-update-returning-subquery-crash
+7753-like-in-projection
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to