Changeset: 74c2ba209138 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=74c2ba209138
Modified Files:
monetdb5/extras/mal_optimizer_template/opt_sql_append.c
monetdb5/mal/mal.c
monetdb5/mal/mal_client.c
monetdb5/mal/mal_client.h
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_import.c
monetdb5/mal/mal_module.c
monetdb5/mal/mal_module.h
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_private.h
monetdb5/mal/mal_session.c
monetdb5/modules/atoms/uuid.c
monetdb5/modules/mal/factories.c
monetdb5/modules/mal/inspect.c
monetdb5/modules/mal/language.c
monetdb5/modules/mal/language.mal
monetdb5/modules/mal/manifold.c
monetdb5/modules/mal/manual.c
monetdb5/modules/mal/mdb.c
monetdb5/modules/mal/orderidx.c
monetdb5/modules/mal/remote.c
monetdb5/optimizer/opt_aliases.c
monetdb5/optimizer/opt_coercion.c
monetdb5/optimizer/opt_commonTerms.c
monetdb5/optimizer/opt_constants.c
monetdb5/optimizer/opt_costModel.c
monetdb5/optimizer/opt_dataflow.c
monetdb5/optimizer/opt_deadcode.c
monetdb5/optimizer/opt_emptybind.c
monetdb5/optimizer/opt_evaluate.c
monetdb5/optimizer/opt_garbageCollector.c
monetdb5/optimizer/opt_generator.c
monetdb5/optimizer/opt_inline.c
monetdb5/optimizer/opt_jit.c
monetdb5/optimizer/opt_json.c
monetdb5/optimizer/opt_macro.c
monetdb5/optimizer/opt_matpack.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_mitosis.c
monetdb5/optimizer/opt_multiplex.c
monetdb5/optimizer/opt_oltp.c
monetdb5/optimizer/opt_pipes.c
monetdb5/optimizer/opt_profiler.c
monetdb5/optimizer/opt_projectionpath.c
monetdb5/optimizer/opt_pushselect.c
monetdb5/optimizer/opt_querylog.c
monetdb5/optimizer/opt_reduce.c
monetdb5/optimizer/opt_remap.c
monetdb5/optimizer/opt_remoteQueries.c
monetdb5/optimizer/opt_reorder.c
monetdb5/optimizer/opt_support.c
monetdb5/optimizer/opt_volcano.c
monetdb5/optimizer/opt_wrapper.c
monetdb5/optimizer/optimizer.c
monetdb5/scheduler/run_adder.c
monetdb5/scheduler/run_pipeline.c
monetdb5/scheduler/srvpool.c
sql/backends/monet5/sql_execute.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_scenario.c
Branch: malparsing
Log Message:
Name change nspace ->usermodule
Mostly separating out the user module from the global modules.
diffs (truncated from 2020 to 300 lines):
diff --git a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
--- a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
+++ b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
@@ -276,7 +276,7 @@ str OPTsql_append(Client cntxt, MalBlkPt
modnme= getArgDefault(mb,p,1);
fcnnme= getArgDefault(mb,p,2);
}
- s= findSymbol(cntxt->nspace, putName(modnme),putName(fcnnme));
+ s= findSymbol(cntxt->usermodule,
putName(modnme),putName(fcnnme));
if( s == NULL) {
char buf[1024];
@@ -294,7 +294,7 @@ str OPTsql_append(Client cntxt, MalBlkPt
actions= OPTsql_appendImplementation(cntxt, mb,stk,p);
/* Defense line against incorrect plans */
- chkTypes(cntxt->nspace, mb, FALSE);
+ chkTypes(cntxt->usermodule, mb, FALSE);
chkFlow(mb);
chkDeclarations(mb);
/* the mb->errors will be set to the first error encountered */
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -144,17 +144,25 @@ void mserver_reset(int exit)
mal_dataflow_reset();
THRdel(mal_clients->mythread);
GDKfree(mal_clients->errbuf);
- mal_clients->fdin->s = NULL;
bstream_destroy(mal_clients->fdin);
+ mal_clients->fdin = 0;
GDKfree(mal_clients->prompt);
+ mal_clients->prompt = 0;
GDKfree(mal_clients->username);
+ mal_clients->username = 0;
freeStack(mal_clients->glb);
+ mal_clients->glb = 0;
freeSymbol(mal_clients->curprg);
+ mal_clients->curprg = 0;
+ if( mal_clients->usermodule &&
strcmp(mal_clients->usermodule->name,"user")==0)
+ freeModule(mal_clients->usermodule);
+ mal_clients->usermodule = 0;
mal_client_reset();
mal_linker_reset();
mal_resource_reset();
mal_runtime_reset();
mal_module_reset();
+ mdbExit();
memset((char*)monet_cwd,0, sizeof(monet_cwd));
monet_memory = 0;
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
@@ -200,7 +200,6 @@ MCinitClientRecord(Client c, oid user, b
c->username = 0;
c->scenario = NULL;
c->oldscenario = NULL;
- c->srcFile = NULL;
c->blkmode = 0;
c->fdin = fin ? fin : bstream_create(GDKin, 0);
@@ -221,10 +220,7 @@ MCinitClientRecord(Client c, oid user, b
/* remove garbage from previous connection
* be aware, a user can introduce several modules
* that should be freed to avoid memory leaks */
- if (c->nspace) {
- freeModule(c->nspace);
- c->nspace = 0;
- }
+ c->usermodule = c->curmodule = 0;
c->father = NULL;
c->login = c->lastcmd = time(0);
@@ -331,8 +327,8 @@ MCforkClient(Client father)
son->prompt = GDKstrdup(father->prompt);
son->promptlength = strlen(father->prompt);
/* reuse the scopes wherever possible */
- if (son->nspace == 0)
- son->nspace = newModule(NULL, putName("child"));
+ if (son->usermodule == 0)
+ son->usermodule = userModule();
}
return son;
}
@@ -376,6 +372,9 @@ freeClient(Client c)
GDKfree(c->errbuf);
c->errbuf = 0;
}
+ if (c->usermodule)
+ freeModule(c->usermodule);
+ c->usermodule = c->curmodule = 0;
c->father = 0;
c->login = c->lastcmd = 0;
//c->active = 0;
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -90,7 +90,6 @@ typedef struct CLIENT {
* It is perfectly legal to have a client without input stream.
* It will simply terminate after consuming the input buffer.
*/
- str srcFile; /* NULL for stdin, or file name */
bstream *fdin;
int yycur; /* the scanners current position */
str line;
@@ -146,7 +145,8 @@ typedef struct CLIENT {
* object space (the global variables). Moreover, the parser needs
* some administration variables to keep track of critical elements.
*/
- Module nspace; /* private user scope */
+ Module usermodule; /* private user scope */
+ Module curmodule; /* where to deliver the symbol,
used by parser , only freed globally */
Symbol curprg; /* container for the malparser */
MalStkPtr glb; /* global variable stack */
/*
diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -76,6 +76,12 @@ mdbInit(void)
}
}
+void
+mdbExit(void)
+{
+ GDKfree(mdbTable);
+ mdbTable = 0;
+}
static char
isBreakpoint(Client cntxt, MalBlkPtr mb, InstrPtr p, int pc)
{
@@ -139,7 +145,7 @@ mdbSetBreakRequest(Client cntxt, MalBlkP
modnme = request;
*fcnnme = 0;
fcnnme++;
- sym = findSymbol(cntxt->nspace, modnme, fcnnme);
+ sym = findSymbol(cntxt->usermodule, modnme, fcnnme);
mdb->brkBlock[mdb->brkTop] = sym ? sym->def : mb;
mdb->brkPc[mdb->brkTop] = -1;
mdb->brkVar[mdb->brkTop] = -1;
@@ -254,7 +260,7 @@ int
mdbSetTrap(Client cntxt, str modnme, str fcnnme, int flag)
{
Symbol s;
- s = findSymbol(cntxt->nspace, putName(modnme),
+ s = findSymbol(cntxt->usermodule, putName(modnme),
putName(fcnnme));
if (s == NULL)
return -1;
@@ -357,7 +363,7 @@ mdbLocateMalBlk(Client cntxt, MalBlkPtr
if( idx < 0)
return NULL;
}
- fsym = findSymbolInModule(findModule(cntxt->nspace,
putName(b)), fcnname + 1);
+ fsym = findSymbolInModule(findModule(cntxt->usermodule,
putName(b)), fcnname + 1);
*fcnname = '.';
if (h)
*h = '[';
@@ -376,7 +382,7 @@ static void
mdbCommand(Client cntxt, MalBlkPtr mb, MalStkPtr stkbase, InstrPtr p, int pc)
{
int m = 1;
- char *b, *c, lastcmd = 0;
+ char *b= 0, *c, lastcmd = 0;
stream *out = cntxt->fdout;
char *oldprompt = cntxt->prompt;
size_t oldpromptlength = cntxt->promptlength;
@@ -466,7 +472,7 @@ retryRead:
fcnnme = strchr(b,'.');
*fcnnme++ = 0;
- fs = findSymbol(cntxt->nspace,
putName(modnme),putName(fcnnme));
+ fs = findSymbol(cntxt->usermodule,
putName(modnme),putName(fcnnme));
if (fs == 0) {
mnstr_printf(out, "#'%s.%s' not
found\n", modnme,fcnnme);
continue;
@@ -474,7 +480,7 @@ retryRead:
for(; fs; fs = fs->peer){
for(i=0; i< fs->def->stop; i++)
fs->def->stmt[i]->typechk = TYPE_UNKNOWN;
- chkProgram(cntxt->nspace,
fs->def);
+ chkProgram(cntxt->usermodule,
fs->def);
}
} else
mnstr_printf(out, "#<modnme>.<fcnnme>
expected\n");
@@ -552,9 +558,9 @@ retryRead:
*fcnname = 0;
fcnname++;
}
- fsym = findModule(cntxt->nspace,
putName(modname));
+ fsym = findModule(cntxt->usermodule,
putName(modname));
- if (fsym == cntxt->nspace && strcmp(modname,
"user")) {
+ if (fsym == cntxt->usermodule &&
strcmp(modname, "user")) {
mnstr_printf(out, "#module '%s' not
found\n", modname);
continue;
}
@@ -570,7 +576,7 @@ retryRead:
Module* list;
int length;
int i;
- mnstr_printf(out,"#%s ",cntxt->nspace->name);
+ mnstr_printf(out,"#%s
",cntxt->usermodule->name);
getModuleList(&list, &length);
for(i = 0; i < length; i++) {
mnstr_printf(out, "%s ",
list[i]->name);
@@ -624,7 +630,7 @@ retryRead:
modname = b;
fcnname = strchr(b, '.');
if (fcnname == NULL) {
- fsym = findModule(cntxt->nspace,
putName(modname));
+ fsym = findModule(cntxt->usermodule,
putName(modname));
if (fsym == 0) {
mnstr_printf(out, "#%s module
not found\n", modname);
continue;
@@ -640,7 +646,7 @@ retryRead:
}
*fcnname = 0;
fcnname++;
- fsym = findModule(cntxt->nspace,
putName(modname));
+ fsym = findModule(cntxt->usermodule,
putName(modname));
if (fsym == 0) {
mnstr_printf(out, "#%s module not
found\n", modname);
continue;
@@ -890,7 +896,7 @@ retryRead:
fcnnme = strchr(b,'.');
*fcnnme++ = 0;
- fs = findSymbol(cntxt->nspace,
putName(modnme),putName(fcnnme));
+ fs = findSymbol(cntxt->usermodule,
putName(modnme),putName(fcnnme));
if (fs == 0) {
mnstr_printf(out, "#'%s' not
found\n", modnme);
continue;
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -91,12 +91,12 @@ evalFile(Client cntxt, str fname, int li
{
Client c;
stream *fd;
- str p, filename;
+ str p, filename, base;
str files[MAXMULTISCRIPT];
int cnt, i;
str msg = MAL_SUCCEED;
- fname = malResolveFile(fname);
+ base = fname = malResolveFile(fname);
if (fname == NULL)
throw(MAL,"mal.import", "#WARNING: could not open file: %s\n",
fname);
@@ -111,21 +111,27 @@ evalFile(Client cntxt, str fname, int li
files[cnt++]= filename;
}
for(i=0; i<cnt; i++){
-#ifdef _DEBUG_IMPORT_
- fprintf(stderr,"load file %s\n",files[i]);
-#endif
fd = malOpenSource(files[i]);
if (fd == 0 || mnstr_errnr(fd) == MNSTR_OPEN_ERROR) {
if(fd) mnstr_destroy(fd);
+ GDKfree(base);
throw(MAL,"mal.import", "#WARNING: could not open file:
%s\n", fname);
}
if( included){
- if( MCpushClientInput(cntxt, bstream_create(fd, 32 *
BLOCK), listing, ""))
+#ifdef _DEBUG_IMPORT_
+ fprintf(stderr,"include file %s\n",files[i]);
+#endif
+ if( MCpushClientInput(cntxt, bstream_create(fd, 32 *
BLOCK), listing, "")){
+ GDKfree(base);
throw(MAL,"mal.evalFile","Could not push the
input stream");
+ }
} else {
+#ifdef _DEBUG_IMPORT_
+ fprintf(stderr,"load file %s using new
client\n",files[i]);
+#endif
c = MCinitClient((oid)0,bstream_create(fd, 32 *
BLOCK),0);
- c->nspace = newModule(NULL, putName("user"));
+ c->usermodule = userModule();
GDKfree(c->prompt);
c->prompt= NULL;
c->promptlength = 0;
@@ -139,6 +145,7 @@ evalFile(Client cntxt, str fname, int li
MCcloseClient(c);
}
}
+ GDKfree(base);
return msg;
}
/*
@@ -192,7 +199,7 @@ compileString(Client cntxt, str s)
c = MCinitClient((oid)0,0,0);
c->fdin = bstream_create(buffer_rastream(b, "compileString"), b->len);
strncpy(c->fdin->buf,s,len);
- c->nspace = newModule(NULL, putName("user"));
+ c->usermodule = userModule();
GDKfree(c->prompt);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list