Changeset: cdbea7f3fa48 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cdbea7f3fa48
Added Files:
sql/test/BugTracker-2026/Tests/7888-or-false-write.test
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_relation.h
sql/test/BugTracker-2026/Tests/All
Branch: Dec2025
Log Message:
fixes for issue #7888, ie properly handle anti with and/or
diffs (145 lines):
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
@@ -696,14 +696,19 @@ exp_bin_conjunctive(backend *be, sql_exp
sel1 = sel;
for (n = l->h; n; n = n->next) {
sql_exp *c = n->data;
- stmt *sin = (sel1 && sel1->nrcols)?sel1:NULL;
+ stmt *sin = (sel1 && sel1->nrcols && !anti)?sel1:NULL;
/* propagate the anti flag */
- if (anti)
- set_anti(c);
+ if (anti && reduce)
+ negate_anti(c);
s = exp_bin(be, c, left, right, grp, ext, cnt, reduce?sin:NULL,
depth, reduce, push);
if (!s)
return s;
+ /* propagate the anti flag */
+ if (anti && !reduce) {
+ sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not",
bt, NULL, F_FUNC, true, true);
+ s = stmt_unop(be, s, NULL, not);
+ }
if (!reduce && sin && sin != sel) {
sql_subfunc *f = sql_bind_func(be->mvc, "sys",
anti?"or":"and", bt, bt, F_FUNC, true, true);
@@ -757,11 +762,16 @@ exp_bin_disjunctive(backend *be, sql_exp
sql_exp *c = n->data;
/* propagate the anti flag */
- if (anti)
- set_anti(c);
+ if (anti && reduce)
+ negate_anti(c);
s = exp_bin(be, c, left, right, grp, ext, cnt, reduce?sel:NULL,
depth, reduce, push);
if (!s)
return s;
+ /* propagate the anti flag */
+ if (anti && !reduce) {
+ sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not",
bt, NULL, F_FUNC, true, true);
+ s = stmt_unop(be, s, NULL, not);
+ }
if (reduce && s->nrcols == 0 && left) {
stmt *predicate = bin_find_smallest_column(be, left);
diff --git a/sql/include/sql_relation.h b/sql/include/sql_relation.h
--- a/sql/include/sql_relation.h
+++ b/sql/include/sql_relation.h
@@ -240,6 +240,7 @@ typedef enum operator_type {
#define is_anti(e) ((e)->anti)
#define set_anti(e) (e)->anti = 1
#define reset_anti(e) (e)->anti = 0
+#define negate_anti(e) (e)->anti = !(e)->anti
#define is_semantics(e) ((e)->semantics)
#define set_semantics(e) (e)->semantics = 1
#define is_any(e) ((e)->any)
diff --git a/sql/test/BugTracker-2026/Tests/7888-or-false-write.test
b/sql/test/BugTracker-2026/Tests/7888-or-false-write.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/7888-or-false-write.test
@@ -0,0 +1,76 @@
+statement ok
+DROP TABLE IF EXISTS bug_t2
+
+statement ok
+DROP TABLE IF EXISTS bug_t1
+
+statement ok
+CREATE TABLE bug_t1 (
+ c1 INT,
+ c4 INT,
+ c5 DATE
+)
+
+statement ok
+CREATE TABLE bug_t2 (
+ c15 DOUBLE
+)
+
+statement ok rowcount 1
+INSERT INTO bug_t1 VALUES (1, 30, DATE '2019-02-16')
+
+statement ok rowcount 1
+INSERT INTO bug_t2 VALUES (531.0)
+
+statement ok rowcount 1
+UPDATE bug_t1
+SET c5 = DATE '2000-10-03'
+WHERE NOT c4 IS NULL
+ AND NOT (c4 IN (SELECT c15 FROM bug_t2) AND 1 = 0)
+
+query IIT
+SELECT * FROM bug_t1
+----
+1
+30
+2000-10-03
+
+statement ok
+DROP TABLE IF EXISTS bug_t2
+
+statement ok
+DROP TABLE IF EXISTS bug_t1
+
+statement ok
+CREATE TABLE bug_t1 (
+ c1 INT,
+ c4 INT,
+ c5 DATE
+)
+
+statement ok
+CREATE TABLE bug_t2 (
+ c15 DOUBLE
+)
+
+statement ok rowcount 1
+INSERT INTO bug_t1 VALUES (1, 30, DATE '2019-02-16')
+
+statement ok rowcount 1
+INSERT INTO bug_t2 VALUES (531.0)
+
+statement ok rowcount 1
+UPDATE bug_t1
+SET c5 = DATE '2000-10-03'
+WHERE (1 = 0)
+ OR (
+ NOT c4 IS NULL
+ AND NOT (c4 IN (SELECT c15 FROM bug_t2) AND 1 = 0)
+ )
+
+query IIT
+SELECT * FROM bug_t1;
+----
+1
+30
+2000-10-03
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
@@ -74,3 +74,4 @@ KNOWNFAIL?7774-insert-into-renamed-table
7882-later-distinct
7883-right-join-crash
7886-local-view-in-with
+7888-or-false-write
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]