Changeset: 4dc8f3e4375b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4dc8f3e4375b
Modified Files:
gdk/gdk_aggr.c
gdk/gdk_analytic_bounds.c
gdk/gdk_cand.c
gdk/gdk_imprints.c
monetdb5/modules/atoms/batxml.c
monetdb5/modules/atoms/blob.c
monetdb5/modules/atoms/json.c
monetdb5/modules/atoms/uuid.c
monetdb5/modules/kernel/batstr.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_rank.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_subquery.c
sql/common/sql_hash.c
Branch: Jun2023
Log Message:
BAT iterator fixes and cleanup.
diffs (truncated from 607 to 300 lines):
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3678,7 +3678,6 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
}
MT_lock_unset(&b->theaplock);
}
- bat_iterator_end(&bi);
} else {
r = 0;
}
diff --git a/gdk/gdk_analytic_bounds.c b/gdk/gdk_analytic_bounds.c
--- a/gdk/gdk_analytic_bounds.c
+++ b/gdk/gdk_analytic_bounds.c
@@ -956,6 +956,7 @@ GDKanalyticalrowbounds(BAT *r, BAT *b, B
if (limit == GDK_lng_max) {
bat_iterator_end(&pi);
bat_iterator_end(&bi);
+ bat_iterator_end(&li);
return GDKanalyticalallbounds(r, b, p, preceding);
} else if (is_lng_nil(limit) || limit < 0) { /* this check is
needed if the input is empty */
goto invalid_bound;
diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c
--- a/gdk/gdk_cand.c
+++ b/gdk/gdk_cand.c
@@ -1487,6 +1487,7 @@ BATunmask(BAT *b)
Heap *dels;
if ((dels = GDKmalloc(sizeof(Heap))) == NULL) {
BBPreclaim(bn);
+ bat_iterator_end(&bi);
return NULL;
}
*dels = (Heap) {
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -306,8 +306,10 @@ BATcheckimprints(BAT *b)
if (VIEWtparent(b)) {
assert(b->timprints == NULL);
b = BATdescriptor(VIEWtparent(b));
- if (b == NULL)
+ if (b == NULL) {
+ bat_iterator_end(&bi);
return false;
+ }
}
if (b->timprints == (Imprints *) 1) {
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
@@ -969,26 +969,23 @@ BATXMLforest(Client cntxt, MalBlkPtr mb,
/* collect the admin for the xml elements */
for (i = pci->retc; i < pci->argc; i++) {
BAT *b = BATdescriptor(*getArgReference_bat(stk, pci, i));
- if (b == NULL)
- break;
+ if (b == NULL) {
+ while (i > pci->retc) {
+ i--;
+ b = bi[i].b;
+ bat_iterator_end(&bi[i]);
+ BBPunfix(b->batCacheid);
+ }
+ GDKfree(bi);
+ GDKfree(p);
+ GDKfree(q);
+ GDKfree(buf);
+ throw(MAL, "xml.forest", INTERNAL_BAT_ACCESS);
+ }
bi[i] = bat_iterator(b);
p[i] = 0;
q[i] = BATcount(bi[i].b);
}
- /* check for errors */
- if (i != pci->argc) {
- for (i--; i >= pci->retc; i--)
- if (bi[i].b) {
- BAT *b = bi[i].b;
- bat_iterator_end(&bi[i]);
- BBPunfix(b->batCacheid);
- }
- GDKfree(bi);
- GDKfree(p);
- GDKfree(q);
- GDKfree(buf);
- throw(MAL, "xml.forest", INTERNAL_BAT_ACCESS);
- }
prepareResult(bn, bi[pci->retc].b, TYPE_xml, "forest",
for (i = pci->retc; i < pci->argc; i++) {BAT
*b = bi[i].b; bat_iterator_end(&bi[i]); BBPunfix(b->batCacheid);}
diff --git a/monetdb5/modules/atoms/blob.c b/monetdb5/modules/atoms/blob.c
--- a/monetdb5/modules/atoms/blob.c
+++ b/monetdb5/modules/atoms/blob.c
@@ -190,8 +190,7 @@ BLOBblob_blob_bulk(bat *res, const bat *
if (tfastins_nocheckVAR(dst, i, v) != GDK_SUCCEED) {
msg = createException(SQL,
"batcalc.blob_blob_bulk", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
nils |= is_blob_nil(v);
}
@@ -202,12 +201,12 @@ BLOBblob_blob_bulk(bat *res, const bat *
if (tfastins_nocheckVAR(dst, i, v) != GDK_SUCCEED) {
msg = createException(SQL,
"batcalc.blob_blob_bulk", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
nils |= is_blob_nil(v);
}
}
+ bailout1:
bat_iterator_end(&bi);
bailout:
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
@@ -2045,12 +2045,12 @@ JSONrenderRowObject(BAT **bl, MalBlkPtr
tpe = getBatType(getArgType(mb, pci, i + 1));
bi = bat_iterator(bl[i + 1]);
p = BUNtail(bi, idx);
- if ((val = ATOMformat(tpe, p)) == NULL) {
- bat_iterator_end(&bi);
+ val = ATOMformat(tpe, p);
+ bat_iterator_end(&bi);
+ if (val == NULL) {
GDKfree(row);
return NULL;
}
- bat_iterator_end(&bi);
if (strncmp(val, "nil", 3) == 0) {
GDKfree(val);
val = NULL;
@@ -2162,11 +2162,10 @@ JSONrenderRowArray(BAT **bl, MalBlkPtr m
tpe = getBatType(getArgType(mb, pci, i));
bi = bat_iterator(bl[i]);
p = BUNtail(bi, idx);
- if ((val = ATOMformat(tpe, p)) == NULL) {
- bat_iterator_end(&bi);
+ val = ATOMformat(tpe, p);
+ bat_iterator_end(&bi);
+ if (val == NULL)
goto memfail;
- }
- bat_iterator_end(&bi);
if (strcmp(val, "nil") == 0) {
GDKfree(val);
val = NULL;
diff --git a/monetdb5/modules/atoms/uuid.c b/monetdb5/modules/atoms/uuid.c
--- a/monetdb5/modules/atoms/uuid.c
+++ b/monetdb5/modules/atoms/uuid.c
@@ -322,8 +322,7 @@ UUIDstr2uuid_bulk(bat *res, const bat *b
if (conv(v, &l, (void **) pp, false) <= 0) {
msg = createException(SQL,
"batcalc.str2uuidbulk", SQLSTATE(42000) "Not a UUID");
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
nils |= strNil(v);
}
@@ -335,13 +334,13 @@ UUIDstr2uuid_bulk(bat *res, const bat *b
if (conv(v, &l, (void **) pp, false) <= 0) {
msg = createException(SQL,
"batcalc.str2uuidbulk", SQLSTATE(42000) "Not a UUID");
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
nils |= strNil(v);
}
}
btkey = bi.key;
+ bailout1:
bat_iterator_end(&bi);
bailout:
@@ -409,13 +408,11 @@ UUIDuuid2str_bulk(bat *res, const bat *b
if (conv(&pbuf, &l, &v, false) < 0) { /* it should
never be reallocated */
msg = createException(MAL,
"batcalc.uuid2strbulk", GDK_EXCEPTION);
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
if (tfastins_nocheckVAR(dst, i, buf) != GDK_SUCCEED) {
msg = createException(SQL,
"batcalc.uuid2strbulk", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
nils |= strNil(buf);
}
@@ -426,18 +423,17 @@ UUIDuuid2str_bulk(bat *res, const bat *b
if (conv(&pbuf, &l, &v, false) < 0) { /* it should
never be reallocated */
msg = createException(MAL,
"batcalc.uuid2strbulk", GDK_EXCEPTION);
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
if (tfastins_nocheckVAR(dst, i, buf) != GDK_SUCCEED) {
msg = createException(SQL,
"batcalc.uuid2strbulk", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
nils |= strNil(buf);
}
}
btkey = bi.key;
+ bailout1:
bat_iterator_end(&bi);
bailout:
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -251,20 +251,17 @@ STRbatFromWChr(Client cntxt, MalBlkPtr m
if (is_int_nil(x)) {
if (tfastins_nocheckVAR(bn, i, str_nil) !=
GDK_SUCCEED) {
- bat_iterator_end(&bi);
msg = createException(MAL,
"batstr.unicode", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto bailout;
+ goto bailout1;
}
nils = true;
} else {
if ((msg = str_from_wchr(&buf, &buflen,
vals[p1])) != MAL_SUCCEED) {
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
if (tfastins_nocheckVAR(bn, i, buf) !=
GDK_SUCCEED) {
- bat_iterator_end(&bi);
msg = createException(MAL,
"batstr.unicode", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto bailout;
+ goto bailout1;
}
}
}
@@ -275,24 +272,22 @@ STRbatFromWChr(Client cntxt, MalBlkPtr m
if (is_int_nil(x)) {
if (tfastins_nocheckVAR(bn, i, str_nil) !=
GDK_SUCCEED) {
- bat_iterator_end(&bi);
msg = createException(MAL,
"batstr.unicode", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto bailout;
+ goto bailout1;
}
nils = true;
} else {
if ((msg = str_from_wchr(&buf, &buflen,
vals[p1])) != MAL_SUCCEED) {
- bat_iterator_end(&bi);
- goto bailout;
+ goto bailout1;
}
if (tfastins_nocheckVAR(bn, i, buf) !=
GDK_SUCCEED) {
- bat_iterator_end(&bi);
msg = createException(MAL,
"batstr.unicode", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto bailout;
+ goto bailout1;
}
}
}
}
+ bailout1:
bat_iterator_end(&bi);
bailout:
GDKfree(buf);
@@ -347,15 +342,15 @@ STRbatSpace(Client cntxt, MalBlkPtr mb,
if (is_int_nil(x) || x < 0) {
if (tfastins_nocheckVAR(bn, i, str_nil) !=
GDK_SUCCEED) {
msg = createException(MAL,
"batstr.space", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto bailout;
+ goto bailout1;
}
nils = true;
} else {
if ((msg = str_repeat(&buf, &buflen, s, x)) !=
MAL_SUCCEED)
- goto bailout;
+ goto bailout1;
if (tfastins_nocheckVAR(bn, i, buf) !=
GDK_SUCCEED) {
msg = createException(MAL,
"batstr.space", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto bailout;
+ goto bailout1;
}
}
}
@@ -367,19 +362,20 @@ STRbatSpace(Client cntxt, MalBlkPtr mb,
if (is_int_nil(x) || x < 0) {
if (tfastins_nocheckVAR(bn, i, str_nil) !=
GDK_SUCCEED) {
msg = createException(MAL,
"batstr.space", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto bailout;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]