Changeset: fd45f77a025e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fd45f77a025e
Modified Files:
        sql/server/rel_select.c
        sql/test/BugTracker-2026/Tests/7789-assertion-failure.test
Branch: Dec2025
Log Message:

properly check if subqueries are allowed with in check constrains
fixes issue #7789


diffs (34 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -2837,6 +2837,9 @@ rel_logical_value_exp(sql_query *query, 
 
                if (is_psm_call(f) || is_sql_merge(f))
                        return sql_error(sql, 02, SQLSTATE(42000) "%s: 
subqueries not supported inside %s", is_psm_call(f) ? "CALL" : "MERGE", 
is_psm_call(f) ? "CALL statements" : "MERGE conditions");
+               if (is_sql_no_subquery(f) && is_sql_check(f))
+                       return sql_error(sql, 02, SQLSTATE(42000) "CHECK: 
subqueries not allowed inside check constraint");
+
                if (rel && *rel)
                        query_push_outer(query, *rel, f);
                sq = rel_setquery(query, sc);
diff --git a/sql/test/BugTracker-2026/Tests/7789-assertion-failure.test 
b/sql/test/BugTracker-2026/Tests/7789-assertion-failure.test
--- a/sql/test/BugTracker-2026/Tests/7789-assertion-failure.test
+++ b/sql/test/BugTracker-2026/Tests/7789-assertion-failure.test
@@ -1,16 +1,2 @@
-statement ok
+statement error 42000!CHECK: subqueries not allowed inside check constraint
 CREATE TABLE v0 ( v1 BIGINT , v2 INT , v3 DOUBLE PRECISION CONSTRAINT x CHECK 
( NOT CASE WHEN 255 BETWEEN v1 AND v3 THEN ( SELECT 127 UNION SELECT 97 ) END ) 
UNIQUE )
-
--- sql/backends/monet5/rel_bin.c:1550: exp_bin: Assertion `0' failed.
-statement ok
-INSERT INTO v0 ( v2 ) VALUES ( 30 )
-
-statement ok
-INSERT INTO v0 ( v1, v2 ) VALUES ( 123, 40 )
-
-statement ok
-INSERT INTO v0 ( v1, v2, v3 ) VALUES ( 456, 50, NULL)
-
-statement ok
-DROP TABLE v0
-
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to