Changeset: 0e994d510109 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0e994d510109
Modified Files:
        clients/Tests/MAL-signatures-hge.test
        clients/Tests/MAL-signatures.test
        monetdb5/modules/kernel/algebra.c
        sql/backends/monet5/rel_bin.c
        sql/server/rel_exp.c
        sql/server/rel_exp.h
        sql/server/rel_optimize_others.c
        sql/server/rel_optimize_proj.c
        sql/server/rel_statistics.c
        sql/server/rel_unnest.c
        sql/storage/bat/bat_storage.c
        sql/test/BugTracker-2026/Tests/All
        tools/merovingian/daemon/merovingian.c
Branch: default
Log Message:

Merge with Dec2025 branch.


diffs (truncated from 3981 to 300 lines):

diff --git a/ChangeLog.Dec2025 b/ChangeLog.Dec2025
--- a/ChangeLog.Dec2025
+++ b/ChangeLog.Dec2025
@@ -1,3 +1,7 @@
 # ChangeLog file for devel
 # This file is updated with Maddlog
 
+* Thu Apr 23 2026 Sjoerd Mullender <[email protected]>
+- It is no longer allowed to run mserver5 or monetdbd as root.  There are
+  important security concerns when these servers are run as root.
+
diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -48222,12 +48222,12 @@ mmath
 log2arg
 command mmath.log2arg(X_0:dbl, X_1:dbl):dbl
 MATHbinary_LOGdbl
-The log(x) function returns the logarithm of x in the given base.
+The log(base,x) function returns the logarithm of x in the given base.
 mmath
 log2arg
 command mmath.log2arg(X_0:flt, X_1:flt):flt
 MATHbinary_LOGflt
-The log(x) function returns the logarithm of x in the given base.
+(empty)
 mmath
 nextafter
 command mmath.nextafter(X_0:dbl, X_1:dbl):dbl
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -36707,12 +36707,12 @@ mmath
 log2arg
 command mmath.log2arg(X_0:dbl, X_1:dbl):dbl
 MATHbinary_LOGdbl
-The log(x) function returns the logarithm of x in the given base.
+The log(base,x) function returns the logarithm of x in the given base.
 mmath
 log2arg
 command mmath.log2arg(X_0:flt, X_1:flt):flt
 MATHbinary_LOGflt
-The log(x) function returns the logarithm of x in the given base.
+(empty)
 mmath
 nextafter
 command mmath.nextafter(X_0:dbl, X_1:dbl):dbl
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -57,6 +57,7 @@ static gdk_return
 CMDgen_group(BAT **result, BAT *gids, BAT *cnts)
 {
        BUN j;
+       BUN n = 0;
        BATiter gi = bat_iterator(gids);
        BAT *r = COLnew(0, TYPE_oid, gi.count * 2, TRANSIENT);
 
@@ -65,38 +66,45 @@ CMDgen_group(BAT **result, BAT *gids, BA
                return GDK_FAIL;
        }
        BATiter ci = bat_iterator(cnts);
+       oid *rp = (oid *) Tloc(r, 0);
        if (gi.type == TYPE_void) {
                oid id = gi.tseq;
                lng *cnt = (lng *) ci.base;
                for (j = 0; j < gi.count; j++) {
-                       lng i, sz = cnt[j];
-                       for (i = 0; i < sz; i++) {
-                               if (BUNappend(r, &id, false) != GDK_SUCCEED) {
-                                       BBPreclaim(r);
-                                       bat_iterator_end(&ci);
-                                       bat_iterator_end(&gi);
-                                       return GDK_FAIL;
+                       for (lng sz = cnt[j], i = 0; i < sz; i++) {
+                               if (n >= BATcapacity(r)) {
+                                       r->theap->free = n * sizeof(oid);
+                                       BUN sz = BATgrows(r);
+                                       if (BATextend(r, sz) != GDK_SUCCEED) {
+                                               BBPreclaim(r);
+                                               return GDK_FAIL;
+                                       }
+                                       rp = (oid *) Tloc(r, 0);
                                }
+                               rp[n++] = id;
                        }
-                       id ++;
+                       id++;
                }
        } else {
-               oid *id = (oid *) gi.base;
+               oid *idp = (oid *) gi.base;
                lng *cnt = (lng *) ci.base;
                for (j = 0; j < gi.count; j++) {
-                       lng i, sz = cnt[j];
-                       for (i = 0; i < sz; i++) {
-                               if (BUNappend(r, id, false) != GDK_SUCCEED) {
-                                       BBPreclaim(r);
-                                       bat_iterator_end(&ci);
-                                       bat_iterator_end(&gi);
-                                       return GDK_FAIL;
+                       for (lng sz = cnt[j], i = 0; i < sz; i++) {
+                               if (n >= BATcapacity(r)) {
+                                       r->theap->free = n * sizeof(oid);
+                                       BUN sz = BATgrows(r);
+                                       if (BATextend(r, sz) != GDK_SUCCEED) {
+                                               BBPreclaim(r);
+                                               return GDK_FAIL;
+                                       }
+                                       rp = (oid *) Tloc(r, 0);
                                }
+                               rp[n++] = idp[j];
                        }
-                       id ++;
                }
        }
        bat_iterator_end(&ci);
+       BATsetcount(r, n);
        r->tkey = false;
        r->tseqbase = oid_nil;
        r->tsorted = gi.sorted;
diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c
--- a/monetdb5/modules/kernel/mmath.c
+++ b/monetdb5/modules/kernel/mmath.c
@@ -362,8 +362,8 @@ static mel_func mmath_init_funcs[] = {
  command("mmath", "exp", MATHunary_EXPdbl, false, "The exp(x) function returns 
the value of e (the base of \nnatural logarithms) raised to the power of x.", 
args(1,2, arg("",dbl),arg("x",dbl))),
  command("mmath", "log", MATHunary_LOGflt, false, "", args(1,2, 
arg("",flt),arg("x",flt))),
  command("mmath", "log", MATHunary_LOGdbl, false, "The log(x) function returns 
the natural logarithm of x.", args(1,2, arg("",dbl),arg("x",dbl))),
- command("mmath", "log2arg", MATHbinary_LOGflt, false, "The log(x) function 
returns the logarithm of x in the given base.", args(1,3, 
arg("",flt),arg("x",flt),arg("base",flt))),
- command("mmath", "log2arg", MATHbinary_LOGdbl, false, "The log(x) function 
returns the logarithm of x in the given base.", args(1,3, 
arg("",dbl),arg("x",dbl),arg("base",dbl))),
+ command("mmath", "log2arg", MATHbinary_LOGflt, false, "", args(1,3, 
arg("",flt),arg("x",flt),arg("base",flt))),
+ command("mmath", "log2arg", MATHbinary_LOGdbl, false, "The log(base,x) 
function returns the logarithm of x in the given base.", args(1,3, 
arg("",dbl),arg("x",dbl),arg("base",dbl))),
  command("mmath", "log10", MATHunary_LOG10flt, false, "", args(1,2, 
arg("",flt),arg("x",flt))),
  command("mmath", "log10", MATHunary_LOG10dbl, false, "The log10(x) function 
returns the base-10 logarithm of x.", args(1,2, arg("",dbl),arg("x",dbl))),
  command("mmath", "log2", MATHunary_LOG2flt, false, "", args(1,2, 
arg("",flt),arg("x",flt))),
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
@@ -1939,6 +1939,10 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                        s = exp_bin(be, n->data, right, NULL, 
grp, ext, cnt, NULL, depth+1, 0, push);
                                        swapped = 1;
                                }
+                               if (!s && right && !reduce) {
+                                       clean_mal_statements(be, oldstop, 
oldvtop);
+                                       s = exp_bin(be, n->data, left, right, 
grp, ext, cnt, NULL, depth+1, 0, push);
+                               }
                                if (!s)
                                        return s;
                                if (s->nrcols == 0 && first && left && 
left->nrcols)
diff --git a/sql/common/sql_list.c b/sql/common/sql_list.c
--- a/sql/common/sql_list.c
+++ b/sql/common/sql_list.c
@@ -713,6 +713,8 @@ list_map(list *l, void *data, fmap map)
 list *
 list_join(list *l, list *data)
 {
+       if (!l)
+               return data;
        assert(data->sa);
        assert(data->sa == l->sa);
        assert(!l->ht);
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -3392,6 +3392,28 @@ exp_copy(mvc *sql, sql_exp * e)
        return ne;
 }
 
+list *
+exps_refs(mvc *sql, list *exps)
+{
+       if (mvc_highwater(sql)) {
+               return sql_error(sql, 10, SQLSTATE(42000) "Query too complex: 
running out of stack space");
+       }
+       if (!exps) {
+               return NULL;
+       }
+       list *nexps = new_exp_list(sql->sa);
+       for (node *n = exps->h; n; n = n->next) {
+               sql_exp *arg = n->data;
+
+               arg = exp_ref(sql, arg);
+               if (!arg) {
+                       return NULL;
+               }
+               append(nexps, arg);
+       }
+       return nexps;
+}
+
 /* scaling for the division operator */
 static sql_exp *
 exp_scale_algebra(mvc *sql, sql_subfunc *f, sql_rel *rel, sql_exp *l, sql_exp 
*r)
diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h
--- a/sql/server/rel_exp.h
+++ b/sql/server/rel_exp.h
@@ -127,6 +127,7 @@ extern list* exps_label(mvc *sql, list *
 extern sql_exp * exp_copy( mvc *sql, sql_exp *e);
 extern list * exps_copy( mvc *sql, list *exps);
 extern list * exps_alias( mvc *sql, list *exps);
+extern list * exps_refs( mvc *sql, list *exps); /* create new list of 
references to the exps */
 
 extern void exp_swap( sql_exp *e );
 
diff --git a/sql/server/rel_optimize_others.c b/sql/server/rel_optimize_others.c
--- a/sql/server/rel_optimize_others.c
+++ b/sql/server/rel_optimize_others.c
@@ -440,7 +440,8 @@ rel_exps_mark_used(allocator *sa, sql_re
                }
 
                if (!nr && is_project(rel->op) && len > 0) /* project at least 
one column if exists */
-                       exps[0]->used = 1;
+                       if (!is_freevar(exps[0]))
+                               exps[0]->used = 1;
 
                for (i = len-1; i >= 0; i--) {
                        sql_exp *e = exps[i];
@@ -456,7 +457,8 @@ rel_exps_mark_used(allocator *sa, sql_re
        if (!nr && subrel && (is_project(subrel->op) || is_base(subrel->op)) && 
!list_empty(subrel->exps) &&
                (is_simple_project(rel->op) && project_unsafe(rel, false))) {
                sql_exp *e = subrel->exps->h->data;
-               e->used = 1;
+               if (!is_freevar(e))
+                       e->used = 1;
        }
        if (rel->r && (is_simple_project(rel->op) || is_groupby(rel->op))) {
                list *l = rel->r;
@@ -526,7 +528,8 @@ rel_used(sql_rel *rel)
                return;
        if (is_join(rel->op) || is_set(rel->op) || is_semi(rel->op) || 
is_modify(rel->op)) {
                rel_used(rel->l);
-               rel_used(rel->r);
+               if (!is_semi(rel->op) && !(is_left(rel->op) && 
!list_empty(rel->attr)))
+                       rel_used(rel->r);
        } else if (rel->op == op_munion) {
                list *l = rel->l;
                for(node *n = l->h; n; n = n->next)
@@ -775,10 +778,12 @@ rel_remove_unused(mvc *sql, sql_rel *rel
                                sql_exp *e = n->data;
 
                                /* at least one (needed for crossproducts, 
count(*), rank() and single value projections) */
-                               if (!e->used && list_length(rel->exps) > 1)
+                               if (!e->used && (list_length(rel->exps) > 1 || 
is_freevar(e)))
                                        list_remove_node(rel->exps, NULL, n);
                                n = next;
                        }
+                       if (list_empty(rel->exps))
+                               append(rel->exps, exp_atom_bool(sql->sa, 0));
                }
                return rel;
 
@@ -1159,7 +1164,7 @@ rel_dce(visitor *v, global_props *gp, sq
 sql_rel *
 rel_deadcode_elimination(mvc *sql, sql_rel *rel)
 {
-       visitor v = {.sql = sql };
+       visitor v = {.sql = sql, .opt = rel->opt };
        return rel_dce_(&v, rel);
 }
 
@@ -1507,6 +1512,14 @@ rel_push_topn_and_sample_down_(visitor *
        return rel;
 }
 
+sql_rel *
+rel_push_topn_down(mvc *sql, sql_rel *rel)
+{
+       visitor v = { .sql = sql };
+       return rel_push_topn_and_sample_down_( &v, rel);
+}
+
+
 static sql_rel *
 rel_push_topn_and_sample_down(visitor *v, global_props *gp, sql_rel *rel)
 {
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
@@ -293,6 +293,13 @@ rel_merge_projects_(visitor *v, sql_rel 
        return rel;
 }
 
+sql_rel *
+rel_merge_project(mvc *sql, sql_rel *rel)
+{
+       visitor v = { .sql = sql };
+       return rel_merge_projects_(&v, rel);
+}
+
 static sql_rel *
 rel_merge_projects(visitor *v, global_props *gp, sql_rel *rel)
 {
@@ -1812,9 +1819,8 @@ rel_push_aggr_down_n_arry(visitor *v, sq
        for (node *n = ((list*)u->l)->h; n; n = n->next) {
                r = rel_dup(n->data);
                //n->data = NULL; /* clean list as we steal the relation r, 
stealing is needed else (with multiple references) double project cleanup fails 
*/
-               if (!is_project(r->op))
-                       r = rel_project(v->sql->sa, r,
-                                           rel_projections(v->sql, r, NULL, 1, 
1));
+               if (!is_project(r->op) || exps_have_selfref(r->exps))
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to