Changeset: 92a56f94169f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/92a56f94169f
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/server/rel_optimize_sel.c
        sql/server/rel_unnest.c
        sql/test/BugTracker-2026/Tests/All
Branch: default
Log Message:

Merge with Dec2025 branch.


diffs (truncated from 1366 to 300 lines):

diff --git a/clients/NT/mclient.bat b/clients/NT/mclient.bat
--- a/clients/NT/mclient.bat
+++ b/clients/NT/mclient.bat
@@ -2,9 +2,11 @@
 @REM
 @REM This Source Code Form is subject to the terms of the Mozilla Public
 @REM License, v. 2.0.  If a copy of the MPL was not distributed with this
-@REM file, You can obtain one at http://mozilla.org/MPL/2.0/.
+@REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
 @REM
-@REM For copyright information, see the file debian/copyright.
+@REM Copyright 2024 - present MonetDB Foundation;
+@REM Copyright August 2008 - 2023 MonetDB B.V.;
+@REM Copyright 1997 - July 2008 CWI.
 
 @echo off
 rem figure out the folder name
diff --git a/clients/NT/msqldump.bat b/clients/NT/msqldump.bat
--- a/clients/NT/msqldump.bat
+++ b/clients/NT/msqldump.bat
@@ -2,9 +2,11 @@
 @REM
 @REM This Source Code Form is subject to the terms of the Mozilla Public
 @REM License, v. 2.0.  If a copy of the MPL was not distributed with this
-@REM file, You can obtain one at http://mozilla.org/MPL/2.0/.
+@REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
 @REM
-@REM For copyright information, see the file debian/copyright.
+@REM Copyright 2024 - present MonetDB Foundation;
+@REM Copyright August 2008 - 2023 MonetDB B.V.;
+@REM Copyright 1997 - July 2008 CWI.
 
 @rem figure out the folder name
 @set MONETDB=%~dp0
diff --git a/monetdb5/NT/M5server.bat b/monetdb5/NT/M5server.bat
--- a/monetdb5/NT/M5server.bat
+++ b/monetdb5/NT/M5server.bat
@@ -2,9 +2,11 @@
 @REM
 @REM This Source Code Form is subject to the terms of the Mozilla Public
 @REM License, v. 2.0.  If a copy of the MPL was not distributed with this
-@REM file, You can obtain one at http://mozilla.org/MPL/2.0/.
+@REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
 @REM
-@REM For copyright information, see the file debian/copyright.
+@REM Copyright 2024 - present MonetDB Foundation;
+@REM Copyright August 2008 - 2023 MonetDB B.V.;
+@REM Copyright 1997 - July 2008 CWI.
 
 @echo off
 
diff --git a/sql/NT/MSQLclient.bat b/sql/NT/MSQLclient.bat
--- a/sql/NT/MSQLclient.bat
+++ b/sql/NT/MSQLclient.bat
@@ -2,9 +2,11 @@
 @REM
 @REM This Source Code Form is subject to the terms of the Mozilla Public
 @REM License, v. 2.0.  If a copy of the MPL was not distributed with this
-@REM file, You can obtain one at http://mozilla.org/MPL/2.0/.
+@REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
 @REM
-@REM For copyright information, see the file debian/copyright.
+@REM Copyright 2024 - present MonetDB Foundation;
+@REM Copyright August 2008 - 2023 MonetDB B.V.;
+@REM Copyright 1997 - July 2008 CWI.
 
 @rem figure out the folder name
 @set MONETDB=%~dp0
diff --git a/sql/NT/MSQLserver.bat b/sql/NT/MSQLserver.bat
--- a/sql/NT/MSQLserver.bat
+++ b/sql/NT/MSQLserver.bat
@@ -2,9 +2,11 @@
 @REM
 @REM This Source Code Form is subject to the terms of the Mozilla Public
 @REM License, v. 2.0.  If a copy of the MPL was not distributed with this
-@REM file, You can obtain one at http://mozilla.org/MPL/2.0/.
+@REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
 @REM
-@REM For copyright information, see the file debian/copyright.
+@REM Copyright 2024 - present MonetDB Foundation;
+@REM Copyright August 2008 - 2023 MonetDB B.V.;
+@REM Copyright 1997 - July 2008 CWI.
 
 @echo off
 
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
@@ -731,7 +731,7 @@ exp_bin_conjunctive(backend *be, sql_exp
                }
                sel1 = s;
        }
-       if (sel1->nrcols == 0 && left) {
+       if (sel1 && sel1->nrcols == 0 && left) {
                stmt *predicate = bin_find_smallest_column(be, left);
 
                if (!reduce) {
diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -471,8 +471,23 @@ exps_cse_dis( visitor *v, list *oexps, s
                m = m->next;
                lpos++;
        }
-       //if (changes) {
-               /* todo check for empty lists */
+       if (changes) {
+               for (node *n = dis->h; n; ) {
+                       node *nxt = n->next;
+                       if (!n->data)
+                               list_remove_node(dis, NULL, n);
+                       else {
+                               sql_exp *e = n->data;
+                               assert(e->type == e_cmp && e->flag == cmp_con);
+                               list *l = e->l;
+                               if (list_empty(l))
+                                       list_remove_node(dis, NULL, n);
+                       }
+                       n = nxt;
+               }
+               if (list_empty(dis))
+                       de = exp_atom_bool(v->sql->sa, 1);
+       }
        append(oexps, de);
        return changes;
 }
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -163,6 +163,7 @@ rel_has_freevar(mvc *sql, sql_rel *rel)
                (void) sql_error(sql, 10, SQLSTATE(42000) "Query too complex: 
running out of stack space");
                return 0;
        }
+       assert(rel);
        if (!rel)
                return 0;
        if (is_independent(rel->used))
@@ -988,6 +989,8 @@ push_up_project(mvc *sql, sql_rel *rel, 
                        /* move project up, ie all attributes of left + the old 
expression list */
                        sql_rel *n = rel_project( sql->sa, (r->l)?rel:rel->l,
                                        rel_projections(sql, rel->l, NULL, 1, 
1));
+                       if (need_distinct(r))
+                                       set_distinct(n);
 
                        if (is_left(rel->op) && !list_empty(rel->attr))
                                rel_project_add_exp(sql, n, exp_ref(sql, 
rel->attr->h->data));
diff --git 
a/sql/test/BugTracker-2026/Tests/7875-rel2bin_groupjoin-assertion-failure.test 
b/sql/test/BugTracker-2026/Tests/7875-rel2bin_groupjoin-assertion-failure.test
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2026/Tests/7875-rel2bin_groupjoin-assertion-failure.test
@@ -0,0 +1,138 @@
+statement ok
+CREATE SCHEMA test7875
+
+statement ok
+SET SCHEMA test7875
+
+statement ok
+CREATE TABLE users (
+    id           INT,
+    username     VARCHAR(100),
+    email        VARCHAR(255),
+    age          INT,
+    status       VARCHAR(20),
+    created_at   TIMESTAMP,
+    score        DOUBLE
+)
+
+statement ok
+CREATE TABLE posts (
+    id          INT,
+    user_id     INT,
+    title       VARCHAR(255),
+    content     VARCHAR(1000),
+    views       INT,
+    likes       INT,
+    created_at  TIMESTAMP,
+    rating      DOUBLE
+)
+
+statement ok
+CREATE TABLE comments (
+    id          INT,
+    post_id     INT,
+    user_id     INT,
+    content     VARCHAR(1000),
+    is_spam     INT,
+    created_at  TIMESTAMP
+)
+
+statement ok
+CREATE TABLE orders (
+    id          INT,
+    user_id     INT,
+    amount      DOUBLE,
+    status      VARCHAR(20),
+    created_at  TIMESTAMP
+)
+
+statement ok
+INSERT INTO users VALUES
+(1, 'alice', '[email protected]', 20, 'active',  '2022-01-01 10:00:00', 88.5),
+(2, 'bob',   '[email protected]',   30, 'active',  '2022-01-02 11:00:00', 92.3),
+(3, 'carol', NULL,             NULL, 'banned','2022-01-03 12:00:00', NULL),
+(4, 'dave',  '[email protected]',  45, 'active',  '2022-01-04 13:00:00', 65.2),
+(5, NULL,    '[email protected]',  18, 'inactive','2022-01-05 14:00:00', 70.0)
+
+statement ok
+INSERT INTO posts VALUES
+(1, 1, 'Hello World', 'First post', 100, 10, '2022-01-10 10:00:00', 4.5),
+(2, 1, 'Another Post', NULL,        150, 20, '2022-01-11 11:00:00', 3.0),
+(3, 2, 'Bob Post',     'Content',   NULL,  5, '2022-01-12 12:00:00', NULL),
+(4, 3, NULL,           'Empty',     50,   2, '2022-01-13 13:00:00', 5.0),
+(5, 4, 'Last Post',    'Last',      300,  30,'2022-01-14 14:00:00', 4.9)
+
+statement ok
+INSERT INTO comments VALUES
+(1, 1, 2, 'Nice post', 0, '2022-01-20 10:00:00'),
+(2, 1, 3, 'Spam here', 1,  '2022-01-21 11:00:00'),
+(3, 2, 1, 'Thanks',    0, '2022-01-22 12:00:00'),
+(4, 4, 5, NULL,        0, '2022-01-23 13:00:00')
+
+statement ok
+INSERT INTO orders VALUES
+(1, 1, 100.00, 'paid',    '2022-02-01 09:00:00'),
+(2, 1, 200.50, 'shipped', '2022-02-02 10:00:00'),
+(3, 2, NULL,   'failed',  '2022-02-03 11:00:00'),
+(4, 3, 50.00,  'paid',    '2022-02-04 12:00:00'),
+(5, 5, 999.99, 'paid',    '2022-02-05 13:00:00')
+
+-- mserver5: sql/backends/monet5/rel_bin.c:3202: rel2bin_groupjoin: Assertion 
`sql->session->status == -10' failed.
+-- query triggers assertion failure in rel2bin_groupjoin (be=0x7fca481a61b0, 
rel=0x7fca48265d40, refs=0x7fca48288a20) at sql/backends/monet5/rel_bin.c:3202
+query I rowsort
+SELECT 1
+FROM users AS ref_0,
+LATERAL (
+    SELECT
+           CASE WHEN ref_1.likes > (SELECT id FROM orders LIMIT 1 OFFSET 1) 
THEN ref_0.id ELSE ref_0.id END AS c2,
+           ref_1.title AS c4,
+           (SELECT AVG(id) FROM comments) AS c5,
+           79 AS c6
+    FROM posts AS ref_1
+    RIGHT JOIN orders AS ref_2 ON ref_1.likes = ref_2.id
+    WHERE sys.ms_round((SELECT var_pop(id) FROM posts), 0, 0) >= CASE WHEN 'S' 
>= 'qn4cal' THEN 32.84 ELSE sqrt(36.28) END
+    LIMIT 177
+) AS subq_0,
+LATERAL (
+    SELECT 73 AS c1
+    FROM users AS ref_3
+    INNER JOIN comments AS ref_4
+        LEFT JOIN posts AS ref_5
+            INNER JOIN users AS ref_6
+                ON (('fDJ' <= 'b') OR ((TRUE AND FALSE) OR (ref_6.age != 
(SELECT id FROM users LIMIT 1 OFFSET 4) OR (subq_0.c5 > subq_0.c5))))
+        ON ('P' < 'ZxoS')
+    INNER JOIN orders AS ref_7
+        ON ((ref_5.user_id < subq_0.c6) OR EXISTS (
+            SELECT 1
+            FROM posts AS ref_8
+            WHERE (ref_0.age < ref_0.age) OR ((SELECT id FROM orders LIMIT 1 
OFFSET 4) != ref_4.is_spam)
+        ))
+        ON ref_6.username IS NOT NULL
+    WHERE CASE WHEN (subq_0.c5 < subq_0.c5) AND (ref_4.created_at IS NOT NULL)
+               THEN CASE WHEN subq_0.c5 != subq_0.c5 THEN 'grSb' ELSE '30zdhO' 
END
+               ELSE 'M' END
+          != CASE WHEN (subq_0.c5 <= subq_0.c5) AND (subq_0.c5 != subq_0.c5) 
THEN 'KTYV' ELSE 'V9Iovm' END
+    LIMIT 135
+) AS subq_2
+WHERE subq_2.c1 >= subq_0.c2
+LIMIT 134
+----
+
+statement ok
+DROP TABLE orders
+
+statement ok
+DROP TABLE comments
+
+statement ok
+DROP TABLE posts
+
+statement ok
+DROP TABLE users
+
+statement ok
+SET SCHEMA sys
+
+statement ok
+DROP SCHEMA test7875
+
diff --git 
a/sql/test/BugTracker-2026/Tests/7876-rel2bin_select-assertion-failure.test 
b/sql/test/BugTracker-2026/Tests/7876-rel2bin_select-assertion-failure.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/7876-rel2bin_select-assertion-failure.test
@@ -0,0 +1,132 @@
+statement ok
+CREATE SCHEMA test7876
+
+statement ok
+SET SCHEMA test7876
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to