Changeset: 595862c688de for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/595862c688de
Modified Files:
        gdk/gdk_storage.c
        sql/backends/monet5/sql_upgrades.c
        sql/storage/bat/bat_storage.c
Branch: default
Log Message:

merged with jun2023


diffs (266 lines):

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
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);
        GDKfree(buf);
@@ -2095,6 +2101,8 @@ sql_update_oct2020(Client c, mvc *sql)
                                goto bailout;
                        err = sql_update_storagemodel(c, sql, true); /* because 
of day interval addition, we have to recreate the storagmodel views */
                }
+       } else {
+               err = createException(SQL, "sql.catalog", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
        }
 
 bailout:
@@ -3163,6 +3171,8 @@ sql_update_jul2021(Client c, mvc *sql)
                        fflush(stdout);
                        err = SQLstatementIntern(c, buf, "update", true, false, 
NULL);
                }
+       } else {
+               err = createException(SQL, "sql.catalog", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
        }
 
 bailout:
@@ -3244,6 +3254,8 @@ sql_update_jul2021_5(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);
        }
diff --git a/sql/include/exception_buffer.h b/sql/include/exception_buffer.h
--- a/sql/include/exception_buffer.h
+++ b/sql/include/exception_buffer.h
@@ -15,7 +15,11 @@
 #include <setjmp.h>
 
 typedef struct exception_buffer {
+#ifdef HAVE_SIGLONGJMP
+       sigjmp_buf state;
+#else
        jmp_buf state;
+#endif
        int code;
        char *msg;
        int enabled;
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1631,13 +1631,15 @@ cs_update_bat( sql_trans *tr, sql_delta 
 
                if (b == NULL) {
                        res = LOG_ERR;
-               } else if (BATcount(b)==0) {
-                       if (BATappend(b, updates, NULL, true) != GDK_SUCCEED) 
/* alter add column */
+               } else {
+                       if (BATcount(b)==0) {
+                               if (BATappend(b, updates, NULL, true) != 
GDK_SUCCEED) /* alter add column */
+                                       res = LOG_ERR;
+                       } else if (BATreplace(b, tids, updates, true) != 
GDK_SUCCEED)
                                res = LOG_ERR;
-               } else if (BATreplace(b, tids, updates, true) != GDK_SUCCEED)
-                       res = LOG_ERR;
-               BBPcold(b->batCacheid);
-               bat_destroy(b);
+                       BBPcold(b->batCacheid);
+                       bat_destroy(b);
+               }
        }
        unlock_table(tr->store, t->base.id);
        if (otids != tids)
diff --git a/tools/merovingian/daemon/merovingian.c 
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -257,7 +257,8 @@ logListener(void *x)
                        if (w->pid > 0)
                                nfds += 2;
                }
-               pfd = malloc(nfds * sizeof(struct pollfd));
+               /* +1 for freebsd compiler issue with stringop-overflow error */
+               pfd = malloc((nfds+1) * sizeof(struct pollfd));
                nfds = 0;
                for (w = d; w != NULL; w = w->next) {
                        if (w->pid <= 0)
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to