Changeset: caeac16cf689 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/caeac16cf689
Modified Files:
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_scenario.c
Branch: Jan2022
Log Message:
merged with jul2021
diffs (178 lines):
diff --git a/sql/backends/monet5/sql_gencode.c
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -322,7 +322,7 @@ static int
node *n;
int i, q, v, res = 0, added_to_cache = 0, *lret, *rret;
size_t len = 1024, nr;
- char *lname, *buf;
+ char *lname = NULL, *buf = NULL, *mal_session_uuid, *err = NULL;
sql_rel *r = rel;
if (local_tbl == NULL) {
@@ -367,6 +367,7 @@ static int
if( c->curprg == NULL) {
GDKfree(lname);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ c->curprg = backup;
return -1;
}
lname[0] = 'l';
@@ -375,9 +376,9 @@ static int
curInstr = relational_func_create_result(m, curBlk, curInstr, rel);
if( curInstr == NULL) {
- GDKfree(lname);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
/* ops */
@@ -392,9 +393,9 @@ static int
sprintf(nbuf, "A%d", i++);
if ((varid = newVariable(curBlk, nbuf, strlen(nbuf),
type)) < 0) {
- GDKfree(lname);
sql_error(m, 10, SQLSTATE(42000) "Internal
error while compiling statement: variable id too long");
- return -1;
+ res = -1;
+ goto cleanup;
}
curInstr = pushArgument(curBlk, curInstr, varid);
setVarType(curBlk, varid, type);
@@ -443,9 +444,9 @@ static int
p = pushArgument(curBlk, p, getArg(o,0));
if (!(buf = rel2str(m, rel))) {
- GDKfree(lname);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
o = newFcnCall(curBlk, remoteRef, putRef);
o = pushArgument(curBlk, o, q);
@@ -454,9 +455,9 @@ static int
free(buf);
if (!(buf = GDKmalloc(len))) {
- GDKfree(lname);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
buf[0] = 0;
@@ -477,10 +478,10 @@ static int
len = (len + nlen) * 2;
char *tmp = GDKrealloc(buf, len);
if (tmp == NULL) {
- GDKfree(lname);
GDKfree(buf);
sql_error(m, 10, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
buf = tmp;
}
@@ -502,11 +503,11 @@ static int
str next = sql_subtype_string(m->ta, t);
if (!next) {
- GDKfree(lname);
GDKfree(buf);
sa_reset(m->ta);
sql_error(m, 10, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
size_t nlen = strlen(next) + 2;
@@ -514,11 +515,11 @@ static int
len = (len + nlen) * 2;
char *tmp = GDKrealloc(buf, len);
if (tmp == NULL) {
- GDKfree(lname);
GDKfree(buf);
sa_reset(m->ta);
sql_error(m, 10, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
buf = tmp;
}
@@ -534,7 +535,6 @@ static int
p = pushArgument(curBlk, p, getArg(o,0));
pushInstruction(curBlk, p);
- char *mal_session_uuid, *err = NULL;
if (!GDKinmemory(0) && !GDKembedded() && (err =
msab_getUUID(&mal_session_uuid)) == NULL) {
str lsupervisor_session = GDKstrdup(mal_session_uuid);
str rsupervisor_session = GDKstrdup(mal_session_uuid);
@@ -543,7 +543,8 @@ static int
GDKfree(lsupervisor_session);
GDKfree(rsupervisor_session);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
str rworker_plan_uuid = generateUUID();
@@ -551,7 +552,8 @@ static int
GDKfree(rsupervisor_session);
GDKfree(lsupervisor_session);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
str lworker_plan_uuid = GDKstrdup(rworker_plan_uuid);
if (lworker_plan_uuid == NULL) {
@@ -559,7 +561,8 @@ static int
GDKfree(lsupervisor_session);
GDKfree(rsupervisor_session);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
- return -1;
+ res = -1;
+ goto cleanup;
}
/* remote.supervisor_register(connection, supervisor_uuid,
plan_uuid) */
@@ -713,8 +716,9 @@ static int
res = -1;
}
+cleanup:
GDKfree(lname); /* make sure stub is called */
- if (res < 0) {
+ if (res < 0 && c->curprg) {
if (!added_to_cache) /* on error, remove generated symbol from
cache */
freeSymbol(c->curprg);
else
@@ -921,7 +925,7 @@ backend_dumpproc(backend *be, Client c,
// restore the context for the wrapper code
cleanup:
- if (res < 0) {
+ if (res < 0 && c->curprg) {
if (!added_to_cache)
freeSymbol(c->curprg);
else
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -973,6 +973,7 @@ SQLparser(Client c)
c->mode = FINISHCLIENT;
throw(SQL, "SQLparser", SQLSTATE(42000) "State descriptor
missing, aborting");
}
+ assert(c->curprg && c->curprg->def);
oldvid = c->curprg->def->vid;
oldvtop = c->curprg->def->vtop;
oldstop = c->curprg->def->stop;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]