Changeset: dda2dd676884 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dda2dd676884 Modified Files: clients/Tests/exports.stable.out monetdb5/mal/mal_client.c monetdb5/mal/mal_parser.c monetdb5/mal/mal_session.c sql/backends/monet5/sql_execute.c sql/backends/monet5/sql_scenario.c sql/storage/store.c Branch: default Log Message:
merged with Dec2016 diffs (263 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -1177,7 +1177,7 @@ str INETnetmask(inet *retval, const inet str INETnetwork(inet *retval, const inet *val); str INETnew(inet *retval, str *in); inet *INETnull(void); -str INETsetmasklen(inet *retval, const inet *val, const int *mask); +str INETsetmasklen(inet *retval, const inet *val, const int *msk); str INETtext(str *retval, const inet *val); int INETtoString(str *retval, int *len, const inet *handle); str INSPECTatom_names(bat *ret); diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c --- a/monetdb5/mal/mal_client.c +++ b/monetdb5/mal/mal_client.c @@ -50,15 +50,6 @@ #include "mal_runtime.h" #include "mal_authorize.h" -/* - * This should be in src/mal/mal.h, as the function is implemented in - * src/mal/mal.c; however, it cannot, as "Client" isn't known there ... - * |-( For now, we move the prototype here, as it it only used here. - * Maybe, we should consider also moving the implementation here... - */ - -static void freeClient(Client c); - int MAL_MAXCLIENTS = 0; ClientRec *mal_clients; @@ -356,7 +347,7 @@ MCforkClient(Client father) * effects of sharing IO descriptors, also its children. Conversely, a * child can not close a parent. */ -void +static void freeClient(Client c) { Thread t = c->mythread; diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c --- a/monetdb5/mal/mal_parser.c +++ b/monetdb5/mal/mal_parser.c @@ -1099,6 +1099,7 @@ fcnHeader(Client cntxt, int kind) } advance(cntxt, 1); + assert(!cntxt->backup); cntxt->backup = cntxt->curprg; cntxt->curprg = newFunction( modnme, fnme, kind); curPrg = cntxt->curprg; @@ -1135,6 +1136,11 @@ fcnHeader(Client cntxt, int kind) } if (currChar(cntxt) != ')') { freeInstruction(curInstr); + if (cntxt->backup) { + freeSymbol(cntxt->curprg); + cntxt->curprg = cntxt->backup; + cntxt->backup = 0; + } parseError(cntxt, "')' expected\n"); skipToEnd(cntxt); return curBlk; @@ -1172,6 +1178,11 @@ fcnHeader(Client cntxt, int kind) if ((ch = currChar(cntxt)) != ',') { if (ch == ')') break; + if (cntxt->backup) { + freeSymbol(cntxt->curprg); + cntxt->curprg = cntxt->backup; + cntxt->backup = 0; + } parseError(cntxt, "',' expected\n"); skipToEnd(cntxt); return curBlk; @@ -1186,6 +1197,11 @@ fcnHeader(Client cntxt, int kind) newarg = (short *) GDKmalloc(max * sizeof(curInstr->argv[0])); if (newarg == NULL){ parseError(cntxt, MAL_MALLOC_FAIL); + if (cntxt->backup) { + freeSymbol(cntxt->curprg); + cntxt->curprg = cntxt->backup; + cntxt->backup = 0; + } skipToEnd(cntxt); return curBlk; } @@ -1295,8 +1311,12 @@ parseCommandPattern(Client cntxt, int ki modnme = putNameLen(modnme, l); if (isModuleDefined(cntxt->nspace, modnme)) insertSymbol(findModule(cntxt->nspace, modnme), curPrg); - else + else { + freeSymbol(curPrg); + cntxt->curprg = cntxt->backup; + cntxt->backup = 0; return (MalBlkPtr) parseError(cntxt, "<module> not found\n"); + } chkProgram(cntxt->fdout, cntxt->nspace, curBlk); if (cntxt->backup) { cntxt->curprg = cntxt->backup; diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c --- a/monetdb5/mal/mal_session.c +++ b/monetdb5/mal/mal_session.c @@ -468,8 +468,19 @@ MSserveClient(void *dummy) /* * At this stage we should clean out the MAL block */ - freeMalBlk(c->curprg->def); - c->curprg->def = 0; + if (c->backup) { + assert(0); + freeSymbol(c->backup); + c->backup = 0; + } + if (c->curprg) { + assert(0); + freeSymbol(c->curprg); + c->curprg = 0; + } + if (c->nspace) { + assert(0); + } if (c->mode > FINISHCLIENT) { if (isAdministrator(c) /* && moreClients(0)==0 */) { @@ -480,7 +491,7 @@ MSserveClient(void *dummy) } if (!isAdministrator(c)) MCcloseClient(c); - if (strcmp(c->nspace->name, "user") == 0) { + if (c->nspace && strcmp(c->nspace->name, "user") == 0) { GDKfree(c->nspace->space); GDKfree(c->nspace); c->nspace = NULL; @@ -514,6 +525,17 @@ MALexitClient(Client c) if (c->bak) return NULL; c->mode = FINISHCLIENT; + if (c->backup) { + assert(0); + freeSymbol(c->backup); + c->backup = NULL; + } + /* should be in the nspace */ + c->curprg = NULL; + if (c->nspace) { + freeModule(c->nspace); + c->nspace = NULL; + } return NULL; } diff --git a/sql/backends/monet5/sql_execute.c b/sql/backends/monet5/sql_execute.c --- a/sql/backends/monet5/sql_execute.c +++ b/sql/backends/monet5/sql_execute.c @@ -482,9 +482,7 @@ SQLstatementIntern(Client c, str *expr, mnstr_printf(c->fdout, "#SQLstatement:post-compile\n"); printFunction(c->fdout, c->curprg->def, 0, LIST_MAL_NAME | LIST_MAL_VALUE | LIST_MAL_MAPI); #endif - /* always keep it around for inspection */ - SQLaddQueryToCache(c); - msg =SQLoptimizeFunction(c,c->curprg->def); + msg =SQLoptimizeFunction(c, c->curprg->def); if( msg) goto endofcompile; 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 @@ -1187,9 +1187,6 @@ SQLCacheRemove(Client c, str nme) s = findSymbolInModule(c->nspace, nme); if (s == NULL) throw(MAL, "cache.remove", "internal error, symbol missing\n"); - if (getInstrPtr(s->def, 0)->token == FACTORYsymbol) - shutdownFactoryByName(c, c->nspace, nme); - else - deleteSymbol(c->nspace, s); + deleteSymbol(c->nspace, s); return MAL_SUCCEED; } diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -471,21 +471,18 @@ load_trigger(sql_trans *tr, sql_table *t v = table_funcs.column_find_value(tr, find_sql_column(triggers, "event"), rid); nt->event = *(sht*)v; _DELETE(v); - nt->old_name = table_funcs.column_find_value(tr, find_sql_column(triggers, "old_name"), rid); - if (ATOMcmp(TYPE_str, ATOMnilptr(TYPE_str), nt->old_name) != 0) { - _DELETE(nt->old_name); - nt->old_name = NULL; - } - nt->new_name = table_funcs.column_find_value(tr, find_sql_column(triggers, "new_name"), rid); - if (ATOMcmp(TYPE_str, ATOMnilptr(TYPE_str), nt->new_name) != 0) { - _DELETE(nt->new_name); - nt->new_name = NULL; - } - nt->condition = table_funcs.column_find_value(tr, find_sql_column(triggers, "condition"), rid); - if (ATOMcmp(TYPE_str, ATOMnilptr(TYPE_str), nt->condition) != 0) { - _DELETE(nt->condition); - nt->condition = NULL; - } + v = table_funcs.column_find_value(tr, find_sql_column(triggers, "old_name"), rid); + if (ATOMcmp(TYPE_str, ATOMnilptr(TYPE_str), v) != 0) + nt->old_name = sa_strdup(tr->sa, v); + _DELETE(v); + v = table_funcs.column_find_value(tr, find_sql_column(triggers, "new_name"), rid); + if (ATOMcmp(TYPE_str, ATOMnilptr(TYPE_str), v) != 0) + nt->new_name = sa_strdup(tr->sa, v); + _DELETE(v); + v = table_funcs.column_find_value(tr, find_sql_column(triggers, "condition"), rid); + if (ATOMcmp(TYPE_str, ATOMnilptr(TYPE_str), v) != 0) + nt->condition = sa_strdup(tr->sa, v); + _DELETE(v); nt->statement = table_funcs.column_find_value(tr, find_sql_column(triggers, "statement"), rid); nt->t = t; @@ -536,9 +533,8 @@ load_column(sql_trans *tr, sql_table *t, c->def = NULL; def = table_funcs.column_find_value(tr, find_sql_column(columns, "default"), rid); if (ATOMcmp(TYPE_str, ATOMnilptr(TYPE_str), def) != 0) - c->def = def; - else - _DELETE(def); + c->def = sa_strdup(tr->sa, def); + _DELETE(def); v = table_funcs.column_find_value(tr, find_sql_column(columns, "null"), rid); c->null = *(bit *)v; _DELETE(v); v = table_funcs.column_find_value(tr, find_sql_column(columns, "number"), rid); @@ -547,9 +543,8 @@ load_column(sql_trans *tr, sql_table *t, c->storage_type = NULL; st = table_funcs.column_find_value(tr, find_sql_column(columns, "storage"), rid); if (ATOMcmp(TYPE_str, ATOMnilptr(TYPE_str), st) != 0) - c->storage_type = st; - else - _DELETE(st); + c->storage_type = sa_strdup(tr->sa, st); + _DELETE(st); c->t = t; if (isTable(c->t)) store_funcs.create_col(tr, c); @@ -4789,13 +4784,16 @@ sql_trans_ranges( sql_trans *tr, sql_col sql_column *stats_column_id = find_sql_column(stats, "column_id"); oid rid = table_funcs.column_find_row(tr, stats_column_id, &col->base.id, NULL); if (rid != oid_nil) { + char *v; sql_column *stats_min = find_sql_column(stats, "minval"); sql_column *stats_max = find_sql_column(stats, "maxval"); - *min = table_funcs.column_find_value(tr, stats_min, rid); - *max = table_funcs.column_find_value(tr, stats_max, rid); - col->min = *min; - col->max = *max; + v = table_funcs.column_find_value(tr, stats_min, rid); + *min = col->min = sa_strdup(tr->sa, v); + _DELETE(v); + v = table_funcs.column_find_value(tr, stats_max, rid); + *max = col->max = sa_strdup(tr->sa, v); + _DELETE(v); return 1; } } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list