Changeset: 9afa6be2a50e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9afa6be2a50e
Modified Files:
sql/backends/monet5/sql_gencode.c
Branch: Jun2016
Log Message:
more cleanup after failures.
diffs (103 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
@@ -425,7 +425,7 @@ static int
backend *be = (backend *) c->sqlcontext;
MalBlkPtr curBlk = 0;
InstrPtr curInstr = 0;
- Symbol backup = NULL;
+ Symbol backup = NULL, curPrg = NULL;
stmt *s;
int old_argc = be->mvc->argc;
@@ -445,7 +445,7 @@ static int
s = stmt_return(m->sa, s, 0);
backup = c->curprg;
- c->curprg = newFunction(putName(mod), putName(name), FUNCTIONsymbol);
+ curPrg = c->curprg = newFunction(putName(mod), putName(name),
FUNCTIONsymbol);
curBlk = c->curprg->def;
curInstr = getInstrPtr(curBlk, 0);
@@ -477,12 +477,16 @@ static int
}
be->mvc->argc = 0;
- if (backend_dumpstmt(be, curBlk, s, 0, 1) < 0)
+ if (backend_dumpstmt(be, curBlk, s, 0, 1) < 0) {
+ freeSymbol(curPrg);
+ if (backup)
+ c->curprg = backup;
return -1;
+ }
be->mvc->argc = old_argc;
/* SQL function definitions meant for inlineing should not be optimized
before */
if (inline_func)
- curBlk->inlineProp =1;
+ curBlk->inlineProp = 1;
addQueryToCache(c);
if (backup)
c->curprg = backup;
@@ -3047,10 +3051,10 @@ backend_create_sql_func(backend *be, sql
{
mvc *m = be->mvc;
sql_schema *schema = m->session->schema;
- MalBlkPtr curBlk = 0;
- InstrPtr curInstr = 0;
+ MalBlkPtr curBlk = NULL;
+ InstrPtr curInstr = NULL;
Client c = be->client;
- Symbol backup = NULL;
+ Symbol backup = NULL, curPrg = NULL;
stmt *s;
int i, retseen = 0, sideeffects = 0, vararg = (f->varres || f->vararg);
sql_allocator *sa;
@@ -3078,7 +3082,7 @@ backend_create_sql_func(backend *be, sql
assert(s);
backup = c->curprg;
- c->curprg = newFunction(userRef, putName(f->base.name), FUNCTIONsymbol);
+ curPrg = c->curprg = newFunction(userRef, putName(f->base.name),
FUNCTIONsymbol);
curBlk = c->curprg->def;
curInstr = getInstrPtr(curBlk, 0);
@@ -3120,10 +3124,8 @@ backend_create_sql_func(backend *be, sql
int varid = 0;
char *buf = GDKmalloc(MAXIDENTLEN);
- if (buf == NULL) {
- sa_destroy(sa);
- return -1;
- }
+ if (buf == NULL)
+ goto cleanup;
if (a->name)
(void) snprintf(buf, MAXIDENTLEN, "A%s",
a->name);
else
@@ -3136,10 +3138,8 @@ backend_create_sql_func(backend *be, sql
}
/* announce the transaction mode */
- if (backend_dumpstmt(be, curBlk, s, 0, 1) < 0) {
- sa_destroy(sa);
- return -1;
- }
+ if (backend_dumpstmt(be, curBlk, s, 0, 1) < 0)
+ goto cleanup;
/* selectively make functions available for inlineing */
/* for the time being we only inline scalar functions */
/* and only if we see a single return value */
@@ -3162,6 +3162,13 @@ backend_create_sql_func(backend *be, sql
if (backup)
c->curprg = backup;
return 0;
+cleanup:
+ freeSymbol(curPrg);
+ sa_destroy(sa);
+ if (backup)
+ c->curprg = backup;
+ return -1;
+
}
/* TODO handle aggr */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list