Changeset: 7524c44de275 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7524c44de275
Modified Files:
        gdk/gdk_bbp.c
        tools/monetdbe/monetdbe.c
Branch: properties
Log Message:

Merged with default


diffs (truncated from 858 to 300 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2623,7 +2623,6 @@ dump_database(Mapi mid, stream *toConsol
                "ORDER BY sch.name, seq.name";
        const char *sequences2 =
                "SELECT * FROM sys.describe_sequences ORDER BY sch, seq";
-       /* we must dump tables, views, functions/procedures and triggers in 
order of creation since they can refer to each other */
        const char *tables =
                "SELECT t.id AS id, "
                           "s.name AS sname, "
@@ -2682,6 +2681,8 @@ dump_database(Mapi mid, stream *toConsol
                  "AND d.id = t2.id "
                  "AND t2.schema_id = s2.id "
                "ORDER BY t1.id, t2.id";
+       /* we must dump views, functions/procedures and triggers in order
+        * of creation since they can refer to each other */
        const char *views_functions_triggers =
                "with vft (sname, name, id, query, remark) AS ("
                        "SELECT s.name AS sname, " /* views */
@@ -2896,11 +2897,11 @@ dump_database(Mapi mid, stream *toConsol
               !mnstr_errnr(toConsole) &&
               mapi_fetch_row(hdl) != 0) {
                char *id = strdup(mapi_fetch_field(hdl, 0));
-               char *nschema = mapi_fetch_field(hdl, 1), *schema = nschema ? 
strdup(nschema) : NULL; /* the fetched value might be null, so do this */
+               char *schema = strdup(mapi_fetch_field(hdl, 1));
                char *name = strdup(mapi_fetch_field(hdl, 2));
                const char *type = mapi_fetch_field(hdl, 3);
 
-               if (mapi_error(mid) || !id || (nschema && !schema) || !name) {
+               if (mapi_error(mid) || id == NULL || schema == NULL || name == 
NULL) {
                        free(id);
                        free(schema);
                        free(name);
@@ -2916,8 +2917,8 @@ dump_database(Mapi mid, stream *toConsol
                        if (curschema == NULL || strcmp(schema, curschema) != 
0) {
                                if (curschema)
                                        free(curschema);
-                               curschema = schema ? strdup(schema) : NULL;
-                               if (schema && !curschema) {
+                               curschema = strdup(schema);
+                               if (curschema == NULL) {
                                        free(id);
                                        free(schema);
                                        free(name);
@@ -3076,12 +3077,12 @@ dump_database(Mapi mid, stream *toConsol
               !mnstr_errnr(toConsole) &&
               mapi_fetch_row(hdl) != 0) {
                char *id = strdup(mapi_fetch_field(hdl, 0));
-               char *nschema = mapi_fetch_field(hdl, 1), *schema = nschema ? 
strdup(nschema) : NULL; /* the fetched value might be null, so do this */
+               char *schema = strdup(mapi_fetch_field(hdl, 1));
                char *name = strdup(mapi_fetch_field(hdl, 2));
                const char *query = mapi_fetch_field(hdl, 3);
                const char *remark = mapi_fetch_field(hdl, 4);
 
-               if (mapi_error(mid) || !id || (nschema && !schema) || !name) {
+               if (mapi_error(mid) || id == NULL || schema == NULL || name == 
NULL) {
                        free(id);
                        free(schema);
                        free(name);
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -1742,12 +1742,18 @@ BATprod(void *res, int tp, BAT *b, BAT *
 /* ---------------------------------------------------------------------- */
 /* average */
 
+#define GOTO_BAILOUT()                                 \
+       do {                                            \
+               GDKfree(avgs);                          \
+               GOTO_LABEL_TIMEOUT_HANDLER(bailout);    \
+       } while (0)
+
 #define AGGR_AVG(TYPE)                                                 \
        do {                                                            \
                const TYPE *restrict vals = (const TYPE *) bi.base;     \
                TYPE *restrict avgs = GDKzalloc(ngrp * sizeof(TYPE));   \
-               if (avgs == NULL)                       \
-                       goto bailout;                           \
+               if (avgs == NULL)                                       \
+                       goto bailout;                                   \
                TIMEOUT_LOOP(ncand, timeoffset) {                       \
                        i = canditer_next(&ci) - b->hseqbase;           \
                        if (gids == NULL ||                             \
@@ -1767,8 +1773,7 @@ BATprod(void *res, int tp, BAT *b, BAT *
                                }                                       \
                        }                                               \
                }                                                       \
-               TIMEOUT_CHECK(timeoffset,                               \
-                             GOTO_LABEL_TIMEOUT_HANDLER(bailout));     \
+               TIMEOUT_CHECK(timeoffset, GOTO_BAILOUT());              \
                for (i = 0; i < ngrp; i++) {                            \
                        if (cnts[i] == 0 || is_lng_nil(cnts[i])) {      \
                                dbls[i] = dbl_nil;                      \
@@ -4023,8 +4028,8 @@ BATmax(BAT *b, void *aggr)
 
 #define DO_QUANTILE_AVG(TPE)                                           \
        do {                                                            \
-               TPE low = *(TPE*) BUNtail(bi, r + (BUN) hi);            \
-               TPE high = *(TPE*) BUNtail(bi, r + (BUN) lo);           \
+               TPE low = *(TPE*) BUNtloc(bi, r + (BUN) hi);            \
+               TPE high = *(TPE*) BUNtloc(bi, r + (BUN) lo);           \
                if (is_##TPE##_nil(low) || is_##TPE##_nil(high)) {      \
                        val = dbl_nil;                                  \
                        nils++;                                         \
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -615,7 +615,7 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                        /* convert \r\n into just \n */
                        if (s[1] != '\n') {
                                TRC_CRITICAL(GDK, "invalid format for BBP.dir 
on line %d", lineno);
-                               return GDK_FAIL;
+                               goto bailout;
                        }
                        *s++ = '\n';
                        *s = 0;
@@ -630,12 +630,12 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                           &count, &capacity, &base,
                           &nread) < 8) {
                        TRC_CRITICAL(GDK, "invalid format for BBP.dir on line 
%d", lineno);
-                       return GDK_FAIL;
+                       goto bailout;
                }
 
                if (batid >= N_BBPINIT * BBPINIT) {
                        TRC_CRITICAL(GDK, "bat ID (%" PRIu64 ") too large to 
accomodate (max %d), on line %d.", batid, N_BBPINIT * BBPINIT - 1, lineno);
-                       return GDK_FAIL;
+                       goto bailout;
                }
 
                /* convert both / and \ path separators to our own DIR_SEP */
@@ -654,26 +654,26 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                if (batid >= (uint64_t) ATOMIC_GET(&BBPsize)) {
                        if ((bat) ATOMIC_GET(&BBPsize) + 1 >= BBPlimit &&
                            BBPextend(0, false, bid + 1) != GDK_SUCCEED)
-                               return GDK_FAIL;
+                               goto bailout;
                        ATOMIC_SET(&BBPsize, bid + 1);
                }
                if (BBP_desc(bid) != NULL) {
                        TRC_CRITICAL(GDK, "duplicate entry in BBP.dir (ID = "
                                     "%" PRIu64 ") on line %d.", batid, lineno);
-                       return GDK_FAIL;
+                       goto bailout;
                }
                if ((bn = GDKzalloc(sizeof(BAT))) == NULL ||
                    (bn->theap = GDKzalloc(sizeof(Heap))) == NULL) {
                        GDKfree(bn);
                        TRC_CRITICAL(GDK, "cannot allocate memory for BAT.");
-                       return GDK_FAIL;
+                       goto bailout;
                }
                bn->batCacheid = bid;
                if (BATroles(bn, NULL) != GDK_SUCCEED) {
                        GDKfree(bn->theap);
                        GDKfree(bn);
                        TRC_CRITICAL(GDK, "BATroles failed.");
-                       return GDK_FAIL;
+                       goto bailout;
                }
                bn->batTransient = false;
                bn->batCopiedtodisk = true;
@@ -693,7 +693,7 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                if (base > (uint64_t) GDK_oid_max) {
                        BATdestroy(bn);
                        TRC_CRITICAL(GDK, "head seqbase out of range (ID = %" 
PRIu64 ", seq = %" PRIu64 ") on line %d.", batid, base, lineno);
-                       return GDK_FAIL;
+                       goto bailout;
                }
                bn->hseqbase = (oid) base;
                n = heapinit(bn, buf + nread,
@@ -703,13 +703,13 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                             bbpversion, bid, filename, lineno);
                if (n < 0) {
                        BATdestroy(bn);
-                       return GDK_FAIL;
+                       goto bailout;
                }
                nread += n;
                n = vheapinit(bn, buf + nread, bid, filename, lineno);
                if (n < 0) {
                        BATdestroy(bn);
-                       return GDK_FAIL;
+                       goto bailout;
                }
                nread += n;
 #ifdef GDKLIBRARY_HASHASH
@@ -717,9 +717,8 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                        assert(bbpversion <= GDKLIBRARY_HASHASH);
                        bat *sb = GDKrealloc(hbats, ++nhbats * sizeof(bat));
                        if (sb == NULL) {
-                               GDKfree(hbats);
                                BATdestroy(bn);
-                               return GDK_FAIL;
+                               goto bailout;
                        }
                        hbats = sb;
                        hbats[nhbats - 1] = bn->batCacheid;
@@ -728,22 +727,16 @@ BBPreadEntries(FILE *fp, unsigned bbpver
 
                if (buf[nread] != '\n' && buf[nread] != ' ') {
                        BATdestroy(bn);
-#ifdef GDKLIBRARY_HASHASH
-                       GDKfree(hbats);
-#endif
                        TRC_CRITICAL(GDK, "invalid format for BBP.dir on line 
%d", lineno);
-                       return GDK_FAIL;
+                       goto bailout;
                }
                if (buf[nread] == ' ')
                        options = buf + nread + 1;
 
                if (snprintf(BBP_bak(bid), sizeof(BBP_bak(bid)), "tmp_%o", 
(unsigned) bid) >= (int) sizeof(BBP_bak(bid))) {
                        BATdestroy(bn);
-#ifdef GDKLIBRARY_HASHASH
-                       GDKfree(hbats);
-#endif
                        TRC_CRITICAL(GDK, "BBP logical filename directory is 
too large, on line %d\n", lineno);
-                       return GDK_FAIL;
+                       goto bailout;
                }
                if ((s = strchr(headname, '~')) != NULL && s == headname) {
                        /* sizeof(logical) > sizeof(BBP_bak(bid)), so
@@ -760,11 +753,8 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                        BBP_logical(bid) = GDKstrdup(logical);
                        if (BBP_logical(bid) == NULL) {
                                BATdestroy(bn);
-#ifdef GDKLIBRARY_HASHASH
-                               GDKfree(hbats);
-#endif
                                TRC_CRITICAL(GDK, "GDKstrdup failed\n");
-                               return GDK_FAIL;
+                               goto bailout;
                        }
                }
                /* tailname is ignored */
@@ -778,11 +768,8 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                        BBP_options(bid) = GDKstrdup(options);
                        if (BBP_options(bid) == NULL) {
                                BATdestroy(bn);
-#ifdef GDKLIBRARY_HASHASH
-                               GDKfree(hbats);
-#endif
                                TRC_CRITICAL(GDK, "GDKstrdup failed\n");
-                               return GDK_FAIL;
+                               goto bailout;
                        }
                }
                BBP_refs(bid) = 0;
@@ -796,6 +783,12 @@ BBPreadEntries(FILE *fp, unsigned bbpver
        *nhashbats = nhbats;
 #endif
        return GDK_SUCCEED;
+
+  bailout:
+#ifdef GDKLIBRARY_HASHASH
+       GDKfree(hbats);
+#endif
+       return GDK_FAIL;
 }
 
 /* check that the necessary files for all BATs exist and are large
@@ -2137,7 +2130,7 @@ BBPdir_step(bat bid, BUN size, int n, ch
                        }
                        *obbpfp = NULL;
                } else {
-                       if (sscanf(buf, "%d", &n) != 1 || n <= 0) {
+                       if (sscanf(buf, "%d", &n) != 1 || n <= 0 || n >= 
N_BBPINIT * BBPINIT) {
                                GDKerror("subcommit attempted with invalid 
backup BBP.dir.");
                                goto bailout;
                        }
@@ -3070,7 +3063,7 @@ decref(bat i, bool logical, bool release
         * conditions are met */
        if (BBP_refs(i) == 0 &&
            (BBP_lrefs(i) == 0 ||
-            (b != NULL
+            (b != NULL && b->theap != NULL
              ? (!BATdirty(b) &&
                 !(BBP_status(i) & chkflag) &&
                 (BBP_status(i) & BBPPERSISTENT) &&
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -1885,7 +1885,8 @@ mergejoin(BAT **r1p, BAT **r2p, BAT *l, 
                         !BATtvoid(l) && !BATtvoid(r));
                lordering = l->tsorted && (r->tsorted || !equal_order) ? 1 : -1;
                rordering = equal_order ? lordering : -lordering;
-               if (!l->tnonil && !nil_matches && !nil_on_miss) {
+               if (!l->tnonil && !nil_matches && !nil_on_miss && lvals != 
NULL) {
+                       /* find first non-nil */
                        nl = binsearch(NULL, 0, l->ttype, lvals, lvars, 
li.width, 0, BATcount(l), nil, l->tsorted ? 1 : -1, l->tsorted ? 1 : 0);
                        nl = canditer_search(lci, nl + l->hseqbase, true);
                        if (l->tsorted) {
diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c
--- a/gdk/gdk_unique.c
+++ b/gdk/gdk_unique.c
@@ -267,11 +267,11 @@ BATunique(BAT *b, BAT *s)
                                HASHput(hs, prb, p);
                        }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to