Changeset: cff68e94fa4d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cff68e94fa4d
Modified Files:
sql/backends/monet5/dict.c
sql/backends/monet5/for.c
Branch: default
Log Message:
Set property only when call succeeded. Throw storage errors
diffs (148 lines):
diff --git a/sql/backends/monet5/dict.c b/sql/backends/monet5/dict.c
--- a/sql/backends/monet5/dict.c
+++ b/sql/backends/monet5/dict.c
@@ -87,9 +87,9 @@ static str
DICTcompress_intern(BAT **O, BAT **U, BAT *b, bool ordered, bool persists,
bool smallest_type)
{
/* for now use all rows */
- BAT *u = BATunique(b, NULL);
+ BAT *u = BATunique(b, NULL), *uu = NULL;
if (!u)
- throw(SQL, "dict.compress", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ throw(SQL, "dict.compress", GDK_EXCEPTION);
assert(u->tkey);
BUN cnt = BATcount(u);
@@ -104,33 +104,34 @@ DICTcompress_intern(BAT **O, BAT **U, BA
throw(SQL, "dict.compress", SQLSTATE(3F000) "dict compress: too
many values");
}
BAT *uv = BATproject(u, b); /* get values */
- uv->tkey = true;
bat_destroy(u);
if (!uv)
- throw(SQL, "dict.compress", SQLSTATE(HY013) MAL_MALLOC_FAIL);
- BAT *uu = NULL;
+ throw(SQL, "dict.compress", GDK_EXCEPTION);
+ uv->tkey = true;
+
if (ordered) {
- if (BATsort(&uu, NULL, NULL, uv, NULL, NULL, false,
false, false) != GDK_SUCCEED) {
- bat_destroy(uv);
- throw(SQL, "dict.compress", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- }
+ if (BATsort(&uu, NULL, NULL, uv, NULL, NULL, false, false,
false) != GDK_SUCCEED) {
bat_destroy(uv);
- uv = uu;
+ throw(SQL, "dict.compress", GDK_EXCEPTION);
+ }
+ bat_destroy(uv);
+ uv = uu;
}
u = uv;
if (persists) {
uu = COLcopy(uv, uv->ttype, true, PERSISTENT);
bat_destroy(uv);
+ if (!uu)
+ throw(SQL, "dict.compress", GDK_EXCEPTION);
assert(uu->tkey);
- if (!uu)
- throw(SQL, "dict.compress", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
u = uu;
}
BAT *o = COLnew(b->hseqbase, tt, BATcount(b),
persists?PERSISTENT:TRANSIENT);
if (!o || BAThash(u) != GDK_SUCCEED) {
+ bat_destroy(o);
bat_destroy(u);
- throw(SQL, "dict.compress", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ throw(SQL, "dict.compress", GDK_EXCEPTION);
}
BUN p, q;
@@ -246,10 +247,31 @@ DICTcompress_col(Client cntxt, MalBlkPtr
msg = DICTcompress_intern(&o, &u, b, ordered, true, true);
bat_destroy(b);
if (msg == MAL_SUCCEED) {
- if (sql_trans_alter_storage(tr, c, "DICT") != LOG_OK ||
(c=get_newcolumn(tr, c)) == NULL || store->storage_api.col_compress(tr, c,
ST_DICT, o, u) != LOG_OK) {
- bat_destroy(u);
- bat_destroy(o);
- throw(SQL, "dict.compress", SQLSTATE(HY013)
"alter_storage failed");
+ switch (sql_trans_alter_storage(tr, c, "DICT")) {
+ case -1:
+ msg = createException(SQL, "dict.compress",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ break;
+ case -2:
+ case -3:
+ msg = createException(SQL, "dict.compress",
SQLSTATE(42000) "transaction conflict detected");
+ break;
+ default:
+ break;
+ }
+ if (msg == MAL_SUCCEED && !(c = get_newcolumn(tr, c)))
+ msg = createException(SQL, "dict.compress",
SQLSTATE(HY013) "alter_storage failed");
+ if (msg == MAL_SUCCEED) {
+ switch (store->storage_api.col_compress(tr, c, ST_DICT,
o, u)) {
+ case -1:
+ msg = createException(SQL,
"dict.compress", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ break;
+ case -2:
+ case -3:
+ msg = createException(SQL,
"dict.compress", SQLSTATE(42000) "transaction conflict detected");
+ break;
+ default:
+ break;
+ }
}
bat_destroy(u);
bat_destroy(o);
diff --git a/sql/backends/monet5/for.c b/sql/backends/monet5/for.c
--- a/sql/backends/monet5/for.c
+++ b/sql/backends/monet5/for.c
@@ -131,9 +131,9 @@ FORcompress_intern(char **comp_min_val,
snprintf(buf, 64, "FOR-" LLFMT, min_val);
} else if (b->ttype == TYPE_int) {
throw(SQL, "for.compress", SQLSTATE(3F000) "for compress:
implement type int");
+ } else {
+ throw(SQL, "for.compress", SQLSTATE(3F000) "for compress: type
not yet implemented");
}
- if (!o)
- throw(SQL, "for.compress", SQLSTATE(HY013) MAL_MALLOC_FAIL);
if (!(*comp_min_val = GDKstrdup(buf))) {
bat_destroy(o);
throw(SQL, "for.compress", SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -194,10 +194,31 @@ FORcompress_col(Client cntxt, MalBlkPtr
msg = FORcompress_intern(&comp_min_val, &o, b);
bat_destroy(b);
if (msg == MAL_SUCCEED) {
- if (sql_trans_alter_storage(tr, c, comp_min_val) != LOG_OK ||
(c=get_newcolumn(tr, c)) == NULL || store->storage_api.col_compress(tr, c,
ST_FOR, o, NULL) != LOG_OK) {
- GDKfree(comp_min_val);
- bat_destroy(o);
- throw(SQL, "for.compress", SQLSTATE(HY013)
"alter_storage failed");
+ switch (sql_trans_alter_storage(tr, c, comp_min_val)) {
+ case -1:
+ msg = createException(SQL, "for.compress",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ break;
+ case -2:
+ case -3:
+ msg = createException(SQL, "for.compress",
SQLSTATE(42000) "transaction conflict detected");
+ break;
+ default:
+ break;
+ }
+ if (msg == MAL_SUCCEED && !(c = get_newcolumn(tr, c)))
+ msg = createException(SQL, "for.compress",
SQLSTATE(HY013) "alter_storage failed");
+ if (msg == MAL_SUCCEED) {
+ switch (store->storage_api.col_compress(tr, c, ST_FOR,
o, NULL)) {
+ case -1:
+ msg = createException(SQL,
"for.compress", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ break;
+ case -2:
+ case -3:
+ msg = createException(SQL,
"for.compress", SQLSTATE(42000) "transaction conflict detected");
+ break;
+ default:
+ break;
+ }
}
GDKfree(comp_min_val);
bat_destroy(o);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list