Changeset: 967379f42c15 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=967379f42c15
Modified Files:
        monetdb5/mal/mal_function.c
        monetdb5/mal/mal_import.c
        monetdb5/mal/mal_linker.c
        monetdb5/mal/mal_listing.c
        monetdb5/mal/mal_module.c
        monetdb5/mal/mal_parser.c
        monetdb5/mal/mal_runtime.c
        monetdb5/mal/mal_scenario.c
        monetdb5/mal/mal_session.c
        monetdb5/mal/mal_session.h
        monetdb5/mal/mal_stack.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/microbenchmark.c
Branch: malparsing
Log Message:

Remogve direct calls to GDKerror
Direct calls to GDKerror should be limited to the GDK layer
and the atoms introduced.


diffs (truncated from 611 to 300 lines):

diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -590,10 +590,8 @@ setVariableScope(MalBlkPtr mb)
 
                if( blockStart(p)){
                        if (getModuleId(p) && getFunctionId(p) && 
strcmp(getModuleId(p),"language")==0 && strcmp(getFunctionId(p),"dataflow")==0){
-                               if( dflow != -1){
-                                       GDKerror("setLifeSpan nested dataflow 
blocks not allowed" );
-                                       mb->errors++;
-                               }
+                               if( dflow != -1)
+                                       addMalException(mb,"setLifeSpan nested 
dataflow blocks not allowed" );
                                dflow= depth;
                        } else
                                depth++;
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
@@ -131,7 +131,7 @@ evalFile(Client cntxt, str fname, int li
                        c->promptlength = 0;
                        msg = defaultScenario(c);
                        if( msg == MAL_SUCCEED){ 
-                               MSinitClientPrg(c, "user", "main");  /* create 
new context */
+                               (void) MSinitClientPrg(c, "user", "main");  /* 
create new context */
                                c->listing = listing;
                                msg = runScenario(c);
                        }
@@ -199,7 +199,7 @@ compileString(Client cntxt, str s)
 
        msg = defaultScenario(c);
        if( msg == MAL_SUCCEED){ 
-               MSinitClientPrg(c, "user", "main");  /* create new context */
+               (void) MSinitClientPrg(c, "user", "main");  /* create new 
context */
                c->blkmode = 1; // collect all statements
                while(msg == MAL_SUCCEED && c->fdin->eof == 0){
                        msg = MALreader(c);
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
@@ -360,10 +360,8 @@ locate_file(const char *basename, const 
                for (c = 0; c < lasts; c++)
                        i += strlen(strs[c]) + 1; /* PATH_SEP or \0 */
                fullname = GDKrealloc(fullname, i);
-               if( fullname == NULL){
-                       GDKerror("locate_file" MAL_MALLOC_FAIL);
+               if( fullname == NULL)
                        return NULL;
-               }
                i = 0;
                for (c = 0; c < lasts; c++) {
                        if (strstr(fullname, strs[c]) == NULL) {
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
@@ -47,7 +47,7 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, 
 
        buf = GDKzalloc(maxlen);
        if( buf == NULL) {
-               GDKerror("renderTerm:Failed to allocate");
+               addMalException(mb, "renderTerm:Failed to allocate");
                return NULL;
        }
        // show the name when required or is used
@@ -75,7 +75,7 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, 
                        buf= GDKrealloc(buf, maxlen =len + strlen(cv) + BUFSIZ);
 
                if( buf == 0){
-                       GDKerror("renderTerm:Failed to allocate");
+                       addMalException(mb,"renderTerm:Failed to allocate");
                        return NULL;
                }
 
@@ -121,7 +121,7 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, 
        }
 
        if( len >= maxlen)
-               GDKerror("renderTerm:Value representation too large");
+               addMalException(mb,"renderTerm:Value representation too large");
        return buf;
 }
 
@@ -530,7 +530,7 @@ mal2str(MalBlkPtr mb, int first, int las
        len = GDKmalloc(sizeof(int) * mb->stop);
 
        if( txt == NULL || len == NULL){
-               GDKerror("mal2str: " MAL_MALLOC_FAIL);
+               addMalException(mb,"mal2str: " MAL_MALLOC_FAIL);
                if( txt ) GDKfree(txt);
                if( len ) GDKfree(len);
                return NULL;
@@ -549,7 +549,7 @@ mal2str(MalBlkPtr mb, int first, int las
        }
        ps = GDKmalloc(totlen + mb->stop + 1);
        if( ps == NULL){
-               GDKerror("mal2str: " MAL_MALLOC_FAIL);
+               addMalException(mb,"mal2str: " MAL_MALLOC_FAIL);
                GDKfree(len);
                GDKfree(txt);
                return NULL;
@@ -618,7 +618,7 @@ printSignature(stream *fd, Symbol s, int
                (void) fcnDefinition(s->def, p, txt, flg, txt, MAXLISTING);
                mnstr_printf(fd, "%s\n", txt);
                GDKfree(txt);
-       } else GDKerror("printSignature"MAL_MALLOC_FAIL);
+       } else mnstr_printf(fd,"printSignature"MAL_MALLOC_FAIL);
 }
 
 void showMalBlkHistory(stream *out, MalBlkPtr mb)
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
@@ -50,8 +50,7 @@ static void newModuleSpace(Module scope)
        fprintf(stderr,"#Add jump table to scope %s\n", scope->name);
 #endif
        scope->space = (Symbol *) GDKzalloc(MAXSCOPE * sizeof(Symbol));
-       if( scope->space == 0)
-               GDKerror("newModuleSpace:"MAL_MALLOC_FAIL);
+       // error is reported elsewhere
 }
 
 void
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
@@ -1449,6 +1449,7 @@ int
 parseMAL(Client cntxt)
 {      int cntrl = 0;
        int inlineProp =0, unsafeProp = 0, sealedProp = 0;
+       str msg;
 
        cntxt->lineptr = cntxt->line;
        skipSpace(cntxt);
@@ -1479,7 +1480,9 @@ parseMAL(Client cntxt)
                                        cntxt->curprg->def->sealedProp = 
sealedProp;
                                        if (inlineProp)
                                                parseError(cntxt, 
"parseError:INLINE ignored");
-                                       MSinitClientPrg(cntxt, "user", "main");
+                                       msg = MSinitClientPrg(cntxt, "user", 
"main");
+                                       if( msg != MAL_SUCCEED)
+                                               parseError(cntxt,msg);
                                }
                                return 0;
                        }
@@ -1560,7 +1563,9 @@ parseMAL(Client cntxt)
                                        chkProgram(cntxt->nspace, 
cntxt->curprg->def);
                                        if( cntxt->curprg->def->errors)
                                                parseError(cntxt,"Program 
contains errors\n");
-                                       MSinitClientPrg(cntxt, "user","main");
+                                       msg = MSinitClientPrg(cntxt, 
"user","main");
+                                       if( msg != MAL_SUCCEED)
+                                               parseError(cntxt,msg);
                                        return 0;
                                }
                                continue;
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -66,7 +66,7 @@ runtimeProfileInit(Client cntxt, MalBlkP
        if ( qtop +1 == qsize )
                QRYqueue = (QueryQueue) GDKrealloc( QRYqueue, sizeof (struct 
QRYQUEUE) * (qsize +=256));
        if ( QRYqueue == NULL){
-               GDKerror("runtimeProfileInit" MAL_MALLOC_FAIL);
+                       addMalException(mb,"runtimeProfileInit" 
MAL_MALLOC_FAIL);
                MT_lock_unset(&mal_delayLock);
                return;
        }
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
@@ -578,7 +578,10 @@ runScenarioBody(Client c)
                        freeException(msg);
                        msg = MAL_SUCCEED;
                }
-               showErrors(c); // GDK level errors
+               if( GDKerrbuf && GDKerrbuf[0]){
+                       mnstr_printf(c->fdout,"!GDKerror: %s\n",GDKerrbuf);
+                       mnstr_flush(c->fdout);
+               }
                assert(c->curprg->def->errors == NULL);
                c->actions++;
        }
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
@@ -93,7 +93,7 @@ malBootstrap(void)
  * was added.  At the end of the session we have to garbage collect the
  * BATs introduced.
  */
-static void
+static str
 MSresetClientPrg(Client cntxt)
 {
        MalBlkPtr mb;
@@ -116,26 +116,24 @@ MSresetClientPrg(Client cntxt)
                freeMalBlk(mb->history);
                mb->history = 0;
        }
+       return MAL_SUCCEED;
 }
 
 /*
  * Create a new container block
  */
 
-void
+str
 MSinitClientPrg(Client cntxt, str mod, str nme)
 {
        InstrPtr p;
        MalBlkPtr mb;
 
-       if (cntxt->curprg && idcmp(nme, cntxt->curprg->name) == 0) {
-               MSresetClientPrg(cntxt);
-               return;
-       }
+       if (cntxt->curprg && idcmp(nme, cntxt->curprg->name) == 0) 
+               return MSresetClientPrg(cntxt);
        cntxt->curprg = newFunction(putName("user"), putName(nme), 
FUNCTIONsymbol);
        if( cntxt->curprg == 0){
-               GDKerror("MSinitClientPrg" "Failed to create function");
-               return;
+               throw(MAL, "initClientPrg", MAL_MALLOC_FAIL);
        }
        mb = cntxt->curprg->def;
        p = getSignature(cntxt->curprg);
@@ -146,7 +144,10 @@ MSinitClientPrg(Client cntxt, str mod, s
        setVarType(mb, findVariable(mb, nme), TYPE_void);
        if (cntxt->glb == NULL )
                cntxt->glb = newGlobalStack(MAXGLOBALS + mb->vsize);
+       if( cntxt->glb == NULL)
+               throw(MAL,"initClientPrg", MAL_MALLOC_FAIL);
        assert(cntxt->curprg->def != NULL);
+       return MAL_SUCCEED;
 }
 
 /*
@@ -334,7 +335,7 @@ MSscheduleClient(str command, str challe
                }
        }
 
-       MSinitClientPrg(c, "user", "main");
+       (void) MSinitClientPrg(c, "user", "main");
 
        GDKfree(command);
 
@@ -719,7 +720,7 @@ MALparser(Client cntxt)
                } 
                msg = cntxt->curprg->def->errors;
                cntxt->curprg->def->errors = 0;
-               MSinitClientPrg(cntxt,"user","main");
+               (void) MSinitClientPrg(cntxt,"user","main");
        }
 
        return msg;
diff --git a/monetdb5/mal/mal_session.h b/monetdb5/mal/mal_session.h
--- a/monetdb5/mal/mal_session.h
+++ b/monetdb5/mal/mal_session.h
@@ -13,7 +13,7 @@
 
 mal_export str malBootstrap(void);
 mal_export str MSserveClient(void *dummy);
-mal_export void MSinitClientPrg(Client cntxt, str mod, str nme);
+mal_export str MSinitClientPrg(Client cntxt, str mod, str nme);
 mal_export void MSscheduleClient(str command, str challenge, bstream *fin, 
stream *fout);
 
 mal_export str MALreader(Client c);
diff --git a/monetdb5/mal/mal_stack.c b/monetdb5/mal/mal_stack.c
--- a/monetdb5/mal/mal_stack.c
+++ b/monetdb5/mal/mal_stack.c
@@ -60,10 +60,8 @@ newGlobalStack(int size)
        MalStkPtr s;
 
        s = (MalStkPtr) GDKzalloc(stackSize(size) + offsetof(MalStack, stk));
-       if (!s) {
-               GDKerror("newGlobalStack:"MAL_MALLOC_FAIL);
+       if (!s) 
                return NULL;
-       }
        s->stksize = size;
        return s;
 }
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -97,22 +97,21 @@ CMDgen_group(BAT **result, BAT *gids, BA
 }
 
 
-static gdk_return
+static str
 slice(BAT **retval, BAT *b, lng start, lng end)
 {
        /* the internal BATslice requires exclusive end */
-       if (start < 0) {
-               GDKerror("CMDslice: start position of slice should >= 0\n");
-               return GDK_FAIL;
-       }
+       if (start < 0) 
+               throw(MAL,"algebra.slice","start position of slice should >= 
0\n");
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to