Changeset: 385c18ff602d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/385c18ff602d
Modified Files:
        sql/server/rel_select.c
Branch: label
Log Message:

Merge with default branch.


diffs (132 lines):

diff --git a/cmake/monetdb-versions.cmake b/cmake/monetdb-versions.cmake
--- a/cmake/monetdb-versions.cmake
+++ b/cmake/monetdb-versions.cmake
@@ -53,7 +53,8 @@ set(MAPI_VERSION_MINOR "2")
 set(MAPI_VERSION_PATCH "2")
 set(MAPI_VERSION 
"${MAPI_VERSION_MAJOR}.${MAPI_VERSION_MINOR}.${MAPI_VERSION_PATCH}")
 
-# version of the MONETDB5 library (subdirectory monetdb5, not including extras 
or sql)
+# version of the MONETDB5 library (subdirectory monetdb5, not including
+# extras, and tools/utils/msabaoth.[ch])
 set(MONETDB5_VERSION_MAJOR "35")
 set(MONETDB5_VERSION_MINOR "0")
 set(MONETDB5_VERSION_PATCH "4")
diff --git a/common/utils/copybinary.h b/common/utils/copybinary.h
--- a/common/utils/copybinary.h
+++ b/common/utils/copybinary.h
@@ -13,8 +13,6 @@
 #ifndef COPYBINARY_H
 #define COPYBINARY_H
 
-#include "monetdb_config.h"
-
 typedef struct {
        uint8_t day;
        uint8_t month;
diff --git a/common/utils/md5.c b/common/utils/md5.c
--- a/common/utils/md5.c
+++ b/common/utils/md5.c
@@ -50,7 +50,7 @@ static void MD5Transform(uint32_t [4], c
 static void Encode(uint8_t *, const uint32_t *, unsigned int);
 static void Decode(uint32_t *, const uint8_t *, unsigned int);
 
-static uint8_t PADDING[64] = {
+static uint8_t const PADDING[64] = {
        0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
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
@@ -2830,15 +2830,42 @@ rel_logical_exp(sql_query *query, sql_re
                char *compare_op = n->next->data.sval;
                int quantifier = 0;
                int is_semantics = 0;
+               bool is_distinct_from = false;
 
                if (n->next->next->next)
                        quantifier = n->next->next->next->data.i_val + 1;
                assert(quantifier == 0 || quantifier == 1 || quantifier == 2 || 
quantifier == 3 || quantifier == 4);
 
                if (quantifier >= 3) {
+                       if (quantifier == 4)
+                               is_distinct_from = true;
                        quantifier = 0;
                        is_semantics = 1;
                }
+               if (is_distinct_from) {
+                       sql_exp* ls = rel_value_exp(query, &rel, lo, 
f|sql_farg, ek);
+                       if (!ls)
+                               return NULL;
+                       sql_exp* rs = rel_value_exp(query, &rel, ro, 
f|sql_farg, ek);
+                       if (!rs)
+                               return NULL;
+
+                       bool ls_is_non_null_atom = exp_is_atom(ls) && 
exp_is_not_null(ls);
+                       bool rs_is_non_null_atom = exp_is_atom(rs) && 
exp_is_not_null(rs);
+
+                       if (ls_is_non_null_atom || rs_is_non_null_atom) {
+                               sql_rel* l = rel_compare(query, rel, sc, lo, 
ro, compare_op, f | sql_or, ek, quantifier, 0);
+                               sql_subtype *t;
+                               if (!(t = 
exp_subtype(rs_is_non_null_atom?ls:rs)))
+                                       return sql_error(sql, 01, 
SQLSTATE(42000) "Cannot have a parameter for IS NULL operator");
+                               sql_exp* e = exp_compare(sql->sa, 
rs_is_non_null_atom?ls:rs, exp_atom(sql->sa, atom_general(sql->sa, t, NULL, 
0)), cmp_equal);
+                               set_has_no_nil(e);
+                               set_semantics(e);
+                               sql_rel* r = 
rel_select_push_compare_exp_down(sql, rel, e, e->l, e->r, NULL, f | sql_or);
+
+                               return rel_or(sql, rel_dup(rel), l, r, NULL, 
NULL, NULL);
+                       }
+               }
 
                /* [NOT] DISTINCT FROM */
                return rel_compare(query, rel, sc, lo, ro, compare_op, f, ek, 
quantifier, is_semantics);
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
@@ -107,6 +107,28 @@ 1
 1
 0
 
+query I nosort
+select s FROM foo WHERE s IS DISTINCT FROM 20;
+----
+10
+NULL
+
+query I nosort
+select s FROM foo WHERE s IS NOT DISTINCT FROM 20;
+----
+20
+
+query I nosort
+select s FROM foo WHERE s + 10 IS DISTINCT FROM s;
+----
+10
+20
+
+query I nosort
+select s FROM foo WHERE s + 10 IS NOT DISTINCT FROM s;
+----
+NULL
+
 statement ok
 create table bar(s) as values (20), (30), (NULL)
 
@@ -176,3 +198,16 @@ 20
 20
 NULL
 NULL
+
+statement ok
+create table baz(s int)
+
+query II rowsort
+SELECT * FROM baz RIGHT JOIN foo ON true WHERE (1 IS DISTINCT FROM baz.s);
+----
+NULL
+10
+NULL
+20
+NULL
+NULL
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to