Changeset: 544b35d05740 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=544b35d05740 Modified Files: clients/Tests/exports.stable.out monetdb5/mal/mal.h monetdb5/mal/mal_instruction.c monetdb5/mal/mal_instruction.h monetdb5/mal/mal_listing.c monetdb5/mal/mal_module.c monetdb5/mal/mal_module.h monetdb5/mal/mal_parser.c monetdb5/optimizer/opt_profiler.c sql/backends/monet5/sql_scenario.c Branch: mosaic Log Message:
Merge with default diffs (267 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 @@ -2150,7 +2150,6 @@ str exportOperationRef; str export_tableRef; str fcnDefinition(MalBlkPtr mb, InstrPtr p, str s, int flg, str base, size_t len); int findGDKtype(int type); -int findInstruction(Module scope, MalBlkPtr mb, InstrPtr pci); Module findModule(Module scope, str name); str findRef; Scenario findScenario(str nme); diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h --- a/monetdb5/mal/mal.h +++ b/monetdb5/mal/mal.h @@ -151,7 +151,7 @@ typedef struct VARRECORD { int eolife; /* pc index when it should be garbage collected */ int depth; /* scope block depth, set to -1 if not used */ int worker; /* thread id of last worker producing it */ - str stc; /* rendering schema.table.column */ + char stc[2* IDLENGTH]; /* rendering schema.table.column, with little more space */ BUN rowcnt; /* estimated row count*/ } *VarPtr, VarRecord; @@ -181,14 +181,14 @@ typedef struct { lng rbytes; /* accumulated number of bytes read, currently ignored */ lng wbytes; /* accumulated number of bytes produced */ /* the core admin */ - str modname; /* module context */ - str fcnname; /* function name */ + str modname; /* module context, reference into namespace */ + str fcnname; /* function name, reference into namespace */ int argc, retc, maxarg; /* total and result argument count */ int argv[FLEXIBLE_ARRAY_MEMBER]; /* at least a few entries */ } *InstrPtr, InstrRecord; typedef struct MALBLK { - str binding; /* related C-function */ + char binding[IDLENGTH]; /* related C-function */ str help; /* supportive commentary */ oid tag; /* unique block tag */ struct MALBLK *alternative; diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c --- a/monetdb5/mal/mal_instruction.c +++ b/monetdb5/mal/mal_instruction.c @@ -120,7 +120,8 @@ newMalBlk(int maxvars, int maxstmts) mb->vtop = 0; mb->vid = 0; mb->vsize = maxvars; - mb->help = mb->binding = NULL; + mb->help = NULL; + mb->binding[0] = 0; mb->tag = 0; mb->errors = 0; mb->alternative = NULL; @@ -215,9 +216,7 @@ freeMalBlk(MalBlkPtr mb) if (mb->history) freeMalBlk(mb->history); - if (mb->binding) - GDKfree(mb->binding); - mb->binding = 0; + mb->binding[0] = 0; mb->tag = 0; if (mb->help) GDKfree(mb->help); @@ -282,7 +281,7 @@ copyMalBlk(MalBlkPtr old) mb->stmt[i] = copyInstruction(old->stmt[i]); mb->help = old->help ? GDKstrdup(old->help) : NULL; - mb->binding = old->binding ? GDKstrdup(old->binding) : NULL; + strncpy(mb->binding, old->binding, IDLENGTH); mb->errors = old->errors; mb->tag = old->tag; mb->typefixed = old->typefixed; @@ -816,8 +815,7 @@ cloneVariable(MalBlkPtr tm, MalBlkPtr mb setVarUDFtype(tm, res); if (isVarCleanup(mb, x)) setVarCleanup(tm, res); - if ( getSTC(mb,x) ) - setSTC(mb,x, getSTC(mb,x)); + strncpy(getSTC(tm,x),getSTC(mb,x), 2 *IDLENGTH); return res; } @@ -876,15 +874,13 @@ clearVariable(MalBlkPtr mb, int varid) v = getVar(mb, varid); if (v == 0) return; - if (v->stc) - GDKfree(v->stc); if (isVarConstant(mb, varid) || isVarDisabled(mb, varid)) VALclear(&v->value); v->type = 0; v->flags = 0; v->rowcnt = 0; v->eolife = 0; - v->stc = 0; + v->stc[0] = 0; } void diff --git a/monetdb5/mal/mal_instruction.h b/monetdb5/mal/mal_instruction.h --- a/monetdb5/mal/mal_instruction.h +++ b/monetdb5/mal/mal_instruction.h @@ -101,7 +101,6 @@ #define getMitosisPartition(P) ((P)->mitosis) #define getSTC(M,I) ((M)->var[I]->stc) -#define setSTC(M,I,X) (M)->var[I]->stc =X #define getDestVar(P) (P)->argv[0] #define setDestVar(P,X) (P)->argv[0] =X diff --git a/monetdb5/mal/mal_listing.c b/monetdb5/mal/mal_listing.c --- a/monetdb5/mal/mal_listing.c +++ b/monetdb5/mal/mal_listing.c @@ -198,7 +198,7 @@ fcnDefinition(MalBlkPtr mb, InstrPtr p, if(t < base + len) *t++ = ')'; } - if (mb->binding) + if (mb->binding[0]) snprintf(t,(len-(t-base))," address %s;", mb->binding); else if( t <base + len) sprintf(t, ";"); diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c --- a/monetdb5/mal/mal_module.c +++ b/monetdb5/mal/mal_module.c @@ -288,26 +288,3 @@ Symbol findSymbol(Module nspace, str mod return findSymbolInModule(m,fcn); } -int -findInstruction(Module scope, MalBlkPtr mb, InstrPtr pci){ - Module m; - Symbol s; - int i,fnd; - - for(m= findModule(scope,getModuleId(pci)); m; m= m->link) - if( m->name == getModuleId(pci) ) { - s= m->space[(int)(getSymbolIndex(getFunctionId(pci)))]; - for(; s; s= s->peer) - if( getFunctionId(pci)==s->name && pci->argc == getSignature(s)->argc ){ - /* found it check argtypes */ - for( fnd=1, i = 0; i < pci->argc; i++) - if ( getArgType(mb,pci,i) != getArgType(s->def,getSignature(s),i)) - fnd = 0; - if( fnd) - return 1; - } - } - - return 0; -} - diff --git a/monetdb5/mal/mal_module.h b/monetdb5/mal/mal_module.h --- a/monetdb5/mal/mal_module.h +++ b/monetdb5/mal/mal_module.h @@ -36,7 +36,6 @@ mal_export Module findModule(Module sc mal_export Symbol findSymbol(Module nspace, str mod, str fcn); mal_export int isModuleDefined(Module scope, str name); mal_export Symbol findSymbolInModule(Module v, str fcn); -mal_export int findInstruction(Module scope, MalBlkPtr mb, InstrPtr pci); #define getSymbolIndex(N) (int)(*(N)) 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 @@ -171,8 +171,6 @@ idCopy(Client cntxt, int length) memcpy(s, CURRENT(cntxt), (size_t) length); s[length] = 0; /* avoid a clash with old temporaries */ - if (s[0] == TMPMARKER) - s[0] = REFMARKER; advance(cntxt, length); return s; } @@ -1314,7 +1312,6 @@ parseCommandPattern(Client cntxt, int ki * [note, command and patterns do not have a MAL block] */ if (MALkeyword(cntxt, "address", 7)) { - str nme; int i; i = idLength(cntxt); if (i == 0) { @@ -1322,13 +1319,17 @@ parseCommandPattern(Client cntxt, int ki return 0; } cntxt->blkmode = 0; - nme = idCopy(cntxt, i); if (getModuleId(curInstr)) setModuleId(curInstr, NULL); setModuleScope(curInstr, findModule(cntxt->nspace, modnme)); - curInstr->fcn = getAddress(cntxt->fdout, cntxt->srcFile, nme, 0); - curBlk->binding = nme; + + memcpy(curBlk->binding, CURRENT(cntxt), (size_t)(i < IDLENGTH? i:IDLENGTH-1)); + curBlk->binding[(i< IDLENGTH? i:IDLENGTH-1)] = 0; + /* avoid a clash with old temporaries */ + advance(cntxt, i); + curInstr->fcn = getAddress(cntxt->fdout, cntxt->srcFile, curBlk->binding, 0); + if (cntxt->nspace->isAtomModule) { if (curInstr->fcn == NULL) { parseError(cntxt, "<address> not found\n"); diff --git a/monetdb5/optimizer/opt_profiler.c b/monetdb5/optimizer/opt_profiler.c --- a/monetdb5/optimizer/opt_profiler.c +++ b/monetdb5/optimizer/opt_profiler.c @@ -69,36 +69,34 @@ OPTprofilerImplementation(Client cntxt, continue; if( getModuleId(p)== sqlRef && getFunctionId(p)== bindRef){ // we know the arguments are constant - snprintf(buf, BUFSIZ, "%s.%s.%s", + snprintf(getSTC(mb,getArg(p,0)), 2 * IDLENGTH, "%s.%s.%s", getVarConstant(mb, getArg(p,p->retc +1)).val.sval, getVarConstant(mb, getArg(p,p->retc +2)).val.sval, getVarConstant(mb, getArg(p,p->retc +3)).val.sval); - setSTC(mb, getArg(p,0),GDKstrdup(buf)); } else if( getModuleId(p)== sqlRef && getFunctionId(p)== tidRef){ // we know the arguments are constant - snprintf(buf, BUFSIZ, "%s.%s", + snprintf(getSTC(mb,getArg(p,0)), 2 * IDLENGTH, "%s.%s", getVarConstant(mb, getArg(p,2)).val.sval, getVarConstant(mb, getArg(p,3)).val.sval); - setSTC(mb, getArg(p,0),GDKstrdup(buf)); } else if( getModuleId(p)== sqlRef && getFunctionId(p)== projectdeltaRef){ // inherit property of first argument v = getSTC(mb,getArg(p,1)); if(v != NULL) - setSTC(mb, getArg(p,0),GDKstrdup(v)); + strncpy(getSTC(mb,getArg(p,0)),v, 2 * IDLENGTH); } else if( getModuleId(p)== algebraRef && getFunctionId(p)== projectionRef){ // inherit property of last argument v = getSTC(mb,getArg(p,p->argc-1)); if( v != NULL) - setSTC(mb, getArg(p,0), GDKstrdup(v)); + strncpy(getSTC(mb,getArg(p,0)),v, 2 * IDLENGTH); } else if( getModuleId(p)== algebraRef && getFunctionId(p)== subjoinRef){ // inherit property of last argument v = getSTC(mb,getArg(p,p->argc-1) ); if( v != NULL) - setSTC(mb, getArg(p,0), GDKstrdup(v)); + strncpy(getSTC(mb,getArg(p,0)),v, 2 * IDLENGTH); } } /* Defense line against incorrect plans */ 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 @@ -189,10 +189,12 @@ SQLepilogue(void *ret) str res; (void) ret; + MT_lock_set(&sql_contextLock); if (SQLinitialized) { mvc_exit(); SQLinitialized = FALSE; } + MT_lock_unset(&sql_contextLock); /* this function is never called, but for the style of it, we clean * up our own mess */ res = msab_retreatScenario(m); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list