Changeset: 3a51d8edf6af for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3a51d8edf6af
Modified Files:
sql/server/rel_select.c
sql/test/2024/Tests/distinct_from.test
Branch: default
Log Message:
fix and test bug #7521
diffs (54 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
@@ -2318,9 +2318,24 @@ negate_symbol_tree(mvc *sql, symbol *sc)
case SQL_COMPARE: {
dnode *cmp_n = sc->data.lval->h;
comp_type neg_cmp_type =
negate_compare(compare_str2type(cmp_n->next->data.sval)); /* negate the
comparator */
+ if (cmp_n->next->next->next) {
+ switch(cmp_n->next->next->next->data.i_val)
+ {
+ case 0: /* negating ANY/ALL */
+ cmp_n->next->next->next->data.i_val = 1;
+ break;
+ case 1: /* negating ANY/ALL */
+ cmp_n->next->next->next->data.i_val = 0;
+ break;
+ case 2: /* negating IS [NOY] DINSTINCT FROM */
+ cmp_n->next->next->next->data.i_val = 3;
+ break;
+ case 3: /* negating IS [NOY] DINSTINCT FROM */
+ cmp_n->next->next->next->data.i_val = 2;
+ break;
+ }
+ }
cmp_n->next->data.sval = sa_strdup(sql->sa,
compare_func(neg_cmp_type, 0));
- if (cmp_n->next->next->next) /* negating ANY/ALL */
- cmp_n->next->next->next->data.i_val =
cmp_n->next->next->next->data.i_val == 0 ? 1 : 0;
} break;
case SQL_AND:
case SQL_OR: {
diff --git a/sql/test/2024/Tests/distinct_from.test
b/sql/test/2024/Tests/distinct_from.test
--- a/sql/test/2024/Tests/distinct_from.test
+++ b/sql/test/2024/Tests/distinct_from.test
@@ -34,10 +34,20 @@ SELECT NULL IS DISTINCT FROM NULL
0
query I nosort
+SELECT NOT (NULL IS DISTINCT FROM NULL)
+----
+1
+
+query I nosort
SELECT NULL IS NOT DISTINCT FROM NULL
----
1
+query I nosort
+SELECT NOT (NULL IS NOT DISTINCT FROM NULL)
+----
+0
+
statement ok
create table foo(s) as values (10), (20), (NULL)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]