Changeset: f5d791884514 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f5d791884514
Removed Files:
        monetdb5/modules/atoms/Tests/asciify.test
        monetdb5/modules/atoms/Tests/endswith.test
        monetdb5/modules/kernel/Tests/batstr_asciify.test
Modified Files:
        monetdb5/modules/atoms/Tests/All
        monetdb5/modules/kernel/Tests/All
        sql/test/strings/Tests/All
        sql/test/strings/Tests/asciify.test
        sql/test/strings/Tests/batstr_asciify.test
        sql/test/strings/Tests/endswith.test
Branch: ascii-flag
Log Message:

Merge with default branch.


diffs (truncated from 1030 to 300 lines):

diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1206,6 +1206,9 @@ BATrange(BATiter *bi, const void *tl, co
        if (tl == NULL && th == NULL)
                return range_contains; /* looking for everything */
 
+       if (VIEWtparent(bi->b))
+               pb = BATdescriptor(VIEWtparent(bi->b));
+
        /* keep locked while we look at the property values */
        MT_lock_set(&bi->b->theaplock);
        if (bi->minpos != BUN_NONE)
@@ -1221,8 +1224,7 @@ BATrange(BATiter *bi, const void *tl, co
        }
        bool keep = false;      /* keep lock on parent bat? */
        if (minprop == NULL || maxprop == NULL) {
-               if (VIEWtparent(bi->b) &&
-                   (pb = BATdescriptor(VIEWtparent(bi->b))) != NULL) {
+               if (pb != NULL) {
                        MT_lock_set(&pb->theaplock);
                        if (minprop == NULL && (minprop = BATgetprop_nolock(pb, 
GDK_MIN_BOUND)) != NULL) {
                                keep = true;
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -280,15 +280,16 @@ dump_threads(void)
        char buf[1024];
        thread_lock();
        for (struct mtthread *t = mtthreads; t; t = t->next) {
+               MT_Lock *lk = t->lockwait;
+               MT_Sema *sm = t->semawait;
+               MT_Cond *cn = t->condwait;
+               struct mtthread *jn = t->joinwait;
                int pos = snprintf(buf, sizeof(buf),
-                                  "%s, tid %zu, waiting for %s, working on 
%.200s",
+                                  "%s, tid %zu, waiting for %s%s, working on 
%.200s",
                                   t->threadname,
                                   t->tid,
-                                  t->lockwait ? t->lockwait->name :
-                                  t->semawait ? t->semawait->name :
-                                  t->condwait ? t->condwait->name :
-                                  t->joinwait ? t->joinwait->threadname :
-                                  "nothing",
+                                  lk ? "lock " : sm ? "semaphore " : cn ? 
"condvar " : jn ? "thread " : "",
+                                  lk ? lk->name : sm ? sm->name : cn ? 
cn->name : jn ? jn->threadname : "nothing",
                                   ATOMIC_GET(&t->exited) ? "exiting" :
                                   t->working ? t->working : "nothing");
 #ifdef LOCK_OWNER
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -498,7 +498,6 @@ typedef struct MT_Lock {
 
 #define MT_lock_try(l)         (pthread_mutex_trylock(&(l)->lock) == 0 && 
(_DBG_LOCK_LOCKER(l), true))
 
-#ifdef LOCK_STATS
 #define MT_lock_set(l)                                         \
        do {                                                    \
                _DBG_LOCK_COUNT_0(l);                           \
@@ -511,14 +510,6 @@ typedef struct MT_Lock {
                _DBG_LOCK_LOCKER(l);                            \
                _DBG_LOCK_COUNT_2(l);                           \
        } while (0)
-#else
-#define MT_lock_set(l)                         \
-       do {                                    \
-               pthread_mutex_lock(&(l)->lock); \
-               _DBG_LOCK_LOCKER(l);            \
-       } while (0)
-#endif
-
 #define MT_lock_unset(l)                               \
        do {                                            \
                _DBG_LOCK_UNLOCKER(l);                  \
diff --git a/monetdb5/modules/atoms/Tests/All b/monetdb5/modules/atoms/Tests/All
--- a/monetdb5/modules/atoms/Tests/All
+++ b/monetdb5/modules/atoms/Tests/All
@@ -33,13 +33,3 @@ jsonrender
 
 uuid00
 strappend
-
-startswith
-endswith
-contains
-asciify
-startswith_join
-endswith_join
-contains_join
-
-ts_and_tstz_to_str_bug
diff --git a/monetdb5/modules/kernel/Tests/All 
b/monetdb5/modules/kernel/Tests/All
--- a/monetdb5/modules/kernel/Tests/All
+++ b/monetdb5/modules/kernel/Tests/All
@@ -3,8 +3,3 @@ TriBool
 batstr
 math
 select
-
-batstr_asciify
-batstr_startswith
-batstr_endswith
-batstr_contains
diff --git a/monetdb5/modules/mal/Tests/All b/monetdb5/modules/mal/Tests/All
--- a/monetdb5/modules/mal/Tests/All
+++ b/monetdb5/modules/mal/Tests/All
@@ -52,6 +52,3 @@ orderidx00
 orderidx01
 orderidx02
 orderidx04
-
-txtsim_levenshtein
-txtsim_jarowinkler
diff --git a/monetdb5/optimizer/opt_aliases.c b/monetdb5/optimizer/opt_aliases.c
--- a/monetdb5/optimizer/opt_aliases.c
+++ b/monetdb5/optimizer/opt_aliases.c
@@ -17,16 +17,8 @@
 /* an alias is recognized by a simple assignment */
 #define OPTisAlias(X) (X->argc == 2 && X->token == ASSIGNsymbol && X->barrier 
== 0 )
 
-static inline void
-OPTaliasRemap(InstrPtr p, int *alias)
-{
-       for (int i = 0; i < p->argc; i++)
-               getArg(p, i) = alias[getArg(p, i)];
-}
-
 str
-OPTaliasesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
-                                                InstrPtr pci)
+OPTaliasesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
 {
        int i, j, k = 1, limit, actions = 0;
        int *alias = 0;
@@ -67,7 +59,8 @@ OPTaliasesImplementation(Client cntxt, M
                        k--;
                        mb->stmt[k] = 0;
                } else {
-                       OPTaliasRemap(p, alias);
+                       for (int i = 0; i < p->argc; i++)
+                               getArg(p, i) = alias[getArg(p, i)];
                }
        }
 
diff --git a/monetdb5/optimizer/opt_candidates.c 
b/monetdb5/optimizer/opt_candidates.c
--- a/monetdb5/optimizer/opt_candidates.c
+++ b/monetdb5/optimizer/opt_candidates.c
@@ -19,12 +19,13 @@
 #include "opt_candidates.h"
 
 str
-OPTcandidatesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
-                                                       InstrPtr pci)
+OPTcandidatesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
 {
        InstrPtr p;
        str msg = MAL_SUCCEED;
 
+       if (!(ATOMIC_GET(&GDKdebug) & FORCEMITOMASK))
+               goto wrapup;
        (void) cntxt;
        (void) stk;                                     /* to fool compilers */
        for (int i = 0; i < mb->stop; i++) {
@@ -88,6 +89,7 @@ OPTcandidatesImplementation(Client cntxt
        // if( ms== MAL_SUCCEED)
        //      msg = chkDeclarations(mb);
        /* keep actions taken as a fake argument */
+wrapup:
        (void) pushInt(mb, pci, 1);
        return msg;
 }
diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Thu Mar 21 2024 Yunus Koning <yunus.kon...@monetdbsolutions.com>
+- Introduce IS [NOT] DISTINCT FROM syntax. The syntax allows two values
+  to be compared. The comparison always returns boolean FALSE or TRUE
+  never NULL.
+
 * Wed Mar  6 2024 Yunus Koning <yunus.kon...@monetdbsolutions.com>
 - SQL2023 feature: Introduce UNIQUE NULLS [NOT] DISTINCT syntax which
   allows for NULLS to be treated as unique, i.e. a column with this
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
@@ -1831,8 +1831,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                                                                
                   tail_type(l), tail_type(l), F_FUNC, true, true);
                                        assert(f);
                                        if (is_semantics(e)) {
-                                               if (exp_is_null(e->l) && 
exp_is_null(e->r)) {
-                                                       s = stmt_bool(be, 
!is_anti(e));
+                                               if (exp_is_null(e->l) && 
exp_is_null(e->r) && (e->flag == cmp_equal || e->flag == cmp_notequal)) {
+                                                       s = stmt_bool(be, 
e->flag == cmp_equal ? !is_anti(e): is_anti(e));
                                                } else {
                                                        list *args = 
sa_list(sql->sa);
                                                        if (args == NULL)
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
@@ -2367,6 +2367,8 @@ rel_logical_value_exp(sql_query *query, 
                int quantifier = 0, need_not = 0;
                sql_exp *rs = NULL, *ls;
                comp_type cmp_type = compare_str2type(compare_op);
+               bool is_not_distinct_from = false;
+               bool is_distinct_from = false;
 
                /*
                 * = ANY -> IN, <> ALL -> NOT( = ANY) -> NOT IN
@@ -2374,7 +2376,17 @@ rel_logical_value_exp(sql_query *query, 
                 */
                if (n->next->next->next)
                        quantifier = n->next->next->next->data.i_val + 1;
-               assert(quantifier == 0 || quantifier == 1 || quantifier == 2);
+               assert(quantifier == 0 || quantifier == 1 || quantifier == 2 || 
quantifier == 3 || quantifier == 4);
+
+               /* [NOT] DISTINCT FROM */
+               if (quantifier == 3) {
+                               is_not_distinct_from = true;
+                               quantifier = 0;
+               }
+               else if (quantifier == 4) {
+                               is_distinct_from = true;
+                               quantifier = 0;
+               }
 
                if ((quantifier == 1 && cmp_type == cmp_equal) ||
                    (quantifier == 2 && cmp_type == cmp_notequal)) {
@@ -2405,6 +2417,15 @@ rel_logical_value_exp(sql_query *query, 
                rs = rel_value_exp(query, rel, ro, f|sql_farg, ek);
                if (!rs)
                        return NULL;
+
+               if (is_distinct_from || is_not_distinct_from) {
+                       if (rel_convert_types(sql, rel ? *rel : NULL, rel ? 
*rel : NULL, &ls, &rs, 1, type_equal_no_any) < 0)
+                               return NULL;
+                       sql_exp* e = exp_compare(sql->sa, ls, rs, 
is_not_distinct_from?cmp_equal:cmp_notequal);
+                       set_semantics(e);
+                       return e;
+               }
+
                if (rs->type == e_atom)
                        quantifier = 0;
 
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -3909,6 +3909,20 @@ comparison_predicate:
                  append_symbol(l, $5);
                  append_int(l, $3);
                  $$ = _symbol_create_list(SQL_COMPARE, l ); }
+ |     pred_exp IS NOT DISTINCT FROM pred_exp
+               { dlist *l = L();
+                 append_symbol(l, $1);
+                 append_string(l, sa_strdup(SA, "="));
+                 append_symbol(l, $6);
+                 append_int(l, 2);
+                 $$ = _symbol_create_list(SQL_COMPARE, l ); }
+ |     pred_exp IS DISTINCT FROM pred_exp
+               { dlist *l = L();
+                 append_symbol(l, $1);
+                 append_string(l, sa_strdup(SA, "="));
+                 append_symbol(l, $5);
+                 append_int(l, 3);
+                 $$ = _symbol_create_list(SQL_COMPARE, l ); }
  ;
 
 between_predicate:
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -57,10 +57,10 @@ ulng
 store_oldest(sqlstore *store, sql_trans *tr)
 {
        if (tr && tr->ts == (ulng) ATOMIC_GET(&store->oldest)) {
-               sql_session *s = store->active->h->data;
-               if (s->tr == tr && store->active->h->next) {
-                       s = store->active->h->next->data;
-                       return s->tr->ts;
+               sql_trans *otr = store->active->h->data;
+               if (otr == tr && store->active->h->next) {
+                       otr = store->active->h->next->data;
+                       return otr->ts;
                }
        }
        return (ulng) ATOMIC_GET(&store->oldest);
diff --git a/sql/test/2024/Tests/All b/sql/test/2024/Tests/All
--- a/sql/test/2024/Tests/All
+++ b/sql/test/2024/Tests/All
@@ -1,1 +1,2 @@
 groupby_primary_key_project_unique_key
+distinct_from
diff --git a/sql/test/2024/Tests/distinct_from.test 
b/sql/test/2024/Tests/distinct_from.test
new file mode 100644
--- /dev/null
+++ b/sql/test/2024/Tests/distinct_from.test
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to