Changeset: 8838b170cfad for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8838b170cfad
Modified Files:
        monetdb5/mal/mal_debugger.c
        monetdb5/mal/mal_linker.c
        monetdb5/mal/mal_linker.h
        monetdb5/mal/mal_parser.c
        monetdb5/mal/mal_scenario.c
        monetdb5/optimizer/opt_pipes.c
        sql/backends/monet5/UDF/pyapi/pyheader.h
        sql/backends/monet5/sql_optimizer.c
        sql/backends/monet5/sql_statement.c
        sql/backends/monet5/vaults/vault.c
        tools/mserver/shutdowntest.c
Branch: malparsing
Log Message:

Chancing the interface of getAddress
Avoiding direct writes to stderr.
Dropping some showException calls.


diffs (truncated from 357 to 300 lines):

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
@@ -1308,7 +1308,7 @@ printBatDetails(stream *f, bat bid)
 
        /* at this level we don't know bat kernel primitives */
        mnstr_printf(f, "#Show info for %d\n", bid);
-       fcn = getAddress(f, "bat", "BKCinfo", 0);
+       fcn = getAddress("BKCinfo");
        if (fcn) {
                (*fcn)(&ret,&ret2, &bid);
                b[0] = BATdescriptor(ret);
@@ -1342,7 +1342,7 @@ printBatProperties(stream *f, VarPtr n, 
                BUN p;
 
                /* at this level we don't know bat kernel primitives */
-               fcn = getAddress(f, "bat", "BKCinfo", 0);
+               fcn = getAddress( "BKCinfo");
                if (fcn) {
                        BAT *b[2];
                        str res;
diff --git a/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c
--- a/monetdb5/mal/mal_linker.c
+++ b/monetdb5/mal/mal_linker.c
@@ -61,14 +61,13 @@ fileexists(const char *path)
 
 /* Search for occurrence of the function in the library identified by the 
filename.  */
 MALfcn
-getAddress(stream *out, str modname, str fcnname, int silent)
+getAddress(str fcnname)
 {
        void *dl;
        MALfcn adr;
        static int idx=0;
        static int prev= -1;
 
-       (void) out;
        /* First try the last module loaded */
        if( prev >= 0){
                adr = (MALfcn) dlsym(filesLoaded[prev].handle, fcnname);
@@ -99,26 +98,15 @@ getAddress(stream *out, str modname, str
         * the first argument must be the same as the base name of the
         * library that is created in src/tools */
        dl = mdlopen("libmonetdb5", RTLD_NOW | RTLD_GLOBAL);
-       if (dl == NULL) {
-               /* shouldn't happen, really */
-               if (!silent)
-                       fprintf(stderr, "#MAL.getAddress address of '%s.%s' not 
found",
-                                                 
(modname?modname:"<unknown>"), fcnname);
+       if (dl == NULL) 
                return NULL;
-       }
 
        adr = (MALfcn) dlsym(dl, fcnname);
        filesLoaded[lastfile].modname = GDKstrdup("libmonetdb5");
        filesLoaded[lastfile].fullname = GDKstrdup("libmonetdb5");
        filesLoaded[lastfile].handle = dl;
        lastfile ++;
-       if(adr != NULL)
-               return adr; /* found it */
-
-       if (!silent)
-               fprintf(stderr, "#MAL.getAddress address of '%s.%s' not found",
-                       (modname?modname:"<unknown>"), fcnname);
-       return NULL;
+       return adr;
 }
 /*
  * Module file loading
diff --git a/monetdb5/mal/mal_linker.h b/monetdb5/mal/mal_linker.h
--- a/monetdb5/mal/mal_linker.h
+++ b/monetdb5/mal/mal_linker.h
@@ -25,7 +25,7 @@
 
 /* #define DEBUG_MAL_LINKER */
 #define MONET64 1
-mal_export MALfcn getAddress(stream *out, str filename, str fcnname,int 
silent);
+mal_export MALfcn getAddress(str fcnname);
 mal_export char *MSP_locate_sqlscript(const char *mod_name, bit recurse);
 mal_export str loadLibrary(str modulename, int flag);
 mal_export char *locate_file(const char *basename, const char *ext, bit 
recurse);
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
@@ -1101,7 +1101,7 @@ parseCommandPattern(Client cntxt, int ki
                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);
+               curInstr->fcn = getAddress(curBlk->binding);
 
                if (cntxt->nspace->isAtomModule) {
                        if (curInstr->fcn == NULL) {
@@ -1146,7 +1146,7 @@ parseFunction(Client cntxt, int kind)
                        return 0;
                }
                nme = idCopy(cntxt, i);
-               curInstr->fcn = getAddress(cntxt->fdout, cntxt->srcFile, nme, 
0);
+               curInstr->fcn = getAddress( nme);
                GDKfree(nme);
                if (curInstr->fcn == NULL) {
                        parseError(cntxt, "<address> not found\n");
diff --git a/monetdb5/mal/mal_scenario.c b/monetdb5/mal/mal_scenario.c
--- a/monetdb5/mal/mal_scenario.c
+++ b/monetdb5/mal/mal_scenario.c
@@ -172,7 +172,7 @@ initScenario(Client c, Scenario s)
        /* prepare for conclicts */
        MT_lock_set(&mal_contextLock);
        if (s->initSystem && s->initSystemCmd == 0) {
-               s->initSystemCmd = (MALfcn) getAddress(c->fdout, l, 
s->initSystem,0);
+               s->initSystemCmd = (MALfcn) getAddress(s->initSystem);
                if (s->initSystemCmd) {
                        msg = (*s->initSystemCmd) (c);
                } else {
@@ -186,24 +186,68 @@ initScenario(Client c, Scenario s)
                return msg;
        }
 
-       if (s->exitSystem && s->exitSystemCmd == 0)
-               s->exitSystemCmd = (MALfcn) getAddress(c->fdout, l, 
s->exitSystem,0);
-       if (s->initClient && s->initClientCmd == 0)
-               s->initClientCmd = (MALfcn) getAddress(c->fdout, l, 
s->initClient,0);
-       if (s->exitClient && s->exitClientCmd == 0)
-               s->exitClientCmd = (MALfcn) getAddress(c->fdout, l, 
s->exitClient,0);
-       if (s->reader && s->readerCmd == 0)
-               s->readerCmd = (MALfcn) getAddress(c->fdout, l, s->reader,0);
-       if (s->parser && s->parserCmd == 0)
-               s->parserCmd = (MALfcn) getAddress(c->fdout, l, s->parser,0);
-       if (s->optimizer && s->optimizerCmd == 0)
-               s->optimizerCmd = (MALfcn) getAddress(c->fdout, l, 
s->optimizer,0);
-       if (s->tactics && s->tacticsCmd == 0)
-               s->tacticsCmd = (MALfcn) getAddress(c->fdout, l, s->tactics,0);
-       if (s->engine && s->engineCmd == 0)
-               s->engineCmd = (MALfcn) getAddress(c->fdout, l, s->engine,0);
+       if (s->exitSystem && s->exitSystemCmd == 0){
+               s->exitSystemCmd = (MALfcn) getAddress(s->exitSystem);
+               if( s->exitSystemCmd == NULL){
+                       msg = createException(MAL,"initScenario","Address of 
exit system command not resolved");
+                       goto wrapup;
+               }
+       }
+       if (s->initClient && s->initClientCmd == 0){
+               s->initClientCmd = (MALfcn) getAddress( s->initClient);
+               if( s->initSystemCmd == NULL){
+                       msg = createException(MAL,"initScenario","Address of 
initClient command not resolved");
+                       goto wrapup;
+               }
+       }
+       if (s->exitClient && s->exitClientCmd == 0){
+               s->exitClientCmd = (MALfcn) getAddress( s->exitClient);
+               if( s->exitClientCmd == NULL){
+                       MT_lock_unset(&mal_contextLock);
+                       msg = createException(MAL,"initScenario","Address of 
exitClient command not resolved");
+                       goto wrapup;
+               }
+       }
+       if (s->reader && s->readerCmd == 0){
+               s->readerCmd = (MALfcn) getAddress( s->reader);
+               if( s->readerCmd == NULL){
+                       msg = createException(MAL,"initScenario","Address of 
reader command not resolved");
+                       goto wrapup;
+               }
+       }
+       if (s->parser && s->parserCmd == 0){
+               s->parserCmd = (MALfcn) getAddress( s->parser);
+               if( s->parserCmd == NULL){
+                       msg = createException(MAL,"initScenario","Address of 
parse command not resolved");
+                       goto wrapup;
+               }
+       }
+       if (s->optimizer && s->optimizerCmd == 0){
+               s->optimizerCmd = (MALfcn) getAddress( s->optimizer);
+               if( s->optimizerCmd == NULL){
+                       msg = createException(MAL,"initScenario","Address of 
optimizer command not resolved");
+                       goto wrapup;
+               }
+       }
+       if (s->tactics && s->tacticsCmd == 0){
+               s->tacticsCmd = (MALfcn) getAddress( s->tactics);
+               if( s->tacticsCmd == NULL){
+                       msg = createException(MAL,"initScenario","Address of 
tactics command not resolved");
+                       goto wrapup;
+               }
+       }
+       if (s->engine && s->engineCmd == 0){
+               s->engineCmd = (MALfcn) getAddress( s->engine);
+               if( s->engineCmd == NULL){
+                       msg = createException(MAL,"initScenario","Address of 
engineClient command not resolved");
+                       goto wrapup;
+               }
+       }
        MT_lock_unset(&mal_contextLock);
        return(fillScenario(c, s));
+wrapup:
+       MT_lock_unset(&mal_contextLock);
+       return msg;
 }
 
 str
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -328,8 +328,12 @@ getPipeCatalog(bat *nme, bat *def, bat *
        }
 
        for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) {
-               if (pipes[i].prerequisite && getAddress(GDKout, NULL, 
pipes[i].prerequisite, TRUE) == NULL)
-                       continue;
+               if (pipes[i].prerequisite && getAddress(pipes[i].prerequisite) 
== NULL){
+                       BBPreclaim(b);
+                       BBPreclaim(bn);
+                       BBPreclaim(bs);
+                       throw(MAL,"getPipeCatalog","#MAL.getAddress address of 
'%s' not found",pipes[i].name);
+               }
                if (BUNappend(b, pipes[i].name, FALSE) != GDK_SUCCEED ||
                        BUNappend(bn, pipes[i].def, FALSE) != GDK_SUCCEED ||
                        BUNappend(bs, pipes[i].status, FALSE) != GDK_SUCCEED) {
@@ -426,8 +430,10 @@ compileOptimizer(Client cntxt, str name)
                if (strcmp(pipes[i].name, name) == 0 && pipes[i].mb == 0) {
                        for (j = 0; j < MAXOPTPIPES && pipes[j].def; j++) {
                                if (pipes[j].mb == NULL) {
-                                       if (pipes[j].prerequisite && 
getAddress(cntxt->fdout, NULL, pipes[j].prerequisite, TRUE) == NULL)
-                                               continue;
+                                       if (pipes[j].prerequisite && 
getAddress(pipes[j].prerequisite) == NULL){
+                                               msg = 
createException(MAL,"compileOptimizer","#MAL.getAddress address of '%s' not 
found",pipes[i].name);
+                                               goto wrapup;
+                                       }
                                        msg = compileString(cntxt, 
pipes[j].def);
                                        if (msg != MAL_SUCCEED) 
                                                break;
diff --git a/sql/backends/monet5/UDF/pyapi/pyheader.h 
b/sql/backends/monet5/UDF/pyapi/pyheader.h
--- a/sql/backends/monet5/UDF/pyapi/pyheader.h
+++ b/sql/backends/monet5/UDF/pyapi/pyheader.h
@@ -90,7 +90,7 @@
 
 #define LOAD_SQL_FUNCTION_PTR(fcnname)                                         
\
        fcnname##_ptr =                                                         
   \
-               (fcnname##_ptr_tpe)getAddress(NULL, "lib_sql.dll", #fcnname, 
0);       \
+               (fcnname##_ptr_tpe)getAddress( #fcnname );                      
                               \
        if (fcnname##_ptr == NULL) {                                            
   \
                msg = createException(MAL, "pyapi.eval", "Failed to load 
function %s", \
                                                          #fcnname);            
                           \
diff --git a/sql/backends/monet5/sql_optimizer.c 
b/sql/backends/monet5/sql_optimizer.c
--- a/sql/backends/monet5/sql_optimizer.c
+++ b/sql/backends/monet5/sql_optimizer.c
@@ -22,6 +22,7 @@
 #include "sql_gencode.h"
 #include "opt_pipes.h"
 
+/* #define _DEBUG_SQL_OPTIMIZER_ */
 /* calculate the footprint for optimizer pipe line choices
  * and identify empty columns upfront for just in time optimizers.
  */
@@ -94,7 +95,9 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
                                size = SQLgetColumnSize(tr, c, access);
                                space += size;  // accumulate once
                                if( !prepare && size == 0  && ! t->system){
-                                       //mnstr_printf(GDKout,"found empty 
column %s.%s.%s prepare %d size "LLFMT"\n",sname,tname,cname,prepare,size);
+#ifdef _DEBUG_SQL_OPTIMIZER_
+                                       fprintf(stderr,"found empty column 
%s.%s.%s prepare %d size "LLFMT"\n",sname,tname,cname,prepare,size);
+#endif
                                        setFunctionId(p, emptybindRef);
                                }
                        }
@@ -121,7 +124,9 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
 
                                                if( !prepare && size == 0 && ! 
i->t->system){
                                                        setFunctionId(p, 
emptybindidxRef);
-                                                       
//mnstr_printf(GDKout,"found empty column %s.%s.%s prepare %d size 
"LLFMT"\n",sname,tname,idxname,prepare,size);
+#ifdef _DEBUG_SQL_OPTIMIZER_
+                                                       fprintf(stderr,"found 
empty column %s.%s.%s prepare %d size 
"LLFMT"\n",sname,tname,idxname,prepare,size);
+#endif
                                                }
                                                BBPunfix(b->batCacheid);
                                        }
@@ -162,7 +167,9 @@ addOptimizers(Client c, MalBlkPtr mb, ch
                 * we can switch to a better one. */
                if( space > (lng)(0.8 * MT_npages() * MT_pagesize())  && 
GDKnr_threads > 1){
                        pipe = "volcano_pipe";
-                       //mnstr_printf(GDKout, "#use volcano optimizer 
pipeline? "SZFMT"\n", space);
+#ifdef _DEBUG_SQL_OPTIMIZER_
+                       fprintf(stderr, "#use volcano optimizer pipeline? 
"SZFMT"\n", space);
+#endif
                }else
                        pipe = "default_pipe";
        } else
diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -1244,7 +1244,7 @@ stmt_uselect(backend *be, stmt *op1, stm
                        op = ">=";
                        break;
                default:
-                       showException(GDKout, SQL, "sql", "Unknown operator");
+                       addMalException(mb, "sql.statement Unknown operator");
                }
 
                if ((q = multiplex2(mb, mod, convertOperator(op), l, r, 
TYPE_bit)) == NULL) 
@@ -1290,7 +1290,7 @@ stmt_uselect(backend *be, stmt *op1, stm
                        q = pushStr(mb, q, ">=");
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to