Changeset: ef39c0c0521c for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ef39c0c0521c Modified Files: sql/backends/monet5/sql_gencode.c Branch: default Log Message:
merged with jun2016 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 @@ -423,7 +423,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; @@ -443,7 +443,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); @@ -475,12 +475,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; @@ -3084,10 +3088,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), no_inline = 0; sql_allocator *sa; @@ -3115,7 +3119,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); @@ -3157,10 +3161,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 @@ -3173,10 +3175,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 */ @@ -3200,6 +3200,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 checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list