Changeset: 3cfa21253b9d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3cfa21253b9d
Modified Files:
gdk/gdk_logger.c
sql/backends/monet5/UDF/pyapi/convert_loops.h
sql/backends/monet5/vaults/netcdf/netcdf.c
sql/storage/bat/bat_storage.c
sql/storage/bat/bat_utils.c
sql/storage/bat/res_table.c
Branch: Dec2016
Log Message:
Added some error checking.
diffs (204 lines):
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1646,6 +1646,8 @@ logger_load(int debug, const char *fn, c
logger_fatal("Logger_new: inconsistent
database, snapshots_tid does not exist", 0, 0, 0);
} else {
lg->dsnapshots = logbat_new(TYPE_oid, 1, PERSISTENT);
+ if (lg->dsnapshots == NULL)
+ logger_fatal("Logger_new: cannot create
dsnapshot bat", 0, 0, 0);
snprintf(bak, sizeof(bak), "%s_dsnapshots", fn);
if (BBPrename(lg->dsnapshots->batCacheid, bak) < 0)
logger_fatal("Logger_new: BBPrename to %s
failed", bak, 0, 0);
@@ -2672,6 +2674,9 @@ bm_commit(logger *lg)
BAT *n = logbat_new(TYPE_str, BATcount(lg->freed), TRANSIENT);
gdk_return res;
+ if (n == NULL)
+ return LOG_ERR;
+
/* subcommit the freed bats */
if (BATcount(lg->freed)) {
diff --git a/sql/backends/monet5/UDF/pyapi/convert_loops.h
b/sql/backends/monet5/UDF/pyapi/convert_loops.h
--- a/sql/backends/monet5/UDF/pyapi/convert_loops.h
+++ b/sql/backends/monet5/UDF/pyapi/convert_loops.h
@@ -52,6 +52,10 @@
#ifdef HAVE_FORK
#define CREATE_BAT_ZEROCOPY(bat, mtpe, batstore) {
\
bat = COLnew(seqbase, TYPE_##mtpe, 0, TRANSIENT);
\
+ if (bat == NULL) { \
+ msg = createException(MAL, "pyapi.eval", "Cannor create BAT");
\
+ goto wrapup; \
+ } \
bat->tnil = 0; bat->tnonil = 1;
\
bat->tkey = 0; bat->tsorted = 0; bat->trevsorted = 0;
\
/*Change nil values to the proper values, if they exist*/
\
@@ -100,6 +104,10 @@
#else
#define CREATE_BAT_ZEROCOPY(bat, mtpe, batstore) {
\
bat = COLnew(seqbase, TYPE_##mtpe, 0, TRANSIENT);
\
+ if (bat == NULL) { \
+ msg = createException(MAL, "pyapi.eval", "Cannor create BAT");
\
+ goto wrapup; \
+ } \
bat->tnil = 0; bat->tnonil = 1;
\
bat->tkey = 0; bat->tsorted = 0; bat->trevsorted = 0;
\
/*Change nil values to the proper values, if they exist*/
\
@@ -399,6 +407,10 @@
}
\
} else {
\
bat = COLnew(seqbase, TYPE_##mtpe, (BUN) ret->count, TRANSIENT);
\
+ if (bat == NULL) { \
+ msg = createException(MAL, "pyapi.eval", "Cannor create BAT");
\
+ goto wrapup; \
+ } \
if (NOT_HGE(mtpe) && TYPE_##mtpe !=
PyType_ToBat(ret->result_type)) WARNING_MESSAGE("!PERFORMANCE WARNING: You are
returning a Numpy Array of type %s, which has to be converted to a BAT of type
%s. If you return a Numpy\
Array of type %s no copying will be needed.\n",
PyType_Format(ret->result_type), BatType_Format(TYPE_##mtpe),
PyType_Format(BatType_ToPyType(TYPE_##mtpe))); \
bat->tkey = 0; bat->tsorted = 0; bat->trevsorted = 0;
\
diff --git a/sql/backends/monet5/vaults/netcdf/netcdf.c
b/sql/backends/monet5/vaults/netcdf/netcdf.c
--- a/sql/backends/monet5/vaults/netcdf/netcdf.c
+++ b/sql/backends/monet5/vaults/netcdf/netcdf.c
@@ -185,20 +185,24 @@ NCDFARRAYseries(bat *bid, bte start, bte
bte sta = (bte) start, ste = (bte) step, sto = (bte) stop;
bn = COLnew(0, TYPE_bte, cnt, TRANSIENT);
+ if ( bn == NULL)
+ throw(MAL, "array.series", MAL_MALLOC_FAIL);
array_series(sta, ste, sto, bte);
} else if (stop <= (int) GDK_sht_max) {
sht sta = (sht) start, ste = (sht) step, sto = (sht) stop;
bn = COLnew(0, TYPE_sht, cnt, TRANSIENT);
+ if ( bn == NULL)
+ throw(MAL, "array.series", MAL_MALLOC_FAIL);
array_series(sta, ste, sto, sht);
} else {
int sta = (int) start, ste = (int) step, sto = (int) stop;
bn = COLnew(0, TYPE_int, cnt, TRANSIENT);
+ if ( bn == NULL)
+ throw(MAL, "array.series", MAL_MALLOC_FAIL);
array_series(sta, ste, sto, int);
}
- if ( bn == NULL)
- throw(MAL, "array.series", MAL_MALLOC_FAIL);
BATsetcount(bn, cnt);
bn->tsorted = (cnt <= 1 || (series == 1 && step > 0));
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -523,6 +523,8 @@ dup_delta(sql_trans *tr, sql_delta *obat
} else if (oc_isnew && !bat->bid) {
/* move the bat to the new col, fixup the old col*/
b = COLnew((oid) obat->cnt, type, sz, PERSISTENT);
+ if (b == NULL)
+ return LOG_ERR;
bat_set_access(b, BAT_READ);
obat->ibid = temp_create(b);
obat->ibase = bat->ibase = (oid) obat->cnt;
@@ -535,6 +537,8 @@ dup_delta(sql_trans *tr, sql_delta *obat
bat->bid = bat->ibid;
b = COLnew(bat->ibase, type, sz, PERSISTENT);
+ if (b == NULL)
+ return LOG_ERR;
bat_set_access(b, BAT_READ);
bat->ibid = temp_create(b);
}
@@ -549,15 +553,21 @@ dup_delta(sql_trans *tr, sql_delta *obat
if (c_isnew && tr->parent == gtrans) {
obat->uibid = ebat_copy(bat->uibid, 0, 0);
obat->uvbid = ebat_copy(bat->uvbid, 0, 0);
+ if (obat->uibid == BID_NIL ||
+ obat->uvbid == BID_NIL)
+ return LOG_ERR;
} else {
bat->uibid = ebat_copy(bat->uibid, 0, 0);
bat->uvbid = ebat_copy(bat->uvbid, 0, 0);
+ if (bat->uibid == BID_NIL ||
+ bat->uvbid == BID_NIL)
+ return LOG_ERR;
}
- if (bat->uibid == BID_NIL || bat->uvbid == BID_NIL)
- return LOG_ERR;
} else {
bat->uibid = e_bat(TYPE_oid);
obat->uvbid = e_bat(type);
+ if (bat->uibid == BID_NIL || obat->uvbid == BID_NIL)
+ return LOG_ERR;
}
}
if (bat->bid)
@@ -1214,14 +1224,19 @@ new_persistent_delta( sql_delta *bat, in
bat_destroy(i);
} else {
BAT *i, *b = temp_descriptor(bat->ibid);
- int type = b->ttype;
+ int type;
+ if (b == NULL)
+ return LOG_ERR;
+ type = b->ttype;
bat->bid = bat->ibid;
bat->cnt = bat->ibase = BATcount(b);
bat->ucnt = 0;
bat_destroy(b);
i = COLnew(bat->ibase, type, sz, PERSISTENT);
+ if (i == NULL)
+ return LOG_ERR;
bat_set_access(i, BAT_READ);
bat->ibid = temp_create(i);
bat_destroy(i);
diff --git a/sql/storage/bat/bat_utils.c b/sql/storage/bat/bat_utils.c
--- a/sql/storage/bat/bat_utils.c
+++ b/sql/storage/bat/bat_utils.c
@@ -119,16 +119,18 @@ ebat2real(log_bid b, oid ibase)
log_bid
e_bat(int type)
{
- if (!ebats[type])
- ebats[type] = bat_new(type, 0, TRANSIENT);
+ if (ebats[type] == NULL &&
+ (ebats[type] = bat_new(type, 0, TRANSIENT)) == NULL)
+ return BID_NIL;
return temp_create(ebats[type]);
}
BAT *
e_BAT(int type)
{
- if (!ebats[type])
- ebats[type] = bat_new(type, 0, TRANSIENT);
+ if (ebats[type] == NULL &&
+ (ebats[type] = bat_new(type, 0, TRANSIENT)) == NULL)
+ return NULL;
return temp_descriptor(ebats[type]->batCacheid);
}
diff --git a/sql/storage/bat/res_table.c b/sql/storage/bat/res_table.c
--- a/sql/storage/bat/res_table.c
+++ b/sql/storage/bat/res_table.c
@@ -64,18 +64,14 @@ res_col_create(sql_trans *tr, res_table
if (mtype == TYPE_bat) {
b = (BAT*)val;
} else { // wrap scalar values in BATs for result consistency
- b = COLnew(0, mtype, 0, TRANSIENT);
+ b = COLnew(0, mtype, 1, TRANSIENT);
assert (b != NULL);
BUNappend(b, val, FALSE);
- BATsetcount(b, 1);
- BATsettrivprop(b);
/* we need to set the order bat otherwise mvc_export_result
won't work with single-row result sets containing BATs */
if (!t->order) {
oid zero = 0;
- BAT *o = COLnew(0, TYPE_oid, 0, TRANSIENT);
+ BAT *o = COLnew(0, TYPE_oid, 1, TRANSIENT);
BUNappend(o, &zero, FALSE);
- BATsetcount(o, 1);
- BATsettrivprop(o);
t->order = o->batCacheid;
bat_incref(t->order);
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list