Changeset: 6c2ec450b5ee for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6c2ec450b5ee
Modified Files:
monetdb5/modules/mal/remote.c
Branch: Jul2021
Log Message:
Throw internal error when it happens. Also fixed BAT reference handling on
error situations and throw better error message when the GDK type doesn't exist
diffs (109 lines):
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -676,7 +676,7 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
} else if (strcmp(nme, "ttype") == 0) {
if (lv >= GDKatomcnt)
throw(MAL,
"remote.bincopyfrom",
- "bad %s
value: %s", nme, val);
+ "bad %s
value: GDK atom number %s doesn't exist", nme, val);
bb.Ttype = (int) lv;
} else if (strcmp(nme, "tseqbase") ==
0) {
#if SIZEOF_OID < SIZEOF_LNG
@@ -905,12 +905,12 @@ static str RMTget(Client cntxt, MalBlkPt
mnstr_printf(sout, "remote.batbincopy(%s);\n", ident);
mnstr_flush(sout, MNSTR_FLUSH_DATA);
- if ( (tmp = RMTreadbatheader(sin, buf)) != MAL_SUCCEED) {
+ if ((tmp = RMTreadbatheader(sin, buf)) != MAL_SUCCEED) {
MT_lock_unset(&c->lock);
return tmp;
}
- if ((tmp = RMTinternalcopyfrom(&b, buf, sin, true)) != NULL) {
+ if ((tmp = RMTinternalcopyfrom(&b, buf, sin, true)) !=
MAL_SUCCEED) {
MT_lock_unset(&c->lock);
return(tmp);
}
@@ -1370,53 +1370,47 @@ static str RMTexec(Client cntxt, MalBlkP
/* Temporary hack:
* use a callback to immediately handle columnar results before hdl is
destroyed. */
- if(tmp == MAL_SUCCEED && rcb && mhdl && (mapi_get_querytype(mhdl) ==
Q_TABLE || mapi_get_querytype(mhdl) == Q_PREPARE)) {
-
+ if (tmp == MAL_SUCCEED && rcb && mhdl && (mapi_get_querytype(mhdl) ==
Q_TABLE || mapi_get_querytype(mhdl) == Q_PREPARE)) {
int fields = mapi_get_field_count(mhdl);
-
columnar_result* results = GDKzalloc(sizeof(columnar_result) *
fields);
- char buf[256] = {0};
+ if (!results) {
+ tmp = createException(MAL, "remote.exec",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ } else {
+ int i = 0;
+ char buf[256] = {0};
+ stream *sin = mapi_get_from(c->mconn);
- stream* sin = mapi_get_from(c->mconn);
-
- char* tblname = mapi_get_table(mhdl, 0);
+ for (; i < fields; i++) {
+ BAT *b = NULL;
- int i;
- for (i = 0; i < fields; i++) {
- BAT *b = NULL;
+ if ((tmp = RMTreadbatheader(sin, buf)) !=
MAL_SUCCEED ||
+ (tmp = RMTinternalcopyfrom(&b, buf,
sin, i == fields - 1)) != MAL_SUCCEED) {
+ break;
+ }
- RMTreadbatheader(sin, buf);
- RMTinternalcopyfrom(&b, buf, sin, i == fields - 1);
-
- if ( b == NULL) {
- tmp=
createException(MAL,"sql.resultset",SQLSTATE(HY005) "Cannot access column
descriptor ");
- break;
+ results[i].id = b->batCacheid;
+ results[i].colname = mapi_get_name(mhdl, i);
+ results[i].tpename = mapi_get_type(mhdl, i);
+ results[i].digits = mapi_get_digits(mhdl, i);
+ results[i].scale = mapi_get_scale(mhdl, i);
}
- results[i].id = b->batCacheid;
- results[i].colname = mapi_get_name(mhdl, i);
- results[i].tpename = mapi_get_type(mhdl, i);
- results[i].digits = mapi_get_digits(mhdl, i);
- results[i].scale = mapi_get_scale(mhdl, i);
- BBPkeepref(results[i].id);
+ if (tmp != MAL_SUCCEED) {
+ for (int j = 0; j < i; j++)
+ BBPunfix(results[j].id);
+ } else {
+ for (int j = 0; j < i; j++)
+ BBPkeepref(results[j].id);
+ assert(rcb->context);
+ tmp = rcb->call(rcb->context,
mapi_get_table(mhdl, 0), results, fields);
+ }
+ GDKfree(results);
}
-
- if (tmp != MAL_SUCCEED) {
- for (int j = 0; j < i; j++) {
- BBPrelease(results[j].id);
- }
- }
- else {
- assert(rcb->context);
- tmp = rcb->call(rcb->context, tblname, results, fields);
- }
- GDKfree(results);
}
if (rcb) {
GDKfree(rcb->context);
- rcb->context = NULL;
GDKfree(rcb);
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list