[prev in list] [next in list] [prev in thread] [next in thread]
List: monetdb-checkins
Subject: MonetDB: scatter - merged
From: Niels_Nes <commits+niels=cwi.nl () monetdb ! org>
Date: 2021-05-29 7:24:38
Message-ID: hg.4a66e48abf74.1622273078.-977076010722048704 () monetdb-vm0 ! spin-off ! cwi ! nl
[Download RAW message or body]
Changeset: 4a66e48abf74 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4a66e48abf74
Modified Files:
sql/backends/monet5/sql.c
sql/server/rel_optimizer.c
Branch: scatter
Log Message:
merged
diffs (truncated from 1197 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/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -383,6 +383,8 @@ join_threads(void)
bool waited;
struct winthread *self = TlsGetValue(threadslot);
+ if (!self)
+ return;
EnterCriticalSection(&winthread_cs);
do {
waited = false;
diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -280,7 +280,14 @@ gdk_return
GDKtracer_stop(void)
{
set_level_for_layer(MDB_ALL, DEFAULT_LOG_LEVEL);
- return GDKtracer_flush_buffer();
+ if (active_tracer) {
+ if (active_tracer != stderr)
+ fclose(active_tracer);
+ else
+ fflush(active_tracer);
+ active_tracer = NULL;
+ }
+ return GDK_SUCCEED;
}
gdk_return
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
@@ -786,29 +786,19 @@ ALGcrossproduct(bat *l, bat *r, const ba
BAT *sl = NULL, *sr = NULL;
gdk_return ret;
- if ((L = BATdescriptor(*left)) == NULL) {
+ if ((L = BBPquickdesc(*left, false)) == NULL)
throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
- }
- if ((R = BATdescriptor(*right)) == NULL) {
- BBPunfix(L->batCacheid);
+ if ((R = BBPquickdesc(*right, false)) == NULL)
throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
- }
- if (slid && !is_bat_nil(*slid) && (sl = BATdescriptor(*slid)) == NULL) {
- BBPunfix(L->batCacheid);
- BBPunfix(R->batCacheid);
+ if (slid && !is_bat_nil(*slid) && (sl = BATdescriptor(*slid)) == NULL)
throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
- }
if (srid && !is_bat_nil(*srid) && (sr = BATdescriptor(*srid)) == NULL) {
- BBPunfix(L->batCacheid);
- BBPunfix(R->batCacheid);
if (sl)
BBPunfix(sl->batCacheid);
throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
}
ret = BATsubcross(&bn1, r ? &bn2 : NULL, L, R, sl, sr,
max_one && !is_bit_nil(*max_one) && *max_one);
- BBPunfix(L->batCacheid);
- BBPunfix(R->batCacheid);
if (sl)
BBPunfix(sl->batCacheid);
if (sr)
@@ -907,7 +897,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)
@@ -1248,16 +1238,14 @@ ALGprojecttail(Client cntxt, MalBlkPtr m
(void) mb;
if( isaBatType(getArgType(mb,pci,2)) )
throw(MAL,"algebra.project","Scalar value expected");
- if ((b = BATdescriptor(bid)) == NULL)
+ if ((b = BBPquickdesc(bid, false)) == NULL)
throw(MAL, "algebra.project", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
bn = BATconstant(b->hseqbase, v->vtype, VALptr(v), BATcount(b), TRANSIENT);
- BBPunfix(b->batCacheid);
if (bn == NULL) {
*ret = bat_nil;
throw(MAL, "algebra.project", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
- *ret= bn->batCacheid;
- BBPkeepref(bn->batCacheid);
+ BBPkeepref(*ret= bn->batCacheid);
return MAL_SUCCEED;
}
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
@@ -833,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);
@@ -864,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++;
}
@@ -928,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);
@@ -1001,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);
@@ -1098,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);
@@ -1147,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;
@@ -1169,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;
@@ -1191,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,9 @@ mat_apply(MalBlkPtr mb, InstrPtr p, matl
{
int matvar[8], fargument[8], k, l, parts = 0;
+ if (nrmats == 1 &&
+ ((getModuleId(p) == batcalcRef && getFunctionId(p) == identityRef) || \
(getModuleId(p) == batRef && getFunctionId(p) == mirrorRef))) + 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 +2351,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/sql.c b/sql/backends/monet5/sql.c
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic