Changeset: f30408e18eff for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f30408e18eff
Added Files:
        sql/test/BugTracker-2026/Tests/7905-sum-case-subquery-bug.test
Modified Files:
        sql/test/BugTracker-2026/Tests/All
Branch: Dec2025
Log Message:

Add test for #7905


diffs (91 lines):

diff --git a/sql/test/BugTracker-2026/Tests/7905-sum-case-subquery-bug.test 
b/sql/test/BugTracker-2026/Tests/7905-sum-case-subquery-bug.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/7905-sum-case-subquery-bug.test
@@ -0,0 +1,75 @@
+statement ok
+CREATE TABLE comments7905 (
+    id          INT,
+    post_id     INT,
+    user_id     INT,
+    content     VARCHAR(1000),
+    is_spam     INT,
+    created_at  TIMESTAMP
+)
+
+statement ok
+INSERT INTO comments7905 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')
+
+query I nosort
+SELECT COUNT(*) as count
+FROM comments7905 AS ref_0
+WHERE (
+    '6vh33z' >= 'm'
+    AND (
+        ref_0.id <= CASE
+                        WHEN FALSE THEN ref_0.user_id
+                        ELSE ref_0.post_id
+                    END
+        OR (
+            ref_0.id <= ref_0.post_id
+            AND (
+                CASE
+                    WHEN ref_0.post_id > ref_0.is_spam THEN TRUE
+                    ELSE COALESCE(TRUE, FALSE)
+                END
+                OR COALESCE(TRUE, FALSE)
+            )
+        )
+    )
+)
+----
+0
+
+-- next query returned 2 instead of 0
+query I nosort
+SELECT SUM(
+    CASE
+        WHEN (
+            '6vh33z' >= 'm'
+            AND (
+                ref_0.id <= CASE
+                                WHEN FALSE THEN ref_0.user_id
+                                ELSE ref_0.post_id
+                            END
+                OR (
+                    ref_0.id <= ref_0.post_id
+                    AND (
+                        CASE
+                            WHEN ref_0.post_id > ref_0.is_spam THEN TRUE
+                            ELSE COALESCE(TRUE, FALSE)
+                        END
+                        OR COALESCE(TRUE, FALSE)
+                    )
+                )
+            )
+        )
+        THEN 1 ELSE 0
+    END + 0
+) as sum
+FROM comments7905 AS ref_0
+----
+0
+
+statement ok
+DROP TABLE comments7905
+
diff --git a/sql/test/BugTracker-2026/Tests/All 
b/sql/test/BugTracker-2026/Tests/All
--- a/sql/test/BugTracker-2026/Tests/All
+++ b/sql/test/BugTracker-2026/Tests/All
@@ -86,6 +86,7 @@ KNOWNFAIL?7896-where-ascii-comparison-bu
 7897-exp_bin-assertion-failure
 7899-correlated-with-complex-and-or
 7903-query-without-result-bug
+7905-sum-case-subquery-bug
 KNOWNFAIL?7906-rel2bin_join-assertion-failure
 7911-query-without-result-bug
 7913-where-exist-subquery-bug
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to