Changeset: 854a15ff5ed4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/854a15ff5ed4
Modified Files:
        sql/backends/monet5/sql_upgrades.c
        sql/storage/bat/bat_storage.c
Branch: insertonly
Log Message:

Merge with default.


diffs (truncated from 506 to 300 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2247,7 +2247,7 @@ BBPdump(void)
                        continue;
                BAT *b = BBP_desc(i);
                unsigned status = BBP_status(i);
-               printf("# %d: " ALGOOPTBATFMT "refs=%d lrefs=%d status=%u%s",
+               printf("# %d: " ALGOOPTBATFMT " refs=%d lrefs=%d status=%u%s",
                       i,
                       ALGOOPTBATPAR(b),
                       BBP_refs(i),
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2085,6 +2085,12 @@ log_load(const char *fn, const char *log
                lg->seqs_val = BATdescriptor(BBPindex(bak));
                strconcat_len(bak, sizeof(bak), fn, "_dseqs", NULL);
                lg->dseqs = BATdescriptor(BBPindex(bak));
+               if (lg->seqs_id == NULL ||
+                   lg->seqs_val == NULL ||
+                   lg->dseqs == NULL) {
+                       GDKerror("Logger_new: cannot load seqs bats");
+                       goto error;
+               }
        } else {
                lg->seqs_id = logbat_new(TYPE_int, 1, PERSISTENT);
                lg->seqs_val = logbat_new(TYPE_lng, 1, PERSISTENT);
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -550,7 +550,7 @@ GDKload(int farmid, const char *nme, con
                                for (n_expected = (ssize_t) size; n_expected > 
0; n_expected -= n) {
                                        n = read(fd, dst, (unsigned) MIN(1 << 
30, n_expected));
                                        if (n < 0)
-                                               GDKsyserror("GDKload: cannot 
read: name=%s, ext=%s, %zu bytes missing\n", nme, ext ? ext : "", (size_t) 
n_expected);
+                                               GDKsyserror("GDKload: cannot 
read: name=%s, ext=%s, expected %zu, %zd bytes missing\n", nme, ext ? ext : "", 
size, n_expected);
 #ifndef __COVERITY__
                                        /* Coverity doesn't seem to
                                         * recognize that we're just
@@ -567,7 +567,8 @@ GDKload(int farmid, const char *nme, con
                                        /* we couldn't read all, error
                                         * already generated */
                                        GDKfree(ret);
-                                       GDKerror("short read from heap %s%s%s, 
expected %zu, missing %zd\n", nme, ext ? "." : "", ext ? ext : "", size, 
n_expected);
+                                       if (n >= 0) /* don't report error twice 
 */
+                                               GDKerror("short read from heap 
%s%s%s, expected %zu, missing %zd\n", nme, ext ? "." : "", ext ? ext : "", 
size, n_expected);
                                        ret = NULL;
                                }
 #ifndef NDEBUG
@@ -763,13 +764,12 @@ BATsave_iter(BAT *b, BATiter *bi, BUN si
                }
                if (size != b->batCount || b->batInserted < b->batCount) {
                        /* if the sizes don't match, the BAT must be dirty */
-                       b->batCopiedtodisk = false;
                        b->theap->dirty = true;
                        if (b->tvheap)
                                b->tvheap->dirty = true;
-               } else {
-                       b->batCopiedtodisk = true;
                }
+               /* there is something on disk now */
+               b->batCopiedtodisk = true;
                MT_lock_unset(&b->theaplock);
                if (locked &&  b->thash && b->thash != (Hash *) 1)
                        BAThashsave(b, dosync);
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -675,17 +675,16 @@ HASHinfo(BAT *bk, BAT *bv, Hash *h, str 
        return GDK_SUCCEED;
 }
 
-
 static str
-BATinfo(BAT **key, BAT **val, const bat bid)
+BKCinfo(bat *ret1, bat *ret2, const bat *bid)
 {
        const char *mode, *accessmode;
        BAT *bk = NULL, *bv = NULL, *b;
        char bf[oidStrlen];
        char buf[32];
 
-       if ((b = BATdescriptor(bid)) == NULL) {
-               throw(MAL, "BATinfo", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+       if ((b = BATdescriptor(*bid)) == NULL) {
+               throw(MAL, "bat.info", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
        }
 
        bk = COLnew(0, TYPE_str, 128, TRANSIENT);
@@ -694,7 +693,7 @@ BATinfo(BAT **key, BAT **val, const bat 
                BBPreclaim(bk);
                BBPreclaim(bv);
                BBPunfix(b->batCacheid);
-               throw(MAL, "bat.getInfo", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+               throw(MAL, "bat.info", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
 
        BATiter bi = bat_iterator(b);
@@ -718,11 +717,11 @@ BATinfo(BAT **key, BAT **val, const bat 
                accessmode = "unknown";
        }
 
-       if (BUNappend(bk, "batId", false) != GDK_SUCCEED ||
-               BUNappend(bv, BATgetId(b), false) != GDK_SUCCEED ||
-               BUNappend(bk, "batCacheid", false) != GDK_SUCCEED ||
-               BUNappend(bv, local_itoa((ssize_t) b->batCacheid, buf),
-                                 false) != GDK_SUCCEED
+       if (BUNappend(bk, "batId", false) != GDK_SUCCEED
+               || BUNappend(bv, BATgetId(b), false) != GDK_SUCCEED
+               || BUNappend(bk, "batCacheid", false) != GDK_SUCCEED
+               || BUNappend(bv, local_itoa((ssize_t) b->batCacheid, buf),
+                                        false) != GDK_SUCCEED
                || BUNappend(bk, "tparentid", false) != GDK_SUCCEED
                || BUNappend(bv, local_itoa((ssize_t) bi.h->parentid, buf),
                                         false) != GDK_SUCCEED
@@ -803,7 +802,7 @@ BATinfo(BAT **key, BAT **val, const bat 
                BBPreclaim(bk);
                BBPreclaim(bv);
                BBPunfix(b->batCacheid);
-               throw(MAL, "bat.getInfo", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+               throw(MAL, "bat.info", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
        /* dump index information */
        MT_rwlock_rdlock(&b->thashlock);
@@ -813,25 +812,12 @@ BATinfo(BAT **key, BAT **val, const bat 
                BBPreclaim(bk);
                BBPreclaim(bv);
                BBPunfix(b->batCacheid);
-               throw(MAL, "bat.getInfo", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+               throw(MAL, "bat.info", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
        MT_rwlock_rdunlock(&b->thashlock);
        bat_iterator_end(&bi);
-       *key = bk;
-       *val = bv;
        assert(BATcount(bk) == BATcount(bv));
-       BBPunfix(bid);
-       return MAL_SUCCEED;
-}
-
-static str
-BKCinfo(bat *ret1, bat *ret2, const bat *bid)
-{
-       BAT *bv, *bk;
-       str msg;
-
-       if ((msg = BATinfo(&bk, &bv, *bid)) != NULL)
-               return msg;
+       BBPunfix(b->batCacheid);
        *ret1 = bk->batCacheid;
        BBPkeepref(bk);
        *ret2 = bv->batCacheid;
diff --git a/monetdb5/modules/kernel/batmmath.c 
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -95,9 +95,10 @@ CMDscienceUNARY(MalStkPtr stk, InstrPtr 
        BBPreclaim(s);
        if (e != 0 || ex != 0) {
                const char *err;
+               char buf[128];
                BBPunfix(bn->batCacheid);
                if (e)
-                       err = GDKstrerror(e, (char[128]) { 0 }, 128);
+                       err = GDKstrerror(e, buf, 128);
                else if (ex & FE_DIVBYZERO)
                        err = "Divide by zero";
                else if (ex & FE_OVERFLOW)
@@ -323,9 +324,10 @@ CMDscienceBINARY(MalStkPtr stk, InstrPtr
                throw(MAL, malfunc, GDK_EXCEPTION);
        if (e != 0 || ex != 0) {
                const char *err;
+               char buf[128];
                BBPunfix(bn->batCacheid);
                if (e)
-                       err = GDKstrerror(e, (char[128]) { 0 }, 128);
+                       err = GDKstrerror(e, buf, 128);
                else if (ex & FE_DIVBYZERO)
                        err = "Divide by zero";
                else if (ex & FE_OVERFLOW)
diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c
--- a/monetdb5/modules/kernel/mmath.c
+++ b/monetdb5/modules/kernel/mmath.c
@@ -96,8 +96,9 @@ MATHunary##NAME##TYPE(TYPE *res, const T
                        (ex = fetestexcept(FE_INVALID | FE_DIVBYZERO |          
        \
                                                           FE_OVERFLOW)) != 0) 
{                                \
                        const char *err;                                        
                                        \
+                       char buf[128];                                          
                                        \
                        if (e) {                                                
                                                \
-                               err = GDKstrerror(e, (char[128]){0}, 128);      
                \
+                               err = GDKstrerror(e, buf, 128);                 
                        \
                        } else if (ex & FE_DIVBYZERO)                           
                        \
                                err = "Divide by zero";                         
                                \
                        else if (ex & FE_OVERFLOW)                              
                                \
@@ -129,8 +130,9 @@ MATHbinary##NAME##TYPE(TYPE *res, const 
                        (ex = fetestexcept(FE_INVALID | FE_DIVBYZERO |          
        \
                                                           FE_OVERFLOW)) != 0) 
{                                \
                        const char *err;                                        
                                        \
+                       char buf[128];                                          
                                        \
                        if (e) {                                                
                                                \
-                               err = GDKstrerror(e, (char[128]){0}, 128);      
                \
+                               err = GDKstrerror(e, buf, 128);                 
                        \
                        } else if (ex & FE_DIVBYZERO)                           
                        \
                                err = "Divide by zero";                         
                                \
                        else if (ex & FE_OVERFLOW)                              
                                \
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -190,26 +190,28 @@ check_sys_tables(Client c, mvc *m, sql_s
                if (err)
                        return err;
                BAT *b;
-               if ((b = BATdescriptor(output->cols[0].b)) != NULL) {
-                       if (BATcount(b) > 0) {
-                               BATiter bi = bat_iterator(b);
-                               needsystabfix = * (int *) BUNtloc(bi, 0) != id;
-                               bat_iterator_end(&bi);
-                       }
-                       BBPunfix(b->batCacheid);
+               b = BATdescriptor(output->cols[0].b);
+               res_table_destroy(output);
+               if (b == NULL)
+                       throw(SQL, "sql.catalog", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+               if (BATcount(b) > 0) {
+                       BATiter bi = bat_iterator(b);
+                       needsystabfix = * (int *) BUNtloc(bi, 0) != id;
+                       bat_iterator_end(&bi);
                }
-               res_table_destroy(output);
+               BBPunfix(b->batCacheid);
                if (i == 0 && !needsystabfix) {
                        snprintf(buf, sizeof(buf),
                                         "select a.type from sys.functions f 
join sys.args a on f.id = a.func_id where f.name = 'quarter' and f.schema_id = 
2000 and a.inout = 0 and a.type = 'int';\n");
                        err = SQLstatementIntern(c, buf, "update", true, false, 
&output);
                        if (err)
                                return err;
-                       if ((b = BATdescriptor(output->cols[0].b)) != NULL) {
-                               needsystabfix = BATcount(b) > 0;
-                               BBPunfix(b->batCacheid);
-                       }
+                       b = BATdescriptor(output->cols[0].b);
                        res_table_destroy(output);
+                       if (b == NULL)
+                               throw(SQL, "sql.catalog", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+                       needsystabfix = BATcount(b) > 0;
+                       BBPunfix(b->batCacheid);
                }
                if (needsystabfix)
                        return sql_fix_system_tables(c, m);
@@ -1718,6 +1720,11 @@ sql_update_jun2020_bam(Client c, mvc *m)
                return err;
        }
        b = BATdescriptor(output->cols[0].b);
+       res_table_destroy(output);
+       if (b == NULL) {
+               GDKfree(buf);
+               throw(SQL, "sql.catalog", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+       }
        pos = 0;
        pos += snprintf(buf + pos, bufsize - pos,
                        "update sys.schemas set system = false where name = 
'bam';\n"
@@ -1733,20 +1740,17 @@ sql_update_jun2020_bam(Client c, mvc *m)
                        "drop function bam.seq_char cascade;\n"
                        "drop procedure bam.sam_export cascade;\n"
                        "drop procedure bam.bam_export cascade;\n");
-       if (b) {
-               if (BATcount(b) > 0 && *(lng *) Tloc(b, 0) == 0) {
-                       /* tables in bam schema are empty: drop them */
-                       pos += snprintf(buf + pos, bufsize - pos,
-                                       "drop table bam.sq cascade;\n"
-                                       "drop table bam.rg cascade;\n"
-                                       "drop table bam.pg cascade;\n"
-                                       "drop table bam.export cascade;\n"
-                                       "drop table bam.files cascade;\n"
-                                       "drop schema bam cascade;\n");
-               }
-               BBPunfix(b->batCacheid);
+       if (BATcount(b) > 0 && *(lng *) Tloc(b, 0) == 0) {
+               /* tables in bam schema are empty: drop them */
+               pos += snprintf(buf + pos, bufsize - pos,
+                                               "drop table bam.sq cascade;\n"
+                                               "drop table bam.rg cascade;\n"
+                                               "drop table bam.pg cascade;\n"
+                                               "drop table bam.export 
cascade;\n"
+                                               "drop table bam.files 
cascade;\n"
+                                               "drop schema bam cascade;\n");
        }
-       res_table_destroy(output);
+       BBPunfix(b->batCacheid);
 
        assert(pos < bufsize);
 
@@ -1958,6 +1962,8 @@ sql_update_oscar(Client c, mvc *sql)
                        err = SQLstatementIntern(c, buf, "update", true, false, 
NULL);
                }
                BBPunfix(b->batCacheid);
+       } else {
+               err = createException(SQL, "sql.catalog", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
        }
        res_table_destroy(output);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to