Changeset: a16cdebc6233 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a16cdebc6233
Added Files:
        sql/test/BugTracker-2026/Tests/7912-where-or-1-is-1-bug.test
Modified Files:
        sql/test/BugTracker-2026/Tests/All
Branch: Dec2025
Log Message:

Add test for #7912


diffs (124 lines):

diff --git a/sql/test/BugTracker-2026/Tests/7912-where-or-1-is-1-bug.test 
b/sql/test/BugTracker-2026/Tests/7912-where-or-1-is-1-bug.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/7912-where-or-1-is-1-bug.test
@@ -0,0 +1,108 @@
+-- Repro for MonetDB logic bug (tautological OR should not reduce result set)
+statement ok
+CREATE TABLE repro_t1(c1 INT)
+
+statement ok
+CREATE TABLE repro_t2(c1 INT, c2 INT)
+
+statement ok
+CREATE TABLE repro_t3(c2 INT, c3 INT)
+
+statement ok rowcount 2
+INSERT INTO repro_t1 VALUES (1), (7)
+
+statement ok rowcount 1
+INSERT INTO repro_t2 VALUES (8, 7)
+
+statement ok rowcount 1
+INSERT INTO repro_t3 VALUES (6, 8)
+
+statement ok
+CREATE TABLE repro_out_orig(id INT)
+
+statement ok
+CREATE TABLE repro_out_mut(id INT)
+
+-- Original
+query I rowsort
+SELECT DISTINCT repro_t2.c1
+FROM repro_t2, repro_t1 AS d
+WHERE d.c1 > (
+  SELECT AVG(repro_t3.c2)
+  FROM repro_t3
+  WHERE repro_t3.c3 = repro_t2.c1
+  ORDER BY AVG(repro_t3.c2) ASC NULLS FIRST
+  LIMIT 1
+)
+AND repro_t2.c2 = d.c1
+----
+8
+
+statement ok rowcount 1
+INSERT INTO repro_out_orig
+SELECT DISTINCT repro_t2.c1
+FROM repro_t2, repro_t1 AS d
+WHERE d.c1 > (
+  SELECT AVG(repro_t3.c2)
+  FROM repro_t3
+  WHERE repro_t3.c3 = repro_t2.c1
+  ORDER BY AVG(repro_t3.c2) ASC NULLS FIRST
+  LIMIT 1
+)
+AND repro_t2.c2 = d.c1
+
+-- Mutated (tautological relaxation)
+query I rowsort
+SELECT DISTINCT repro_t2.c1
+FROM repro_t2, repro_t1 AS d
+WHERE d.c1 > (
+  SELECT AVG(repro_t3.c2)
+  FROM repro_t3
+  WHERE repro_t3.c3 = repro_t2.c1
+  ORDER BY AVG(repro_t3.c2) ASC NULLS FIRST
+  LIMIT 1
+)
+AND (repro_t2.c2 = d.c1 OR 1 = 1)
+----
+8
+
+statement ok rowcount 1
+INSERT INTO repro_out_mut
+SELECT DISTINCT repro_t2.c1
+FROM repro_t2, repro_t1 AS d
+WHERE d.c1 > (
+  SELECT AVG(repro_t3.c2)
+  FROM repro_t3
+  WHERE repro_t3.c3 = repro_t2.c1
+  ORDER BY AVG(repro_t3.c2) ASC NULLS FIRST
+  LIMIT 1
+)
+AND (repro_t2.c2 = d.c1 OR 1 = 1)
+
+-- observed: (8)
+query I rowsort
+SELECT * FROM repro_out_orig ORDER BY id
+----
+8
+
+-- observed: empty
+query I rowsort
+SELECT * FROM repro_out_mut ORDER BY id
+----
+8
+
+statement ok
+DROP TABLE repro_t1
+
+statement ok
+DROP TABLE repro_t2
+
+statement ok
+DROP TABLE repro_t3
+
+statement ok
+DROP TABLE repro_out_orig
+
+statement ok
+DROP TABLE repro_out_mut
+
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
@@ -95,6 +95,7 @@ KNOWNFAIL?7774-insert-into-renamed-table
 7905-sum-case-subquery-bug
 7906-rel2bin_join-assertion-failure
 7911-query-without-result-bug
+7912-where-or-1-is-1-bug
 7913-where-exist-subquery-bug
 7914-exp_bin-assertion-failure
 7915-delete-exists-having-bug
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to