Changeset: 2a087a139713 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2a087a139713
Modified Files:
        gdk/gdk.h
        gdk/gdk_bbp.c
        gdk/gdk_logger.c
        gdk/gdk_select.c
        monetdb5/mal/mal_client.c
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
Branch: default
Log Message:

Merge with Sep2022 branch.


diffs (truncated from 832 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1569,46 +1569,51 @@ BATsettrivprop(BAT *b)
                b->tnosorted = b->tnorevsorted = 0;
                b->tnokey[0] = b->tnokey[1] = 0;
                b->tunique_est = (double) b->batCount;
+               b->tkey = true;
                if (ATOMlinear(b->ttype)) {
                        b->tsorted = true;
                        b->trevsorted = true;
-               }
-               b->tkey = true;
-               if (b->batCount == 0) {
-                       b->tminpos = BUN_NONE;
-                       b->tmaxpos = BUN_NONE;
-                       b->tnonil = true;
-                       b->tnil = false;
-                       if (b->ttype == TYPE_oid) {
-                               b->tseqbase = 0;
-                       }
-               } else if (b->ttype == TYPE_oid) {
-                       oid sqbs = ((const oid *) b->theap->base)[b->tbaseoff];
-                       if (is_oid_nil(sqbs)) {
-                               b->tnonil = false;
-                               b->tnil = true;
+                       if (b->batCount == 0) {
+                               b->tminpos = BUN_NONE;
+                               b->tmaxpos = BUN_NONE;
+                               b->tnonil = true;
+                               b->tnil = false;
+                               if (b->ttype == TYPE_oid) {
+                                       b->tseqbase = 0;
+                               }
+                       } else if (b->ttype == TYPE_oid) {
+                               oid sqbs = ((const oid *) 
b->theap->base)[b->tbaseoff];
+                               if (is_oid_nil(sqbs)) {
+                                       b->tnonil = false;
+                                       b->tnil = true;
+                                       b->tminpos = BUN_NONE;
+                                       b->tmaxpos = BUN_NONE;
+                               } else {
+                                       b->tnonil = true;
+                                       b->tnil = false;
+                                       b->tminpos = 0;
+                                       b->tmaxpos = 0;
+                               }
+                               b->tseqbase = sqbs;
+                       } else if ((b->tvheap
+                                   ? ATOMcmp(b->ttype,
+                                             b->tvheap->base + 
VarHeapVal(Tloc(b, 0), 0, b->twidth),
+                                             ATOMnilptr(b->ttype))
+                                   : ATOMcmp(b->ttype, Tloc(b, 0),
+                                             ATOMnilptr(b->ttype))) == 0) {
+                               /* the only value is NIL */
                                b->tminpos = BUN_NONE;
                                b->tmaxpos = BUN_NONE;
                        } else {
-                               b->tnonil = true;
-                               b->tnil = false;
+                               /* the only value is both min and max */
                                b->tminpos = 0;
                                b->tmaxpos = 0;
                        }
-                       b->tseqbase = sqbs;
-               } else if ((b->tvheap
-                           ? ATOMcmp(b->ttype,
-                                     b->tvheap->base + VarHeapVal(Tloc(b, 0), 
0, b->twidth),
-                                     ATOMnilptr(b->ttype))
-                           : ATOMcmp(b->ttype, Tloc(b, 0),
-                                     ATOMnilptr(b->ttype))) == 0) {
-                       /* the only value is NIL */
+               } else {
+                       b->tsorted = false;
+                       b->trevsorted = false;
                        b->tminpos = BUN_NONE;
                        b->tmaxpos = BUN_NONE;
-               } else {
-                       /* the only value is both min and max */
-                       b->tminpos = 0;
-                       b->tmaxpos = 0;
                }
        } else if (b->batCount == 2 && ATOMlinear(b->ttype)) {
                int c;
@@ -1629,6 +1634,8 @@ BATsettrivprop(BAT *b)
        } else if (!ATOMlinear(b->ttype)) {
                b->tsorted = false;
                b->trevsorted = false;
+               b->tminpos = BUN_NONE;
+               b->tmaxpos = BUN_NONE;
        }
 }
 
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -960,7 +960,8 @@ BBPcheckbats(unsigned bbpversion)
                        if (statb.st_size > (off_t) hfree) {
                                int fd;
                                if ((fd = MT_open(path, O_RDWR | O_CLOEXEC | 
O_BINARY)) >= 0) {
-                                       (void) ftruncate(fd, hfree);
+                                       if (ftruncate(fd, hfree) == -1)
+                                               perror("ftruncate");
                                        (void) close(fd);
                                }
                        }
@@ -988,7 +989,8 @@ BBPcheckbats(unsigned bbpversion)
                        if (statb.st_size > (off_t) hfree) {
                                int fd;
                                if ((fd = MT_open(path, O_RDWR | O_CLOEXEC | 
O_BINARY)) >= 0) {
-                                       (void) ftruncate(fd, hfree);
+                                       if (ftruncate(fd, hfree) == -1)
+                                               perror("ftruncate");
                                        (void) close(fd);
                                }
                        }
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1244,7 +1244,7 @@ log_read_transaction(logger *lg)
                GDKdebug = dbg;
 
        if (cands)
-               GDKfree(cands);
+               BBPunfix(cands->batCacheid);
        if (!ok)
                return LOG_EOF;
        return err;
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1328,7 +1328,7 @@ BATselect(BAT *b, BAT *s, const void *tl
        nil = ATOMnilptr(t);
        /* can we use the base type? */
        t = ATOMbasetype(t);
-       lnil = ATOMcmp(t, tl, nil) == 0; /* low value = nil? */
+       lnil = nil && ATOMcmp(t, tl, nil) == 0; /* low value = nil? */
 
        if (!lnil && th != NULL && (!li || !hi) && !anti && ATOMcmp(t, tl, th) 
== 0) {
                /* upper and lower bound of range are equal and we
@@ -1354,6 +1354,8 @@ BATselect(BAT *b, BAT *s, const void *tl
                        hi = li;
                th = tl;
                hval = true;
+       } else if (nil == NULL) {
+               hval = true;
        } else {
                hval = ATOMcmp(t, th, nil) != 0;
        }
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -283,7 +283,7 @@ MCinitClientRecord(Client c, oid user, b
        }
        c->promptlength = strlen(prompt);
 
-       c->profticks = c->profstmt = NULL;
+       c->profticks = c->profstmt = c->profevents = NULL;
        c->error_row = c->error_fld = c->error_msg = c->error_input = NULL;
        c->sqlprofiler = 0;
        c->blocksize = BLOCK;
@@ -485,7 +485,8 @@ MCcloseClient(Client c)
        if( c->profticks){
                BBPunfix(c->profticks->batCacheid);
                BBPunfix(c->profstmt->batCacheid);
-               c->profticks = c->profstmt = NULL;
+               BBPunfix(c->profevents->batCacheid);
+               c->profticks = c->profstmt = c->profevents = NULL;
        }
        if( c->error_row){
                BBPunfix(c->error_row->batCacheid);
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -108,7 +108,7 @@ lognew(struct logbuf *logbuf)
 static inline void
 logdel(struct logbuf *logbuf)
 {
-       free(logbuf->logbuffer);
+       GDKfree(logbuf->logbuffer);
        logbuf->logbuffer = NULL;
 }
 
@@ -142,7 +142,7 @@ logadd(struct logbuf *logbuf, const char
                        logbuf->logcap = (size_t) tmp_len + (size_t) tmp_len/2;
                        if (logbuf->logcap < LOGLEN)
                                logbuf->logcap = LOGLEN;
-                       alloc_buff = realloc(logbuf->logbuffer, logbuf->logcap);
+                       alloc_buff = GDKrealloc(logbuf->logbuffer, 
logbuf->logcap);
                        if (alloc_buff == NULL) {
                                TRC_ERROR(MAL_SERVER, "Profiler JSON buffer 
reallocation failure\n");
                                logdel(logbuf);
@@ -661,7 +661,7 @@ profilerEvent(MalEvent *me, NonMalEvent 
                }
                if (event) {
                        logjsonInternal(event, true);
-                       free(event);
+                       GDKfree(event);
                }
        }
        MT_lock_unset(&mal_profileLock);
@@ -829,15 +829,10 @@ static void
        cntxt->profticks = cntxt->profstmt = cntxt->profevents = NULL;
 }
 
-static BAT *
+static inline BAT *
 TRACEcreate(int tt)
 {
-       BAT *b;
-
-       b = COLnew(0, tt, 1 << 10, TRANSIENT);
-       if (b == NULL)
-               return NULL;
-       return b;
+       return COLnew(0, tt, 1 << 10, TRANSIENT);
 }
 
 static void
@@ -942,8 +937,7 @@ sqlProfilerEvent(Client cntxt, MalBlkPtr
        }
        errors += BUNappend(cntxt->profticks, &pci->ticks, false) != 
GDK_SUCCEED;
        errors += BUNappend(cntxt->profstmt, c, false) != GDK_SUCCEED;
-       if( ev)
-               errors += BUNappend(cntxt->profevents, ev, false) != 
GDK_SUCCEED;
+       errors += BUNappend(cntxt->profevents, ev ? ev : str_nil, false) != 
GDK_SUCCEED;
        if (errors > 0) {
                /* stop profiling if an error occurred */
                cntxt->sqlprofiler = FALSE;
@@ -951,7 +945,7 @@ sqlProfilerEvent(Client cntxt, MalBlkPtr
 
        MT_lock_unset(&mal_profileLock);
        GDKfree(stmt);
-       if(ev) free(ev);
+       GDKfree(ev);
 }
 
 lng
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -274,7 +274,7 @@ ALGselect2(bat *result, const bat *bid, 
        derefStr(b, low);
        derefStr(b, high);
        nilptr = ATOMnilptr(b->ttype);
-       if (*li == 1 && *hi == 1 &&
+       if (*li == 1 && *hi == 1 && nilptr != NULL &&
                ATOMcmp(b->ttype, low, nilptr) == 0 &&
                ATOMcmp(b->ttype, high, nilptr) == 0) {
                /* special case: equi-select for NIL */
@@ -317,16 +317,18 @@ ALGselect2nil(bat *result, const bat *bi
        /* here we don't need open ended parts with nil */
        if (!nanti) {
                const void *nilptr = ATOMnilptr(b->ttype);
-               if (nli == 1 && ATOMcmp(b->ttype, low, nilptr) == 0) {
-                       low = high;
-                       nli = 0;
+               if (nilptr) {
+                       if (nli == 1 && ATOMcmp(b->ttype, low, nilptr) == 0) {
+                               low = high;
+                               nli = 0;
+                       }
+                       if (nhi == 1 && ATOMcmp(b->ttype, high, nilptr) == 0) {
+                               high = low;
+                               nhi = 0;
+                       }
+                       if (ATOMcmp(b->ttype, low, high) == 0 && 
ATOMcmp(b->ttype, high, nilptr) == 0) /* ugh sql nil != nil */
+                               nanti = 1;
                }
-               if (nhi == 1 && ATOMcmp(b->ttype, high, nilptr) == 0) {
-                       high = low;
-                       nhi = 0;
-               }
-               if (ATOMcmp(b->ttype, low, high) == 0 && ATOMcmp(b->ttype, 
high, nilptr) == 0) /* ugh sql nil != nil */
-                       nanti = 1;
        }
 
        bn = BATselect(b, s, low, high, nli, nhi, nanti);
@@ -385,7 +387,7 @@ ALGselectNotNil(bat *result, const bat *
                throw(MAL, "algebra.selectNotNil", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
 
        MT_lock_set(&b->theaplock);
-       bool bnonil = b->tnonil;
+       bool bnonil = b->tnonil || b->ttype == TYPE_msk;
        MT_lock_unset(&b->theaplock);
        if (!bnonil) {
                BAT *s;
diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -777,6 +777,7 @@ extern sql_key *schema_find_key(sql_tran
 extern sql_idx *find_sql_idx(sql_table *t, const char *kname);
 extern sql_idx *sql_trans_find_idx(sql_trans *tr, sqlid id);
 extern sql_idx *schema_find_idx(sql_trans *tr, sql_schema *s, const char 
*name);
+extern sql_idx *schema_find_idx_id(sql_trans *tr, sql_schema *s, sqlid id);
 
 extern sql_column *find_sql_column(sql_table *t, const char *cname);
 
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to