Changeset: b0c4b14cd2c6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b0c4b14cd2c6
Modified Files:
monetdb5/modules/kernel/aggr.c
monetdb5/modules/kernel/algebra.c
monetdb5/modules/mal/remote.c
sql/backends/monet5/sql_rank.c
sql/backends/monet5/sql_subquery.c
Branch: Jul2021
Log Message:
Revert changes of BATdescriptor to BBPquickdesc.
The GDK level functions should not be called with incomplete BAT
pointers, even if they currently don't use the data.
diffs (truncated from 574 to 300 lines):
diff --git a/monetdb5/modules/kernel/aggr.c b/monetdb5/modules/kernel/aggr.c
--- a/monetdb5/modules/kernel/aggr.c
+++ b/monetdb5/modules/kernel/aggr.c
@@ -35,7 +35,7 @@ AGGRgrouped(bat *retval1, bat *retval2,
b = BATdescriptor(*bid);
g = gid ? BATdescriptor(*gid) : NULL;
- e = eid ? BBPquickdesc(*eid) : NULL;
+ e = eid ? BATdescriptor(*eid) : NULL;
s = sid ? BATdescriptor(*sid) : NULL;
q = quantile ? BATdescriptor(*quantile) : NULL;
@@ -48,6 +48,8 @@ AGGRgrouped(bat *retval1, bat *retval2,
BBPunfix(b->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (q)
@@ -76,6 +78,8 @@ AGGRgrouped(bat *retval1, bat *retval2,
BBPunfix(b->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
BBPunfix(q->batCacheid);
@@ -93,6 +97,8 @@ AGGRgrouped(bat *retval1, bat *retval2,
BBPunfix(b->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (bn == NULL)
@@ -620,7 +626,7 @@ AGGRavg3(bat *retval1, bat *retval2, bat
b = BATdescriptor(*bid);
g = gid != NULL && !is_bat_nil(*gid) ? BATdescriptor(*gid) : NULL;
- e = eid != NULL && !is_bat_nil(*eid) ? BBPquickdesc(*eid) : NULL;
+ e = eid != NULL && !is_bat_nil(*eid) ? BATdescriptor(*eid) : NULL;
s = sid != NULL && !is_bat_nil(*sid) ? BATdescriptor(*sid) : NULL;
if (b == NULL ||
@@ -631,6 +637,8 @@ AGGRavg3(bat *retval1, bat *retval2, bat
BBPunfix(b->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
throw(MAL, "aggr.subavg", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
@@ -641,6 +649,8 @@ AGGRavg3(bat *retval1, bat *retval2, bat
BBPunfix(b->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (rc != GDK_SUCCEED)
@@ -663,7 +673,7 @@ AGGRavg3comb(bat *retval1, const bat *bi
r = BATdescriptor(*rid);
c = BATdescriptor(*cid);
g = gid != NULL && !is_bat_nil(*gid) ? BATdescriptor(*gid) : NULL;
- e = eid != NULL && !is_bat_nil(*eid) ? BBPquickdesc(*eid) : NULL;
+ e = eid != NULL && !is_bat_nil(*eid) ? BATdescriptor(*eid) : NULL;
if (b == NULL ||
r == NULL ||
@@ -678,6 +688,8 @@ AGGRavg3comb(bat *retval1, const bat *bi
BBPunfix(c->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
throw(MAL, "aggr.subavg", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
}
@@ -688,6 +700,8 @@ AGGRavg3comb(bat *retval1, const bat *bi
BBPunfix(c->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (bn == NULL)
throw(MAL, "aggr.subavg", GDK_EXCEPTION);
*retval1 = bn->batCacheid;
@@ -987,7 +1001,7 @@ AGGRgroup_str_concat(bat *retval1, const
b = BATdescriptor(*bid);
g = gid ? BATdescriptor(*gid) : NULL;
- e = eid ? BBPquickdesc(*eid) : NULL;
+ e = eid ? BATdescriptor(*eid) : NULL;
s = sid ? BATdescriptor(*sid) : NULL;
sep = sepid ? BATdescriptor(*sepid) : NULL;
@@ -997,6 +1011,8 @@ AGGRgroup_str_concat(bat *retval1, const
BBPunfix(b->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (sep)
@@ -1009,6 +1025,8 @@ AGGRgroup_str_concat(bat *retval1, const
BBPunfix(b->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (sep)
@@ -1070,7 +1088,7 @@ AGGRgrouped2(bat *retval, const bat *bid
b1 = BATdescriptor(*bid1);
b2 = BATdescriptor(*bid2);
g = gid ? BATdescriptor(*gid) : NULL;
- e = eid ? BBPquickdesc(*eid) : NULL;
+ e = eid ? BATdescriptor(*eid) : NULL;
s = sid ? BATdescriptor(*sid) : NULL;
if (b1 == NULL || b2 == NULL || (gid != NULL && g == NULL) || (eid !=
NULL && e == NULL) ||
@@ -1081,6 +1099,8 @@ AGGRgrouped2(bat *retval, const bat *bid
BBPunfix(b2->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
@@ -1091,6 +1111,8 @@ AGGRgrouped2(bat *retval, const bat *bid
BBPunfix(b2->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
throw(MAL, malfunc, SQLSTATE(42000) "%s requires both arguments
of the same type", malfunc);
@@ -1102,6 +1124,8 @@ AGGRgrouped2(bat *retval, const bat *bid
BBPunfix(b2->batCacheid);
if (g)
BBPunfix(g->batCacheid);
+ if (e)
+ BBPunfix(e->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (bn == NULL)
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
@@ -793,19 +793,28 @@ ALGcrossproduct(bat *l, bat *r, const ba
BAT *sl = NULL, *sr = NULL;
gdk_return ret;
- if ((L = BBPquickdesc(*left)) == NULL)
- throw(MAL, "algebra.crossproduct", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- if ((R = BBPquickdesc(*right)) == NULL)
+ if ((L = BATdescriptor(*left)) == NULL ||
+ (R = BATdescriptor(*right)) == NULL) {
+ if (L)
+ BBPunfix(L->batCacheid);
+ if (R)
+ BBPunfix(R->batCacheid);
throw(MAL, "algebra.crossproduct", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- 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) {
+ }
+ if ((slid && !is_bat_nil(*slid) && (sl = BATdescriptor(*slid)) == NULL)
||
+ (srid && !is_bat_nil(*srid) && (sr = BATdescriptor(*srid)) ==
NULL)) {
+ BBPunfix(L->batCacheid);
+ BBPunfix(R->batCacheid);
if (sl)
BBPunfix(sl->batCacheid);
+ if (sr)
+ BBPunfix(sr->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)
@@ -971,46 +980,28 @@ ALGsort11(bat *result, const bat *bid, c
static str
ALGcountCND_nil(lng *result, const bat *bid, const bat *cnd, const bit
*ignore_nils)
{
- str msg = MAL_SUCCEED;
- BAT *b = NULL, *s = NULL;
- bool heap_loaded = false;
+ BAT *b, *s = NULL;
- if (!(b = BBPquickdesc(*bid))) {
- msg = createException(MAL, "aggr.count", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- goto bailout;
+ if ((b = BATdescriptor(*bid)) == NULL) {
+ throw(MAL, "aggr.count", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
}
- if (cnd && !is_bat_nil(*cnd) && !(s = BATdescriptor(*cnd))) {
- msg = createException(MAL, "aggr.count", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- goto bailout;
- }
- if (b->ttype == TYPE_void || b->ttype == TYPE_msk || (*ignore_nils &&
!b->tnonil)) {
- if (!(b = BATdescriptor(*bid))) { /* has to load the heap */
- msg = createException(MAL, "aggr.count",
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
- goto bailout;
- }
- heap_loaded = true;
+ if (cnd && !is_bat_nil(*cnd) && (s = BATdescriptor(*cnd)) == NULL) {
+ BBPunfix(b->batCacheid);
+ throw(MAL, "aggr.count", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
}
-
if (b->ttype == TYPE_msk || mask_cand(b)) {
- assert(heap_loaded);
- if (BATsum(result, TYPE_lng, b, s, *ignore_nils, false, false)
!= GDK_SUCCEED) {
- msg = createException(MAL, "aggr.count", GDK_EXCEPTION);
- goto bailout;
- }
- } else if (*ignore_nils && !b->tnonil) {
- assert(heap_loaded);
- *result = (lng) BATcount_no_nil(b, s);
- } else {
- struct canditer ci;
- *result = (lng) canditer_init(&ci, b, s);
- }
-
-bailout:
- if (b && heap_loaded)
- BBPunfix(b->batCacheid);
+ BATsum(result, TYPE_lng, b, s, *ignore_nils, false, false);
+ } else
+ if (*ignore_nils) {
+ *result = (lng) BATcount_no_nil(b, s);
+ } else {
+ struct canditer ci;
+ *result = (lng) canditer_init(&ci, b, s);
+ }
if (s)
BBPunfix(s->batCacheid);
- return msg;
+ BBPunfix(b->batCacheid);
+ return MAL_SUCCEED;
}
static str
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -1517,8 +1517,12 @@ static str RMTbincopyto(Client cntxt, Ma
throw(MAL, "remote.bincopyto", MAL_MALLOC_FAIL);
sendtheap = b->ttype != TYPE_void && b->tvarsized;
- if (isVIEW(b) && sendtheap && VIEWvtparent(b) && BATcount(b) <
BATcount(BBP_cache(VIEWvtparent(b))))
+ if (isVIEW(b) && sendtheap && VIEWvtparent(b) && BATcount(b) <
BATcount(BBP_cache(VIEWvtparent(b)))) {
+ if ((b = BATdescriptor(bid)) == NULL)
+ throw(MAL, "remote.bincopyto", RUNTIME_OBJECT_MISSING);
v = COLcopy(b, b->ttype, true, TRANSIENT);
+ BBPunfix(b->batCacheid);
+ }
mnstr_printf(cntxt->fdout, /*JSON*/"{"
"\"version\":1,"
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -1274,7 +1274,7 @@ SQLcount(Client cntxt, MalBlkPtr mb, Mal
{
BAT *r = NULL, *b = NULL, *p = NULL, *o = NULL, *s = NULL, *e = NULL;
int tpe, frame_type;
- bit ignore_nils, heap_loaded = false;
+ bit ignore_nils;
bat *res = NULL;
str msg = MAL_SUCCEED;
@@ -1288,18 +1288,9 @@ SQLcount(Client cntxt, MalBlkPtr mb, Mal
if (isaBatType(tpe))
tpe = getBatType(tpe);
- if (isaBatType(getArgType(mb, pci, 1))) {
- if (!(b = BBPquickdesc(*getArgReference_bat(stk, pci, 1)))) {
- msg = createException(SQL, "sql.count", SQLSTATE(HY005)
"Cannot access column descriptor");
- goto bailout;
- }
- if (ignore_nils && !b->tnonil) {
- if (!(b = BATdescriptor(*getArgReference_bat(stk, pci,
1)))) {
- msg = createException(SQL, "sql.count",
SQLSTATE(HY005) "Cannot access column descriptor");
- goto bailout;
- }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list