Changeset: 1800cb386d51 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1800cb386d51
Modified Files:
        gdk/gdk_logger.c
        gdk/gdk_logger_old.c
Branch: logger-fix
Log Message:

merged with sep2022


diffs (truncated from 1197 to 300 lines):

diff --git a/clients/odbc/driver/SQLExecute.c b/clients/odbc/driver/SQLExecute.c
--- a/clients/odbc/driver/SQLExecute.c
+++ b/clients/odbc/driver/SQLExecute.c
@@ -424,9 +424,6 @@ MNDBExecute(ODBCStmt *stmt)
                return SQL_ERROR;
        }
 
-       /* internal state correctness checks */
-       assert(stmt->State == PREPARED0 || stmt->State == EXECUTED0 || 
stmt->ImplRowDescr->descRec != NULL);
-
        assert(stmt->Dbc);
        assert(stmt->Dbc->mid);
        hdl = stmt->hdl;
diff --git a/gdk/gdk_analytic_bounds.c b/gdk/gdk_analytic_bounds.c
--- a/gdk/gdk_analytic_bounds.c
+++ b/gdk/gdk_analytic_bounds.c
@@ -1160,7 +1160,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
                                break;
                        }
                        default:
-                               assert(0);
+                               MT_UNREACHABLE();
                        }
                        if (is_lng_nil(limit) || limit < 0 || 
is_int_nil(int_limit) || int_limit < 0) {
                                goto invalid_bound;
@@ -1444,7 +1444,7 @@ GDKanalyticalwindowbounds(BAT *r, BAT *b
        case 2:
                return GDKanalyticalgroupsbounds(r, b, p, l, bound, tp2, 
preceding);
        default:
-               assert(0);
+               MT_UNREACHABLE();
        }
        GDKerror("42000!unit type %d not supported (this is a bug).\n", unit);
        return GDK_FAIL;
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -100,55 +100,51 @@ BATcreatedesc(oid hseq, int tt, bool hea
                .batTransient = true,
                .batRestricted = BAT_WRITE,
        };
-       if (heapnames && (bn->theap = GDKmalloc(sizeof(Heap))) == NULL) {
-               GDKfree(bn);
-               return NULL;
-       }
 
-       /*
-        * add to BBP
-        */
-       if (BBPinsert(bn) == 0) {
-               GDKfree(bn->theap);
-               GDKfree(bn);
-               return NULL;
-       }
-       /*
-        * fill in heap names, so HEAPallocs can resort to disk for
-        * very large writes.
-        */
        if (heapnames) {
-               assert(bn->theap != NULL);
+               if ((bn->theap = GDKmalloc(sizeof(Heap))) == NULL) {
+                       GDKfree(bn);
+                       return NULL;
+               }
                *bn->theap = (Heap) {
-                       .parentid = bn->batCacheid,
                        .farmid = BBPselectfarm(role, bn->ttype, offheap),
                        .dirty = true,
                };
 
-               const char *nme = BBP_physical(bn->batCacheid);
-               settailname(bn->theap, nme, tt, width);
-
                if (ATOMneedheap(tt)) {
                        if ((bn->tvheap = GDKmalloc(sizeof(Heap))) == NULL) {
-                               BBPclear(bn->batCacheid);
-                               HEAPfree(bn->theap, true);
                                GDKfree(bn->theap);
                                GDKfree(bn);
                                return NULL;
                        }
                        *bn->tvheap = (Heap) {
-                               .parentid = bn->batCacheid,
                                .farmid = BBPselectfarm(role, bn->ttype, 
varheap),
                                .dirty = true,
                        };
+               }
+       }
+       /*
+        * add to BBP
+        */
+       if (BBPinsert(bn) == 0) {
+               GDKfree(bn->tvheap);
+               GDKfree(bn->theap);
+               GDKfree(bn);
+               return NULL;
+       }
+       if (bn->theap) {
+               bn->theap->parentid = bn->batCacheid;
+               ATOMIC_INIT(&bn->theap->refs, 1);
+               const char *nme = BBP_physical(bn->batCacheid);
+               settailname(bn->theap, nme, tt, width);
+
+               if (bn->tvheap) {
+                       bn->tvheap->parentid = bn->batCacheid;
                        ATOMIC_INIT(&bn->tvheap->refs, 1);
                        strconcat_len(bn->tvheap->filename,
                                      sizeof(bn->tvheap->filename),
                                      nme, ".theap", NULL);
                }
-               ATOMIC_INIT(&bn->theap->refs, 1);
-       } else {
-               assert(bn->theap == NULL);
        }
        char name[MT_NAME_LEN];
        snprintf(name, sizeof(name), "heaplock%d", bn->batCacheid); /* fits */
diff --git a/gdk/gdk_hash.h b/gdk/gdk_hash.h
--- a/gdk/gdk_hash.h
+++ b/gdk/gdk_hash.h
@@ -211,7 +211,7 @@ HASHgetlink(const Hash *h, BUN i)
 #define hash_flt(H,V)  hash_int(H,V)
 #define hash_dbl(H,V)  hash_lng(H,V)
 
-static inline BUN __attribute__((__const__))
+static inline BUN __attribute__((__pure__))
 mix_uuid(const uuid *u)
 {
        ulng u1, u2;
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -266,7 +266,7 @@ HEAPextend(Heap *h, size_t size, bool ma
                if (!must_mmap) {
                        h->newstorage = h->storage = STORE_MEM;
                        h->base = GDKrealloc(h->base, size);
-                       TRC_DEBUG(HEAP, "Extending malloced heap %s %zu %zu %p 
%p\n", h->filename, size, h->size, bak.base, h->base);
+                       TRC_DEBUG(HEAP, "Extending malloced heap %s %zu->%zu 
%p->%p\n", h->filename, bak.size, size, bak.base, h->base);
                        h->size = size;
                        if (h->base)
                                return GDK_SUCCEED; /* success */
@@ -327,22 +327,6 @@ HEAPextend(Heap *h, size_t size, bool ma
                                        return GDK_SUCCEED;
                                }
                                failure = "h->storage == STORE_MEM && can_map 
&& fd >= 0 && HEAPload() != GDK_SUCCEED";
-                               /* couldn't allocate, now first save data to
-                                * file */
-                               if (HEAPsave_intern(&bak, nme, ext, ".tmp", 
false, bak.free, NULL) != GDK_SUCCEED) {
-                                       failure = "h->storage == STORE_MEM && 
can_map && fd >= 0 && HEAPsave_intern() != GDK_SUCCEED";
-                                       goto failed;
-                               }
-                               /* then free memory */
-                               HEAPfree(&bak, false);
-                               /* and load heap back in via memory-mapped
-                                * file */
-                               if (HEAPload_intern(h, nme, ext, ".tmp", false) 
== GDK_SUCCEED) {
-                                       /* success! */
-                                       GDKclrerr();    /* don't leak errors 
from e.g. HEAPload */
-                                       return GDK_SUCCEED;
-                               }
-                               failure = "h->storage == STORE_MEM && can_map 
&& fd >= 0 && HEAPload_intern() != GDK_SUCCEED";
                                /* we failed */
                        } else {
                                failure = "h->storage == STORE_MEM && can_map 
&& fd < 0";
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -124,15 +124,15 @@
 #define IMPRINTS_VERSION       2
 #define IMPRINTS_HEADER_SIZE   4 /* nr of size_t fields in header */
 
-#define BINSIZE(B, FUNC, T)                    \
-       do {                                    \
-               switch (B) {                    \
-               case 8: FUNC(T,8); break;       \
-               case 16: FUNC(T,16); break;     \
-               case 32: FUNC(T,32); break;     \
-               case 64: FUNC(T,64); break;     \
-               default: assert(0); break;      \
-               }                               \
+#define BINSIZE(B, FUNC, T)                            \
+       do {                                            \
+               switch (B) {                            \
+               case 8: FUNC(T,8); break;               \
+               case 16: FUNC(T,16); break;             \
+               case 32: FUNC(T,32); break;             \
+               case 64: FUNC(T,64); break;             \
+               default: MT_UNREACHABLE(); break;       \
+               }                                       \
        } while (0)
 
 
@@ -253,7 +253,7 @@ imprints_create(BAT *b, BATiter *bi, voi
                break;
        default:
                /* should never reach here */
-               assert(0);
+               MT_UNREACHABLE();
        }
 
        *dictcnt = dcnt;
@@ -608,7 +608,7 @@ BATimprints(BAT *b)
                        break;
                default:
                        /* should never reach here */
-                       assert(0);
+                       MT_UNREACHABLE();
                }
 
                imprints_create(b, &bi,
@@ -731,9 +731,7 @@ IMPSgetbin(int tpe, bte bits, const char
                break;
        }
        default:
-               assert(0);
-               (void) inbins;
-               break;
+               MT_UNREACHABLE();
        }
        return ret;
 }
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -906,7 +906,7 @@ la_apply(logger *lg, logaction *c, int t
                        ret = la_bat_destroy(lg, c, tid);
                break;
        default:
-               assert(0);
+               MT_UNREACHABLE();
        }
        return ret;
 }
diff --git a/gdk/gdk_logger_old.c b/gdk/gdk_logger_old.c
--- a/gdk/gdk_logger_old.c
+++ b/gdk/gdk_logger_old.c
@@ -936,7 +936,7 @@ la_apply(old_logger *lg, logaction *c)
                ret = la_bat_clear(lg, c);
                break;
        default:
-               assert(0);
+               MT_UNREACHABLE();
        }
        lg->changes += (ret == GDK_SUCCEED);
        return ret;
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -420,7 +420,8 @@ quickins(oid *dst, BUN cnt, oid o, BAT *
                        checkMINMAX(64, TYPE);                          \
                        impsmask(ISDENSE,TEST,64);                      \
                        break;                                          \
-               default: assert(0); break;                              \
+               default:                                                \
+                       MT_UNREACHABLE();                               \
                }                                                       \
        } while (false)
 
@@ -2639,7 +2640,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT 
                        default:
                                ncnt = BUN_NONE;
                                GDKerror("unsupported type\n");
-                               assert(0);
+                               MT_UNREACHABLE();
                        }
                        if (ncnt == BUN_NONE) {
                                IMPSdecref(imprints, false);
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -43,93 +43,13 @@ MT_Lock     mal_copyLock = MT_LOCK_INITI
 MT_Lock     mal_delayLock = MT_LOCK_INITIALIZER(mal_delayLock);
 
 
-
-#ifdef HAVE_PTHREAD_H
-
-static pthread_key_t tl_client_key;
-
-static int
-initialize_tl_client_key(void)
-{
-       static bool initialized = false;
-       if (initialized)
-               return 0;
-
-       if (pthread_key_create(&tl_client_key, NULL) != 0)
-               return -1;
-
-       initialized = true;
-       return 0;
-}
-
 /* declared in mal_interpreter.h so MAL operators can access it */
 Client
 getClientContext(void)
 {
-       if (initialize_tl_client_key())
-               return NULL;
-       return (Client) pthread_getspecific(tl_client_key);
-}
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to