Changeset: edf8c65d73c9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/edf8c65d73c9
Modified Files:
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_scenario.c
Branch: Jul2021
Log Message:

more curprg resets


diffs (182 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
@@ -327,7 +327,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) {
@@ -372,6 +372,7 @@ static int
        if( c->curprg == NULL) {
                GDKfree(lname);
                sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
+               c->curprg = backup;
                return -1;
        }
        lname[0] = 'l';
@@ -380,9 +381,9 @@ static int
 
        curInstr = relational_func_create_result(m, curBlk, curInstr, rel);
        if( curInstr == NULL) {
-               GDKfree(lname);
                sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
-               return -1;
+               res = -1;
+               goto cleanup;
        }
 
        /* ops */
@@ -397,9 +398,9 @@ static int
 
                        sprintf(nbuf, "A%d", i++);
                        if ((varid = newVariable(curBlk, nbuf, strlen(nbuf), 
type)) < 0) {
-                               GDKfree(lname);
                                sql_error(m, 003, 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);
@@ -448,9 +449,9 @@ static int
        p = pushArgument(curBlk, p, getArg(o,0));
 
        if (!(buf = rel2str(m, rel))) {
-               GDKfree(lname);
                sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
-               return -1;
+               res = -1;
+               goto cleanup;
        }
        o = newFcnCall(curBlk, remoteRef, putRef);
        o = pushArgument(curBlk, o, q);
@@ -459,9 +460,9 @@ static int
        free(buf);
 
        if (!(buf = GDKmalloc(len))) {
-               GDKfree(lname);
                sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
-               return -1;
+               res = -1;
+               goto cleanup;
        }
 
        buf[0] = 0;
@@ -482,10 +483,10 @@ static int
                                len = (len + nlen) * 2;
                                char *tmp = GDKrealloc(buf, len);
                                if (tmp == NULL) {
-                                       GDKfree(lname);
                                        GDKfree(buf);
                                        sql_error(m, 001, SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-                                       return -1;
+                                       res = -1;
+                                       goto cleanup;
                                }
                                buf = tmp;
                        }
@@ -507,11 +508,11 @@ static int
                        str next = sql_subtype_string(m->ta, t);
 
                        if (!next) {
-                               GDKfree(lname);
                                GDKfree(buf);
                                sa_reset(m->ta);
                                sql_error(m, 001, SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-                               return -1;
+                               res = -1;
+                               goto cleanup;
                        }
 
                        size_t nlen = strlen(next) + 2;
@@ -519,11 +520,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, 001, SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-                                       return -1;
+                                       res = -1;
+                                       goto cleanup;
                                }
                                buf = tmp;
                        }
@@ -539,7 +540,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);
@@ -548,7 +548,8 @@ static int
                        GDKfree(lsupervisor_session);
                        GDKfree(rsupervisor_session);
                        sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
-                       return -1;
+                       res = -1;
+                       goto cleanup;
                }
 
                str rworker_plan_uuid = generateUUID();
@@ -556,7 +557,8 @@ static int
                        GDKfree(rsupervisor_session);
                        GDKfree(lsupervisor_session);
                        sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
-                       return -1;
+                       res = -1;
+                       goto cleanup;
                }
                str lworker_plan_uuid = GDKstrdup(rworker_plan_uuid);
                if (lworker_plan_uuid == NULL) {
@@ -564,7 +566,8 @@ static int
                        GDKfree(lsupervisor_session);
                        GDKfree(rsupervisor_session);
                        sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
-                       return -1;
+                       res = -1;
+                       goto cleanup;
                }
 
                /* remote.supervisor_register(connection, supervisor_uuid, 
plan_uuid) */
@@ -716,6 +719,7 @@ static int
                res = -1;
        }
 
+cleanup:
        GDKfree(lname); /* make sure stub is called */
        if (res < 0) {
                if (!added_to_cache) /* on error, remove generated symbol from 
cache */
@@ -868,6 +872,7 @@ backend_dumpproc(backend *be, Client c, 
        if (c->curprg == NULL) {
                sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
                res = -1;
+               c->curprg = symbackup;
                goto cleanup;
        }
 
@@ -1250,6 +1255,7 @@ backend_create_sql_func(backend *be, sql
        if (c->curprg == NULL) {
                sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
                res = -1;
+               c->curprg = symbackup;
                goto cleanup;
        }
 
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
@@ -980,6 +980,7 @@ SQLparser(Client c)
                c->mode = FINISHCLIENT;
                throw(SQL, "SQLparser", SQLSTATE(42000) "State descriptor 
missing, aborting");
        }
+       assert(c->curprg && c->curprg->def && c->curprg->def > 0x100);
        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]

Reply via email to