Changeset: 577b502bb38a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/577b502bb38a
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_select.c
        monetdb5/modules/kernel/algebra.c
        sql/test/2024/Tests/nextafter.test
        
sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test
        sql/test/miscellaneous/Tests/simple_plans.test
        sql/test/rel-optimizers/Tests/merge-ors-base.test
        sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.test
        sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.test
        sql/test/rel-optimizers/Tests/merge-unions.test
        testing/Mtest.py.in
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (truncated from 3372 to 300 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1203,6 +1203,9 @@ BUNappendmulti(BAT *b, const void *value
                                                        maxvalp = t;
                                                }
                                        }
+                               } else {
+                                       b->tnil = true;
+                                       b->tnonil = false;
                                }
                                p++;
                        }
@@ -1222,6 +1225,8 @@ BUNappendmulti(BAT *b, const void *value
                } else if (ATOMstorage(b->ttype) == TYPE_msk) {
                        bi.minpos = bi.maxpos = BUN_NONE;
                        minvalp = maxvalp = NULL;
+                       b->tnil = false;
+                       b->tnonil = true;
                        for (BUN i = 0; i < count; i++) {
                                t = (void *) ((char *) values + (i << 
b->tshift));
                                mskSetVal(b, p, *(msk *) t);
@@ -1258,12 +1263,16 @@ BUNappendmulti(BAT *b, const void *value
                                                        maxvalp = t;
                                                }
                                        }
+                               } else {
+                                       b->tnil = true;
+                                       b->tnonil = false;
                                }
                                p++;
                        }
                        nunique = b->thash ? b->thash->nunique : 0;
                }
        } else {
+               /* inserting nils, unless it's msk */
                for (BUN i = 0; i < count; i++) {
                        gdk_return rc = tfastins_nocheck(b, p, t);
                        if (rc != GDK_SUCCEED) {
@@ -1276,6 +1285,8 @@ BUNappendmulti(BAT *b, const void *value
                        p++;
                }
                nunique = b->thash ? b->thash->nunique : 0;
+               b->tnil = b->ttype != TYPE_msk;
+               b->tnonil = false;
        }
        MT_lock_set(&b->theaplock);
        b->tminpos = bi.minpos;
@@ -1286,8 +1297,6 @@ BUNappendmulti(BAT *b, const void *value
        if (b->ttype == TYPE_oid) {
                /* spend extra effort on oid (possible candidate list) */
                if (values == NULL || is_oid_nil(((oid *) values)[0])) {
-                       b->tnil = true;
-                       b->tnonil = false;
                        b->tsorted = false;
                        b->trevsorted = false;
                        b->tkey = false;
@@ -1298,8 +1307,6 @@ BUNappendmulti(BAT *b, const void *value
                                b->trevsorted = true;
                                b->tkey = true;
                                b->tseqbase = count == 1 ? ((oid *) values)[0] 
: oid_nil;
-                               b->tnil = false;
-                               b->tnonil = true;
                        } else {
                                if (!is_oid_nil(b->tseqbase) &&
                                    (count > 1 ||
@@ -1328,8 +1335,6 @@ BUNappendmulti(BAT *b, const void *value
                        }
                        for (BUN i = 1; i < count; i++) {
                                if (is_oid_nil(((oid *) values)[i])) {
-                                       b->tnil = true;
-                                       b->tnonil = false;
                                        b->tsorted = false;
                                        b->trevsorted = false;
                                        b->tkey = false;
@@ -1360,18 +1365,14 @@ BUNappendmulti(BAT *b, const void *value
                        }
                }
        } else if (!ATOMlinear(b->ttype)) {
-               b->tnil = b->tnonil = false;
                b->tsorted = b->trevsorted = b->tkey = false;
        } else if (b->batCount == 0) {
                if (values == NULL) {
                        b->tsorted = b->trevsorted = true;
                        b->tkey = count == 1;
-                       b->tnil = true;
-                       b->tnonil = false;
                        b->tunique_est = 1;
                } else {
                        int c;
-                       b->tnil = b->tnonil = false;
                        switch (count) {
                        case 1:
                                b->tsorted = b->trevsorted = b->tkey = true;
@@ -1418,11 +1419,7 @@ BUNappendmulti(BAT *b, const void *value
                b->tnokey[0] = 0;
                b->tnokey[1] = !b->tkey;
                b->tunique_est = (double) (1 + b->tkey);
-               b->tnil |= values == NULL;
-               b->tnonil = false;
        } else {
-               b->tnil |= values == NULL;
-               b->tnonil = false;
                b->tsorted = b->trevsorted = b->tkey = false;
        }
        BATsetcount(b, p);
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -767,6 +767,18 @@ la_bat_updates(logger *lg, logaction *la
                                        const void *t = BUNtail(vi, p);
 
                                        if (q < cnt) {
+                                               if (b->tnosorted == q)
+                                                       b->tnosorted = 0;
+                                               if (b->tnorevsorted == q)
+                                                       b->tnorevsorted = 0;
+                                               if (b->tnokey[0] == q ||
+                                                   b->tnokey[1] == q) {
+                                                       b->tnokey[0] = 0;
+                                                       b->tnokey[1] = 0;
+                                               }
+                                               b->tkey = false;
+                                               b->tsorted = false;
+                                               b->tkey = false;
                                                if (BUNreplace(b, q, t, true) 
!= GDK_SUCCEED) {
                                                        logbat_destroy(b);
                                                        bat_iterator_end(&vi);
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1375,6 +1375,7 @@ BATrange(BATiter *bi, const void *tl, co
        BAT *pb = NULL;
        int c;
        int (*atomcmp) (const void *, const void *) = ATOMcompare(bi->type);
+       BATiter bi2 = *bi;
 
        if (tl && (*atomcmp)(tl, ATOMnilptr(bi->type)) == 0)
                tl = NULL;
@@ -1388,26 +1389,36 @@ BATrange(BATiter *bi, const void *tl, co
 
        /* keep locked while we look at the property values */
        MT_lock_set(&bi->b->theaplock);
-       if (bi->minpos != BUN_NONE)
+       if (bi->sorted && (bi->nonil || atomcmp(BUNtail(*bi, 0), 
ATOMnilptr(bi->type)) != 0))
+               minval = BUNtail(*bi, 0);
+       else if (bi->revsorted && (bi->nonil || atomcmp(BUNtail(*bi, bi->count 
- 1), ATOMnilptr(bi->type)) != 0))
+               minval = BUNtail(*bi, bi->count - 1);
+       else if (bi->minpos != BUN_NONE)
                minval = BUNtail(*bi, bi->minpos);
        else if ((minprop = BATgetprop_nolock(bi->b, GDK_MIN_BOUND)) != NULL)
                minval = VALptr(minprop);
-       if (bi->maxpos != BUN_NONE) {
-               maxval = BUNtail(*bi, bi->maxpos);
+       if (bi->sorted && (bi->nonil || atomcmp(BUNtail(bi2, bi->count - 1), 
ATOMnilptr(bi->type)) != 0)) {
+               maxval = BUNtail(bi2, bi->count - 1);
+               maxincl = true;
+       } else if (bi->revsorted && (bi->nonil || atomcmp(BUNtail(bi2, 0), 
ATOMnilptr(bi->type)) != 0)) {
+               maxval = BUNtail(bi2, 0);
+               maxincl = true;
+       } else if (bi->maxpos != BUN_NONE) {
+               maxval = BUNtail(bi2, bi->maxpos);
                maxincl = true;
        } else if ((maxprop = BATgetprop_nolock(bi->b, GDK_MAX_BOUND)) != NULL) 
{
                maxval = VALptr(maxprop);
                maxincl = false;
        }
        bool keep = false;      /* keep lock on parent bat? */
-       if (minprop == NULL || maxprop == NULL) {
+       if (minval == NULL || maxval == NULL) {
                if (pb != NULL) {
                        MT_lock_set(&pb->theaplock);
-                       if (minprop == NULL && (minprop = BATgetprop_nolock(pb, 
GDK_MIN_BOUND)) != NULL) {
+                       if (minval == NULL && (minprop = BATgetprop_nolock(pb, 
GDK_MIN_BOUND)) != NULL) {
                                keep = true;
                                minval = VALptr(minprop);
                        }
-                       if (maxprop == NULL && (maxprop = BATgetprop_nolock(pb, 
GDK_MAX_BOUND)) != NULL) {
+                       if (maxval == NULL && (maxprop = BATgetprop_nolock(pb, 
GDK_MAX_BOUND)) != NULL) {
                                keep = true;
                                maxval = VALptr(maxprop);
                                maxincl = true;
@@ -1418,20 +1429,20 @@ BATrange(BATiter *bi, const void *tl, co
                }
        }
 
-       if (minprop == NULL && maxprop == NULL) {
+       if (minval == NULL && maxval == NULL) {
                range = range_inside; /* strictly: unknown */
-       } else if (maxprop &&
+       } else if (maxval &&
                   tl &&
                   ((c = atomcmp(tl, maxval)) > 0 ||
                    ((!maxincl || !li) && c == 0))) {
                range = range_after;
-       } else if (minprop &&
+       } else if (minval &&
                   th &&
                   ((c = atomcmp(th, minval)) < 0 ||
                    (!hi && c == 0))) {
                range = range_before;
        } else if (tl == NULL) {
-               if (minprop == NULL) {
+               if (minval == NULL) {
                        c = atomcmp(th, maxval);
                        if (c < 0 || ((maxincl || !hi) && c == 0))
                                range = range_atstart;
@@ -1441,7 +1452,7 @@ BATrange(BATiter *bi, const void *tl, co
                        c = atomcmp(th, minval);
                        if (c < 0 || (!hi && c == 0))
                                range = range_before;
-                       else if (maxprop == NULL)
+                       else if (maxval == NULL)
                                range = range_atstart;
                        else {
                                c = atomcmp(th, maxval);
@@ -1452,7 +1463,7 @@ BATrange(BATiter *bi, const void *tl, co
                        }
                }
        } else if (th == NULL) {
-               if (maxprop == NULL) {
+               if (maxval == NULL) {
                        c = atomcmp(tl, minval);
                        if (c >= 0)
                                range = range_atend;
@@ -1462,7 +1473,7 @@ BATrange(BATiter *bi, const void *tl, co
                        c = atomcmp(tl, maxval);
                        if (c > 0 || ((!maxincl || !li) && c == 0))
                                range = range_after;
-                       else if (minprop == NULL)
+                       else if (minval == NULL)
                                range = range_atend;
                        else {
                                c = atomcmp(tl, minval);
@@ -1472,13 +1483,13 @@ BATrange(BATiter *bi, const void *tl, co
                                        range = range_contains;
                        }
                }
-       } else if (minprop == NULL) {
+       } else if (minval == NULL) {
                c = atomcmp(th, maxval);
                if (c < 0 || ((maxincl || !hi) && c == 0))
                        range = range_inside;
                else
                        range = range_atend;
-       } else if (maxprop == NULL) {
+       } else if (maxval == NULL) {
                c = atomcmp(tl, minval);
                if (c >= 0)
                        range = range_inside;
@@ -1907,11 +1918,12 @@ BATselect(BAT *b, BAT *s, const void *tl
        else
                pb = NULL;
        pbi = bat_iterator(pb);
-       /* use hash only for equi-join, and then only if b or its
-        * parent already has a hash, or if b or its parent is
-        * persistent and the total size wouldn't be too large; check
-        * for existence of hash last since that may involve I/O */
-       if (equi || antiequi) {
+       /* use hash only for equi-join if the bat is not sorted, but
+        * only if b or its parent already has a hash, or if b or its
+        * parent is persistent and the total size wouldn't be too
+        * large; check for existence of hash last since that may
+        * involve I/O */
+       if ((equi || antiequi) && !bi.sorted && !bi.revsorted) {
                double cost = joincost(b, 1, &ci, &havehash, &phash, NULL);
                if (cost > 0 && cost < ci.ncand) {
                        wanthash = true;
@@ -2011,7 +2023,7 @@ BATselect(BAT *b, BAT *s, const void *tl
                }
        }
 
-       if (!havehash && (bi.sorted || bi.revsorted || oidxh != NULL)) {
+       if (bi.sorted || bi.revsorted || (!havehash && oidxh != NULL)) {
                BUN low = 0;
                BUN high = bi.count;
 
diff --git a/monetdb5/mal/Tests/dataflow01.maltest 
b/monetdb5/mal/Tests/dataflow01.maltest
--- a/monetdb5/mal/Tests/dataflow01.maltest
+++ b/monetdb5/mal/Tests/dataflow01.maltest
@@ -4,7 +4,7 @@ b:= bat.new(:lng);
 k:=0;
 INT_MAX := 2147483647;
 dbgmsk_restore := mdb.getDebug();
-dbgmsk_unset := 8+8388608;
+dbgmsk_unset := 8+2;
 dbgmsk_keep := calc.xor(INT_MAX,dbgmsk_unset);
 dbgmsk_set := calc.and(dbgmsk_restore,dbgmsk_keep);
 mdb.setDebug(dbgmsk_set);
diff --git a/monetdb5/mal/Tests/tst901a.maltest 
b/monetdb5/mal/Tests/tst901a.maltest
--- a/monetdb5/mal/Tests/tst901a.maltest
+++ b/monetdb5/mal/Tests/tst901a.maltest
@@ -3,7 +3,7 @@ function foo();
 b:= bat.new(:lng);
 INT_MAX := 2147483647;
 dbgmsk_restore := mdb.getDebug();
-dbgmsk_unset := 8+8388608;
+dbgmsk_unset := 8+2;
 dbgmsk_keep := calc.xor(INT_MAX,dbgmsk_unset);
 dbgmsk_set := calc.and(dbgmsk_restore,dbgmsk_keep);
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to