Changeset: a31d8ff703fc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a31d8ff703fc
Modified Files:
        sql/backends/monet5/sql.c
        testing/sqllogictest.py
Branch: default
Log Message:

Merged with Jul2021


diffs (truncated from 13609 to 300 lines):

diff --git a/common/utils/mstring.h b/common/utils/mstring.h
--- a/common/utils/mstring.h
+++ b/common/utils/mstring.h
@@ -29,7 +29,10 @@ strcpy_len(char *restrict dst, const cha
                        if ((dst[i] = src[i]) == 0)
                                return i;
                }
-               dst[n - 1] = 0;
+               /* for correctness, the decrement isn't needed (just assigning 0
+                * to dst[n-1] would be sufficient), but to work around a too
+                * strict GNU C compiler, we do need it */
+               dst[--n] = 0;
 /* in some versions of GCC (at least gcc (Ubuntu 7.5.0-3ubuntu1~18.04)
  * 7.5.0), the error just can't be turned off when using
  * --enable-strict, so we just use the (more) expensive way of getting the
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2183,7 +2183,6 @@ logger_flush(logger *lg, ulng ts)
                }
                logger_unlock(lg);
        }
-       assert(res==LOG_OK);
        if (lid && res == LOG_OK)
                logger_cleanup_range(lg);
        return res == LOG_ERR ? GDK_FAIL : GDK_SUCCEED;
diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c
--- a/monetdb5/modules/atoms/batxml.c
+++ b/monetdb5/modules/atoms/batxml.c
@@ -1250,7 +1250,7 @@ BATxmlaggr(BAT **bnp, BAT *b, BAT *g, BA
                if (BATsort(&t1, &t2, NULL, g, NULL, NULL, false, false, true) 
!= GDK_SUCCEED) {
                        BBPreclaim(bn);
                        bn = NULL;
-                       err = "internal sort failed";
+                       err = GDK_EXCEPTION;
                        goto out;
                }
                if (freeg)
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -2431,7 +2431,7 @@ JSONjsonaggr(BAT **bnp, BAT *b, BAT *g, 
        if (g) {
                /* stable sort g */
                if (BATsort(&t1, &t2, NULL, g, NULL, NULL, false, false, true) 
!= GDK_SUCCEED) {
-                       err = "internal sort failed";
+                       err = GDK_EXCEPTION;
                        goto out;
                }
                if (freeg)
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
@@ -907,7 +907,7 @@ ALGsort33(bat *result, bat *norder, bat 
                if (g)
                        BBPunfix(g->batCacheid);
                BBPunfix(b->batCacheid);
-               throw(MAL, "algebra.sort", OPERATION_FAILED);
+               throw(MAL, "algebra.sort", GDK_EXCEPTION);
        }
        BBPunfix(b->batCacheid);
        if (o)
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
@@ -120,16 +120,11 @@ BKCmirror(bat *ret, const bat *bid)
        BAT *b, *bn;
 
        *ret = 0;
-       if ((b = BATdescriptor(*bid)) == NULL) {
+       if (!(b = BBPquickdesc(*bid, false)))
                throw(MAL, "bat.mirror", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       bn = BATdense(b->hseqbase, b->hseqbase, BATcount(b));
-       BBPunfix(b->batCacheid);
-       if (bn == NULL) {
+       if (!(bn = BATdense(b->hseqbase, b->hseqbase, BATcount(b))))
                throw(MAL, "bat.mirror", GDK_EXCEPTION);
-       }
-       *ret = bn->batCacheid;
-       BBPkeepref(*ret);
+       BBPkeepref(*ret = bn->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -838,7 +833,7 @@ BKCshrinkBAT(bat *ret, const bat *bid, c
        if (res != GDK_SUCCEED) {
                BBPunfix(b->batCacheid);
                BBPunfix(bn->batCacheid);
-               throw(MAL, "bat.shrink", SQLSTATE(HY013) MAL_MALLOC_FAIL );
+               throw(MAL, "bat.shrink", GDK_EXCEPTION);
        }
 
        o = (oid*)Tloc(bs, 0);
@@ -869,7 +864,7 @@ BKCshrinkBAT(bat *ret, const bat *bid, c
                                        if (BUNappend(bn, BUNtail(bi, p), 
false) != GDK_SUCCEED) {
                                                BBPunfix(b->batCacheid);
                                                BBPunfix(bn->batCacheid);
-                                               throw(MAL, "bat.shrink", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+                                               throw(MAL, "bat.shrink", 
GDK_EXCEPTION);
                                        }
                                        cnt++;
                                }
@@ -933,7 +928,7 @@ BKCshrinkBATmap(bat *ret, const bat *bid
        if (res != GDK_SUCCEED) {
                BBPunfix(b->batCacheid);
                BBPunfix(bn->batCacheid);
-               throw(MAL, "bat.shrinkMap", SQLSTATE(HY013) MAL_MALLOC_FAIL );
+               throw(MAL, "bat.shrinkMap", GDK_EXCEPTION);
        }
 
        o = (oid*)Tloc(bs, 0);
@@ -1006,7 +1001,7 @@ BKCreuseBAT(bat *ret, const bat *bid, co
        if (res != GDK_SUCCEED) {
                BBPunfix(b->batCacheid);
                BBPunfix(bn->batCacheid);
-               throw(MAL, "bat.reuse", SQLSTATE(HY013) MAL_MALLOC_FAIL );
+               throw(MAL, "bat.reuse", GDK_EXCEPTION);
        }
 
        const oid *o = (const oid *) Tloc(bs, 0);
@@ -1103,7 +1098,7 @@ BKCreuseBATmap(bat *ret, const bat *bid,
        if (res != GDK_SUCCEED) {
                BBPunfix(b->batCacheid);
                BBPunfix(bn->batCacheid);
-               throw(MAL, "bat.shrinkMap", SQLSTATE(HY013) MAL_MALLOC_FAIL );
+               throw(MAL, "bat.shrinkMap", GDK_EXCEPTION);
        }
 
        const oid *o = (const oid *) Tloc(bs, 0);
@@ -1152,7 +1147,7 @@ BKCmergecand(bat *ret, const bat *aid, c
        BBPunfix(a->batCacheid);
        BBPunfix(b->batCacheid);
        if (bn == NULL)
-               throw(MAL, "bat.mergecand", OPERATION_FAILED);
+               throw(MAL, "bat.mergecand", GDK_EXCEPTION);
        *ret = bn->batCacheid;
        BBPkeepref(*ret);
        return MAL_SUCCEED;
@@ -1174,7 +1169,7 @@ BKCintersectcand(bat *ret, const bat *ai
        BBPunfix(a->batCacheid);
        BBPunfix(b->batCacheid);
        if (bn == NULL)
-               throw(MAL, "bat.intersectcand", OPERATION_FAILED);
+               throw(MAL, "bat.intersectcand", GDK_EXCEPTION);
        *ret = bn->batCacheid;
        BBPkeepref(*ret);
        return MAL_SUCCEED;
@@ -1196,7 +1191,7 @@ BKCdiffcand(bat *ret, const bat *aid, co
        BBPunfix(a->batCacheid);
        BBPunfix(b->batCacheid);
        if (bn == NULL)
-               throw(MAL, "bat.diffcand", OPERATION_FAILED);
+               throw(MAL, "bat.diffcand", GDK_EXCEPTION);
        *ret = bn->batCacheid;
        BBPkeepref(*ret);
        return MAL_SUCCEED;
diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -401,7 +401,7 @@ mat_assign(MalBlkPtr mb, InstrPtr p, mat
        return r;
 }
 
-static InstrPtr
+static int
 mat_apply1(MalBlkPtr mb, InstrPtr p, matlist_t *ml, int m, int var)
 {
        int tpe, k, is_select = isSelect(p), is_mirror = (getFunctionId(p) == 
mirrorRef);
@@ -421,14 +421,14 @@ mat_apply1(MalBlkPtr mb, InstrPtr p, mat
        }
 
        if((r = newInstructionArgs(mb, matRef, packRef, mat[m].mi->argc)) == 
NULL)
-               return NULL;
+               return -1;
        getArg(r, 0) = getArg(p,0);
        tpe = getArgType(mb,p,0);
 
        if (is_identity) {
                if((q = newInstruction(mb,  NULL,NULL)) == NULL) {
                        freeInstruction(r);
-                       return NULL;
+                       return -1;
                }
                getArg(q, 0) = newTmpVariable(mb, TYPE_oid);
                q->retc = 1;
@@ -441,7 +441,7 @@ mat_apply1(MalBlkPtr mb, InstrPtr p, mat
                int res = 0;
                if((q = copyInstruction(p)) == NULL) {
                        freeInstruction(r);
-                       return NULL;
+                       return -1;
                }
 
                if (is_assign)
@@ -471,11 +471,14 @@ mat_apply1(MalBlkPtr mb, InstrPtr p, mat
                        res = setPartnr(ml, -1, getArg(q,0), k);
                if(res) {
                        freeInstruction(r);
-                       return NULL;
+                       return -1;
                }
                r = addArgument(mb, r, getArg(q, 0));
        }
-       return r;
+       if(!r || mat_add(ml, r, mat_type(ml->v, m), getFunctionId(p))) {
+               return -1;
+       }
+       return 0;
 }
 
 static int
@@ -483,6 +486,8 @@ mat_apply(MalBlkPtr mb, InstrPtr p, matl
 {
        int matvar[8], fargument[8], k, l, parts = 0;
 
+       if (nrmats == 1 && (getFunctionId(p) == identityRef && getModuleId(p) 
== batcalcRef))
+               return mat_apply1(mb, p, ml, is_a_mat(getArg(p,1),ml), 1);
        assert(nrmats <= 8);
 
        for(k=p->retc, l=0; k < p->argc; k++) {
@@ -2345,12 +2350,7 @@ OPTmergetableImplementation(Client cntxt
                   (m=is_a_mat(getArg(p,fm), &ml)) >= 0 && bats == 2 &&
                        isaBatType(getArgType(mb,p,2)) && 
isVarConstant(mb,getArg(p,2)) &&
                        is_bat_nil(getVarConstant(mb,getArg(p,2)).val.bval)) {
-                       if ((r = mat_apply1(mb, p, &ml, m, fm)) != NULL) {
-                               if(mat_add(&ml, r, mat_type(ml.v, m), 
getFunctionId(p))) {
-                                       msg = 
createException(MAL,"optimizer.mergetable",SQLSTATE(HY013) MAL_MALLOC_FAIL);
-                                       goto cleanup;
-                               }
-                       } else {
+                       if (mat_apply1(mb, p, &ml, m, fm)) {
                                msg = 
createException(MAL,"optimizer.mergetable",SQLSTATE(HY013) MAL_MALLOC_FAIL);
                                goto cleanup;
                        }
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -1234,7 +1234,9 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                stmt *l;
 
                if (from->type->localtype == 0) {
-                       l = stmt_atom(be, atom_general(sql->sa, to, NULL));
+                       l = exp_bin(be, e->l, left, right, grp, ext, cnt, sel, 
depth+1, 0, push);
+                       if (l)
+                               l = stmt_atom(be, atom_general(sql->sa, to, 
NULL));
                } else {
                        l = exp_bin(be, e->l, left, right, grp, ext, cnt, sel, 
depth+1, 0, push);
                }
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2127,13 +2127,13 @@ DELTAsub(bat *result, const bat *col, co
                        cminu = NULL;
                        if (ret != GDK_SUCCEED) {
                                BBPunfix(res->batCacheid);
-                               throw(MAL, "sql.delta", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+                               throw(MAL, "sql.delta", GDK_EXCEPTION);
                        }
 
                        ret = BATsort(&u, NULL, NULL, res, NULL, NULL, false, 
false, false);
                        BBPunfix(res->batCacheid);
                        if (ret != GDK_SUCCEED) {
-                               throw(MAL, "sql.delta", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+                               throw(MAL, "sql.delta", GDK_EXCEPTION);
                        }
                        res = u;
                } else {
@@ -3141,19 +3141,13 @@ PBATSQLidentity(Client cntxt, MalBlkPtr 
 
        (void) cntxt;
        (void) mb;
-       if ((b = BATdescriptor(bid)) == NULL) {
+       if (!(b = BBPquickdesc(bid, false)))
                throw(MAL, "batcalc.identity", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       bn = BATdense(b->hseqbase, s, BATcount(b));
-       if (bn != NULL) {
-               *ns = s + BATcount(b);
-               BBPunfix(b->batCacheid);
-               BBPkeepref(*res = bn->batCacheid);
-               return MAL_SUCCEED;
-       }
-       BBPunfix(b->batCacheid);
-       throw(MAL, "batcalc.identity", SQLSTATE(45001) "Internal error");
-
+       if (!(bn = BATdense(b->hseqbase, s, BATcount(b))))
+               throw(MAL, "batcalc.identity", GDK_EXCEPTION);
+       *ns = s + BATcount(b);
+       BBPkeepref(*res = bn->batCacheid);
+       return MAL_SUCCEED;
 }
 
 /*
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -1688,18 +1688,17 @@ int
 mvc_export_affrows(backend *b, stream *s, lng val, str w, oid query_id, lng 
starttime, lng maloptimizer)
 {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to