Changeset: 69ce4e52c92f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/69ce4e52c92f
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_logger.c
monetdb5/modules/mal/calc.c
monetdb5/modules/mal/orderidx.c
sql/backends/monet5/sql.c
sql/storage/bat/bat_logger.c
sql/storage/bat/bat_storage.c
sql/storage/store.c
sql/storage/store_dependency.c
Branch: Sep2022
Log Message:
Fix up some error checking.
diffs (truncated from 390 to 300 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3494,6 +3494,8 @@ BBPprepare(bool subcommit)
/* starting a subcommit. Make sure SUBDIR and DELDIR
* are clean */
ret = BBPrecover_subdir();
+ if (ret != GDK_SUCCEED)
+ return ret;
}
if (backup_files == 0) {
backup_dir = 0;
@@ -3526,7 +3528,7 @@ BBPprepare(bool subcommit)
GDKfree(subdirpath);
return GDK_FAIL;
}
- TRC_DEBUG(IO_, "mkdir %s = %d\n", subdirpath, (int) ret);
+ TRC_DEBUG(IO_, "mkdir %s\n", subdirpath);
GDKfree(subdirpath);
}
if (backup_dir != set) {
@@ -4029,6 +4031,7 @@ force_move(int farmid, const char *srcdi
if (ret != GDK_SUCCEED) {
char *srcpath;
+ GDKclrerr();
/* two legal possible causes: file exists or dir
* doesn't exist */
if(!(dstpath = GDKfilepath(farmid, dstdir, name, NULL)))
@@ -4198,10 +4201,10 @@ BBPrecover_subdir(void)
if (dent->d_name[0] == '.')
continue;
ret = GDKmove(0, SUBDIR, dent->d_name, NULL, BAKDIR,
dent->d_name, NULL, true);
- if (ret == GDK_SUCCEED && strcmp(dent->d_name, "BBP.dir") == 0)
- backup_dir = 1;
if (ret != GDK_SUCCEED)
break;
+ if (strcmp(dent->d_name, "BBP.dir") == 0)
+ backup_dir = 1;
}
closedir(dirp);
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -748,8 +748,9 @@ log_read_destroy(logger *lg, trans *tr,
tr->changes[tr->nr].type = LOG_DESTROY;
tr->changes[tr->nr].cid = id;
tr->nr++;
+ return LOG_OK;
}
- return LOG_OK;
+ return LOG_ERR;
}
static gdk_return
@@ -784,9 +785,9 @@ log_read_create(logger *lg, trans *tr, l
tr->changes[tr->nr].tt = tpe;
tr->changes[tr->nr].cid = id;
tr->nr++;
+ return LOG_OK;
}
-
- return LOG_OK;
+ return LOG_ERR;
}
static gdk_return
@@ -1272,7 +1273,7 @@ log_readlog(logger *lg, char *filename,
}
gdk_return res = log_open_input(lg, filename, filemissing);
- if (!lg->input_log)
+ if (!lg->input_log || res != GDK_SUCCEED)
return res;
int fd;
if ((fd = getFileNo(lg->input_log)) < 0 || fstat(fd, &sb) < 0) {
@@ -1314,8 +1315,8 @@ log_readlog(logger *lg, char *filename,
/* we cannot distinguish errors from incomplete transactions
* (even if we would log aborts in the logs). So we simply
* abort and move to the next log file */
- //return err == LOG_ERR ? GDK_FAIL : GDK_SUCCEED;
- return GDK_SUCCEED;
+ return err == LOG_ERR ? GDK_FAIL : GDK_SUCCEED;
+ //return GDK_SUCCEED;
}
/*
@@ -2665,7 +2666,7 @@ log_bat_transient(logger *lg, log_id id)
BAT *b = BBPquickdesc(bid);
assert(b);
lg->end += BATcount(b);
- gdk_return r = log_del_bat(lg, bid);
+ gdk_return r = log_del_bat(lg, bid);
log_unlock(lg);
if (r != GDK_SUCCEED)
(void) ATOMIC_DEC(&lg->refcount);
@@ -2854,7 +2855,8 @@ log_tend(logger *lg)
return result;
}
static int
-request_number_flush_queue(logger *lg) {
+request_number_flush_queue(logger *lg)
+{
// Semaphore protects ring buffer structure in queue against overflowing
static unsigned int _number = 0;
int result;
@@ -2870,7 +2872,8 @@ request_number_flush_queue(logger *lg) {
}
static void
-left_truncate_flush_queue(logger *lg, int limit) {
+left_truncate_flush_queue(logger *lg, int limit)
+{
MT_lock_set(&lg->flush_queue_lock);
lg->flush_queue_begin = (lg->flush_queue_begin + limit) %
FLUSH_QUEUE_SIZE;
lg->flush_queue_length -= limit;
@@ -2880,29 +2883,31 @@ left_truncate_flush_queue(logger *lg, in
MT_sema_up(&lg->flush_queue_semaphore);
}
-static int
-number_in_flush_queue(logger *lg, unsigned int number) {
+static bool
+number_in_flush_queue(logger *lg, unsigned int number)
+{
MT_lock_set(&lg->flush_queue_lock);
const int fql = lg->flush_queue_length;
MT_lock_unset(&lg->flush_queue_lock);
for (int i = 0; i < fql; i++) {
const int idx = (lg->flush_queue_begin + i) % FLUSH_QUEUE_SIZE;
if (lg->flush_queue[idx] == number) {
- return 1;
+ return true;
}
}
- return 0;
+ return false;
}
static int
-flush_queue_length(logger *lg) {
+flush_queue_length(logger *lg)
+{
MT_lock_set(&lg->flush_queue_lock);
const int fql = lg->flush_queue_length;
MT_lock_unset(&lg->flush_queue_lock);
return fql;
}
-static gdk_return
+static void
log_tdone(logger *lg, ulng commit_ts)
{
if (lg->debug & 1)
@@ -2911,7 +2916,6 @@ log_tdone(logger *lg, ulng commit_ts)
if (lg->current) {
lg->current->last_ts = commit_ts;
}
- return GDK_SUCCEED;
}
gdk_return
@@ -3133,6 +3137,7 @@ log_del_bat(logger *lg, log_bid bid)
return GDK_FAIL;
}
+/* returns -1 on failure, 0 when not found, > 0 when found */
log_bid
log_find_bat(logger *lg, log_id id)
{
@@ -3161,7 +3166,8 @@ log_tstart(logger *lg, bool flushnow, ul
while (lg->saved_id+1 < lg->id) {
log_unlock(lg);
MT_lock_unset(&lg->rotation_lock);
- log_flush(lg, (1ULL<<63));
+ if (log_flush(lg, (1ULL<<63)) != GDK_SUCCEED)
+ return GDK_FAIL;
MT_lock_set(&lg->rotation_lock);
log_lock(lg);
}
diff --git a/monetdb5/modules/mal/calc.c b/monetdb5/modules/mal/calc.c
--- a/monetdb5/modules/mal/calc.c
+++ b/monetdb5/modules/mal/calc.c
@@ -693,7 +693,6 @@ CMDBATavg3(Client cntxt, MalBlkPtr mb, M
bit *skip_nils;
BAT *b = NULL, *s = NULL, *avgs, *cnts, *rems;
- gdk_return rc;
(void)cntxt;
(void)mb;
@@ -713,7 +712,8 @@ CMDBATavg3(Client cntxt, MalBlkPtr mb, M
BBPunfix(b->batCacheid);
throw(MAL, "aggr.avg", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
}
- rc = BATgroupavg3(&avgs, &rems, &cnts, b, NULL, NULL, s, *skip_nils);
+ if (BATgroupavg3(&avgs, &rems, &cnts, b, NULL, NULL, s, *skip_nils) !=
GDK_SUCCEED)
+ return mythrow(MAL, "aggr.avg", GDK_EXCEPTION);
if (avgs && BATcount(avgs) == 1) {
/* only type bte, sht, int, lng and hge */
ptr res = VALget(ret);
@@ -754,8 +754,6 @@ CMDBATavg3(Client cntxt, MalBlkPtr mb, M
BBPunfix(b->batCacheid);
if (s)
BBPunfix(s->batCacheid);
- if (rc != GDK_SUCCEED)
- return mythrow(MAL, "aggr.avg", OPERATION_FAILED);
return MAL_SUCCEED;
}
diff --git a/monetdb5/modules/mal/orderidx.c b/monetdb5/modules/mal/orderidx.c
--- a/monetdb5/modules/mal/orderidx.c
+++ b/monetdb5/modules/mal/orderidx.c
@@ -316,15 +316,13 @@ static str
OIDXorderidx(bat *ret, const bat *bid, const bit *stable)
{
BAT *b;
- gdk_return r;
(void) ret;
b = BATdescriptor(*bid);
if (b == NULL)
throw(MAL, "algebra.orderidx", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- r = BATorderidx(b, *stable);
- if (r != GDK_SUCCEED) {
+ if (BATorderidx(b, *stable) != GDK_SUCCEED) {
BBPunfix(*bid);
throw(MAL, "algebra.orderidx", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -1329,8 +1329,10 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb
} else {
int coltype = getBatType(getArgType(mb, pci, 0));
b = store->storage_api.bind_col(m->session->tr, c,
access);
-
- if (b && b->ttype && b->ttype != coltype) {
+ if (b == NULL)
+ throw(SQL, "sql.bind", SQLSTATE(42000) "Cannot
bind column %s.%s.%s", sname, tname, cname);
+
+ if (b->ttype && b->ttype != coltype) {
BBPunfix(b->batCacheid);
throw(SQL,"sql.bind",SQLSTATE(42000) "Column
type mismatch %s.%s.%s",sname,tname,cname);
}
@@ -5029,8 +5031,7 @@ SQLstr_column_auto_vacuum(Client cntxt,
}
void *argv[4] = {m->store, sname_copy, tname_copy, cname_copy};
- gdk_return res;
- if((res = gdk_add_callback("str_column_vacuum",
str_column_vacuum_callback, 4, argv, interval)) != GDK_SUCCEED) {
+ if (gdk_add_callback("str_column_vacuum", str_column_vacuum_callback,
4, argv, interval) != GDK_SUCCEED) {
str_column_vacuum_callback_args_free(4, argv);
throw(SQL, "sql.str_column_auto_vacuum", "adding vacuum
callback failed!");
}
diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -127,7 +127,7 @@ replace_bat(old_logger *old_lg, logger *
lg->cnt++;
}
}
- return GDK_SUCCEED;
+ return rc;
}
#endif
@@ -2003,6 +2003,8 @@ bl_postversion(void *Store, void *Lg)
{
/* new BOOLEAN column sys.functions.semantics */
b = log_temp_descriptor(log_find_bat(lg, 2017)); /*
sys.functions.id */
+ if (b == NULL)
+ return GDK_FAIL;
BAT *sem = BATconstant(b->hseqbase, TYPE_bit,
&(bit){1}, BATcount(b), PERSISTENT);
bat_destroy(b);
if (sem == NULL)
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
@@ -3984,7 +3984,7 @@ log_table_append(sql_trans *tr, sql_tabl
}
unlock_table(tr->store, t->base.id);
- if (cs->ebid) {
+ if (ok == GDK_SUCCEED && cs->ebid) {
BAT *ins = temp_descriptor(cs->ebid);
assert(ins);
if (BATcount(ins) > ins->batInserted)
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3915,7 +3915,7 @@ sql_trans_commit(sql_trans *tr)
sqlstore *store = tr->store;
if (!list_empty(tr->changes)) {
- int flush = 0;
+ bool flush = false;
ulng commit_ts = 0, oldest = 0, log_file_id = 0;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]