Changeset: 36c6018fc87b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=36c6018fc87b
Modified Files:
gdk/gdk_logger.c
geom/monetdb5/geomBulk.c
Branch: default
Log Message:
Lots of error checking.
diffs (truncated from 471 to 300 lines):
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -352,24 +352,30 @@ log_read_updates(logger *lg, trans *tr,
assert(l->nr <= (lng) BUN_MAX);
if (l->flag == LOG_UPDATE) {
uid = COLnew(0, ht, (BUN) l->nr, PERSISTENT);
- r = COLnew(0, tt, (BUN) l->nr, PERSISTENT);
+ if (uid == NULL)
+ return GDK_FAIL;
} else {
assert(ht == TYPE_void);
- r = COLnew(0, tt, (BUN) l->nr, PERSISTENT);
+ }
+ r = COLnew(0, tt, (BUN) l->nr, PERSISTENT);
+ if (r == NULL) {
+ BBPreclaim(uid);
+ return GDK_FAIL;
}
if (tseq)
BATtseqbase(r, 0);
if (ht == TYPE_void && l->flag == LOG_INSERT) {
- for (; l->nr > 0; l->nr--) {
+ for (; res == GDK_SUCCEED && l->nr > 0; l->nr--) {
void *t = rt(tv, lg->log, 1);
if (t == NULL) {
res = GDK_FAIL;
break;
}
- BUNappend(r, t, TRUE);
+ if (BUNappend(r, t, TRUE) != GDK_SUCCEED)
+ res = GDK_FAIL;
if (t != tv)
GDKfree(t);
}
@@ -382,16 +388,15 @@ log_read_updates(logger *lg, trans *tr,
if (hv == NULL)
res = GDK_FAIL;
- for (; l->nr > 0; l->nr--) {
+ for (; res == GDK_SUCCEED && l->nr > 0; l->nr--) {
void *h = rh(hv, lg->log, 1);
void *t = rt(tv, lg->log, 1);
if (h == NULL || t == NULL)
res = GDK_FAIL;
- break;
- }
- BUNappend(uid, h, TRUE);
- BUNappend(r, t, TRUE);
+ else if (BUNappend(uid, h, TRUE) != GDK_SUCCEED
||
+ BUNappend(r, t, TRUE) != GDK_SUCCEED)
+ res = GDK_FAIL;
if (t != tv)
GDKfree(t);
}
@@ -401,7 +406,7 @@ log_read_updates(logger *lg, trans *tr,
GDKfree(tv);
logbat_destroy(b);
- if (tr_grow(tr)) {
+ if (res == GDK_SUCCEED && tr_grow(tr)) {
tr->changes[tr->nr].type = l->flag;
tr->changes[tr->nr].nr = l->nr;
tr->changes[tr->nr].ht = ht;
@@ -1111,19 +1116,22 @@ logger_commit(logger *lg)
p = log_find(lg->seqs_id, lg->dseqs, id);
if (p >= lg->seqs_val->batInserted) {
- BUNinplace(lg->seqs_val, p, &lg->id, FALSE);
+ if (BUNinplace(lg->seqs_val, p, &lg->id, FALSE) != GDK_SUCCEED)
+ return GDK_FAIL;
} else {
oid pos = p;
- BUNappend(lg->dseqs, &pos, FALSE);
- BUNappend(lg->seqs_id, &id, FALSE);
- BUNappend(lg->seqs_val, &lg->id, FALSE);
+ if (BUNappend(lg->dseqs, &pos, FALSE) != GDK_SUCCEED ||
+ BUNappend(lg->seqs_id, &id, FALSE) != GDK_SUCCEED ||
+ BUNappend(lg->seqs_val, &lg->id, FALSE) != GDK_SUCCEED)
+ return GDK_FAIL;
}
/* cleanup old snapshots */
if (BATcount(lg->snapshots_bid)) {
- BATclear(lg->snapshots_bid, TRUE);
- BATclear(lg->snapshots_tid, TRUE);
- BATclear(lg->dsnapshots, TRUE);
+ if (BATclear(lg->snapshots_bid, TRUE) != GDK_SUCCEED ||
+ BATclear(lg->snapshots_tid, TRUE) != GDK_SUCCEED ||
+ BATclear(lg->dsnapshots, TRUE) != GDK_SUCCEED)
+ return GDK_FAIL;
BATcommit(lg->snapshots_bid);
BATcommit(lg->snapshots_tid);
BATcommit(lg->dsnapshots);
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -48,7 +48,12 @@ geom_2_geom_bat(bat *outBAT_id, bat *inB
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, outWKB, TRUE); //add the point to the
new BAT
+ if (BUNappend(outBAT, outWKB, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ GDKfree(outWKB);
+ throw(MAL, "batcalc.wkb", MAL_MALLOC_FAIL);
+ }
GDKfree(outWKB);
outWKB = NULL;
}
@@ -91,7 +96,12 @@ wkbFromText_bat(bat *outBAT_id, bat *inB
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, outSingle, TRUE); //add the result to the
new BAT
+ if (BUNappend(outBAT, outSingle, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ GDKfree(outSingle);
+ throw(MAL, "batgeom.wkbFromText", MAL_MALLOC_FAIL);
+ }
GDKfree(outSingle);
outSingle = NULL;
}
@@ -139,7 +149,11 @@ wkbCoordinateFromMBR_bat(bat *outBAT_id,
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, &outDbl, TRUE);
+ if (BUNappend(outBAT, &outDbl, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ throw(MAL, "batgeom.coordinateFromMBR",
MAL_MALLOC_FAIL);
+ }
}
BBPunfix(inBAT->batCacheid);
@@ -182,7 +196,12 @@ WKBtoSTRflagINT_bat(bat *outBAT_id, bat
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, outSingle, TRUE); //add the result to the
new BAT
+ if (BUNappend(outBAT, outSingle, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ GDKfree(outSingle);
+ throw(MAL, name, MAL_MALLOC_FAIL);
+ }
GDKfree(outSingle);
outSingle = NULL;
}
@@ -244,7 +263,12 @@ WKBtoWKB_bat(bat *outBAT_id, bat *inBAT_
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, outSingle, TRUE); //add the result to the
new BAT
+ if (BUNappend(outBAT, outSingle, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ GDKfree(outSingle);
+ throw(MAL, name, MAL_MALLOC_FAIL);
+ }
GDKfree(outSingle);
outSingle = NULL;
}
@@ -300,7 +324,12 @@ WKBtoWKBflagINT_bat(bat *outBAT_id, bat
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, outSingle, TRUE); //add the result to the
new BAT
+ if (BUNappend(outBAT, outSingle, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ GDKfree(outSingle);
+ throw(MAL, name, MAL_MALLOC_FAIL);
+ }
GDKfree(outSingle);
outSingle = NULL;
}
@@ -355,7 +384,11 @@ WKBtoBIT_bat(bat *outBAT_id, bat *inBAT_
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, &outSingle, TRUE); //add the result to the
new BAT
+ if (BUNappend(outBAT, &outSingle, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ throw(MAL, name, MAL_MALLOC_FAIL);
+ }
}
//set the number of elements in the outBAT
@@ -434,7 +467,11 @@ WKBtoINT_bat(bat *outBAT_id, bat *inBAT_
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, &outSingle, TRUE); //add the result to the
new BAT
+ if (BUNappend(outBAT, &outSingle, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ throw(MAL, name, MAL_MALLOC_FAIL);
+ }
}
//set the number of elements in the outBAT
@@ -494,7 +531,11 @@ WKBtoINTflagINT_bat(bat *outBAT_id, bat
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, &outSingle, TRUE); //add the result to the
new BAT
+ if (BUNappend(outBAT, &outSingle, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ throw(MAL, name, MAL_MALLOC_FAIL);
+ }
}
//set the number of elements in the outBAT
@@ -554,7 +595,11 @@ wkbGetCoordinate_bat(bat *outBAT_id, bat
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, &outSingle, TRUE); //add the result to the
new BAT
+ if (BUNappend(outBAT, &outSingle, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ throw(MAL, "batgeom.wkbGetCoordinate", MAL_MALLOC_FAIL);
+ }
}
//set the number of elements in the outBAT
@@ -606,17 +651,20 @@ wkbBox2D_bat(bat *outBAT_id, bat *aBAT_i
wkb *bWKB = (wkb *) BUNtail(bBAT_iter, i);
if ((ret = wkbBox2D(&outSingle, &aWKB, &bWKB)) != MAL_SUCCEED) {
- BBPunfix(outBAT->batCacheid);
goto clean;
}
- BUNappend(outBAT, outSingle, TRUE); //add the result to the
outBAT
+ if (BUNappend(outBAT, outSingle, FALSE) != GDK_SUCCEED) {
+ GDKfree(outSingle);
+ ret = createException(MAL, "batgeom.wkbBox2D",
MAL_MALLOC_FAIL);
+ goto clean;
+ }
GDKfree(outSingle);
- outSingle = NULL;
}
BBPkeepref(*outBAT_id = outBAT->batCacheid);
clean:
+ BBPreclaim(outBAT);
if (aBAT)
BBPunfix(aBAT->batCacheid);
if (bBAT)
@@ -660,15 +708,18 @@ wkbContains_bat(bat *outBAT_id, bat *aBA
wkb *bWKB = (wkb *) BUNtail(bBAT_iter, i);
if ((ret = wkbContains(&outBIT, &aWKB, &bWKB)) != MAL_SUCCEED) {
- BBPunfix(outBAT->batCacheid);
goto clean;
}
- BUNappend(outBAT, &outBIT, TRUE); //add the result to the
outBAT
+ if (BUNappend(outBAT, &outBIT, FALSE) != GDK_SUCCEED) {
+ ret = createException(MAL, "batgeom.Contains",
MAL_MALLOC_FAIL);
+ goto clean;
+ }
}
BBPkeepref(*outBAT_id = outBAT->batCacheid);
clean:
+ BBPreclaim(outBAT);
if (aBAT)
BBPunfix(aBAT->batCacheid);
if (bBAT)
@@ -708,7 +759,11 @@ wkbContains_geom_bat(bat *outBAT_id, wkb
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, &outBIT, TRUE); //add the result to the
outBAT
+ if (BUNappend(outBAT, &outBIT, FALSE) != GDK_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ throw(MAL, "batgeom.Contains", MAL_MALLOC_FAIL);
+ }
}
BBPunfix(inBAT->batCacheid);
@@ -749,7 +804,11 @@ wkbContains_bat_geom(bat *outBAT_id, bat
BBPunfix(outBAT->batCacheid);
return err;
}
- BUNappend(outBAT, &outBIT, TRUE); //add the result to the
outBAT
+ if (BUNappend(outBAT, &outBIT, FALSE) != GDK_SUCCEED) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list