Changeset: 425438dfb967 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=425438dfb967
Modified Files:
        monetdb5/extras/rapi/Tests/rapi10.malC
        monetdb5/mal/Tests/tst301.malC
        monetdb5/mal/Tests/tst301.stable.out
        monetdb5/mal/mal_import.c
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_interpreter.h
        monetdb5/mal/mal_scenario.c
        monetdb5/mal/mal_scenario.h
        monetdb5/mal/mal_session.c
        monetdb5/modules/atoms/Tests/inet01.malC
        monetdb5/modules/mal/language.c
        monetdb5/optimizer/Tests/tst4630.stable.out
        monetdb5/optimizer/opt_evaluate.c
        monetdb5/optimizer/opt_pipes.c
Branch: malerrors
Log Message:

Intermittent commit
A few more exception handling issues resolved.


diffs (300 lines):

diff --git a/monetdb5/extras/rapi/Tests/rapi10.malC 
b/monetdb5/extras/rapi/Tests/rapi10.malC
--- a/monetdb5/extras/rapi/Tests/rapi10.malC
+++ b/monetdb5/extras/rapi/Tests/rapi10.malC
@@ -1,6 +1,6 @@
-r1:bat[:int] := rapi.eval(nil:ptr,"loopback_query(\"select cast(42 as 
integer)\")[[1]]");
+r1:bat[:int] := rapi.eval(nil:ptr,"loopback_query(\"select cast(42 as 
integer);\")[[1]]");
 io.print(r1);
 
 
-r2:bat[:str] := rapi.eval(nil:ptr,"loopback_query(\"select 'a' as str union 
all select 'b' as str\")$str");
+r2:bat[:str] := rapi.eval(nil:ptr,"loopback_query(\"select 'a' as str union 
all select 'b' as str;\")$str");
 io.print(r2);
diff --git a/monetdb5/mal/Tests/tst301.malC b/monetdb5/mal/Tests/tst301.malC
--- a/monetdb5/mal/Tests/tst301.malC
+++ b/monetdb5/mal/Tests/tst301.malC
@@ -6,3 +6,4 @@ catch IllegalAccess;
        io.printf("caught %d\n",IllegalAccess);
 exit IllegalAccess;
 end;
+foo();
diff --git a/monetdb5/mal/Tests/tst301.stable.out 
b/monetdb5/mal/Tests/tst301.stable.out
--- a/monetdb5/mal/Tests/tst301.stable.out
+++ b/monetdb5/mal/Tests/tst301.stable.out
@@ -29,6 +29,7 @@ Ready.
 # 09:11:14 >  "mclient" "-lmal" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-23106" "--port=30527"
 # 09:11:14 >  
 
+caught 1234
 
 # 09:11:14 >  
 # 09:11:14 >  "Done."
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
@@ -28,6 +28,7 @@
 #include "mal_import.h"
 #include "mal_interpreter.h"   /* for showErrors() */
 #include "mal_linker.h"                /* for loadModuleLibrary() */
+#include "mal_scenario.h"
 #include "mal_parser.h"
 #include "mal_private.h"
 
@@ -257,7 +258,7 @@ evalFile(str fname, int listing)
        }
        MSinitClientPrg(c, "user", "main");
 
-       msg = runScenario(c);
+       msg = runScenario(c,0);
        //MCcloseClient(c);
        return msg;
 }
@@ -299,22 +300,24 @@ compileString(Symbol *fcn, Client cntxt,
        }
 
        buffer_init(b, qry, len);
-       c= MCinitClient((oid)0, bstream_create(buffer_rastream(b, 
"callString"), b->len),0);
+       c= MCinitClient((oid)0, bstream_create(buffer_rastream(b, 
"compileString"), b->len),0);
        if( c == NULL){
                GDKfree(b);
                GDKfree(qry);
                throw(MAL,"mal.eval","Can not create user context");
        }
-       c->curmodule = c->usermodule = userModule();
+       // compile in context of called
+       c->curmodule = c->usermodule = cntxt->usermodule;
        c->promptlength = 0;
+       c->listing = 0;
 
     if ( (msg = defaultScenario(c)) ) {
+               c->usermodule= 0;
                MCcloseClient(c);
                throw(MAL,"mal.compile","%s",msg);
        }
 
        MSinitClientPrg(c, "user", "main");  /* create new context */
-       msg = (str) (*c->phase[MAL_SCENARIO_READER])(c);
        if(msg == MAL_SUCCEED && c->phase[MAL_SCENARIO_PARSER])
                msg = (str) (*c->phase[MAL_SCENARIO_PARSER])(c);
        if(msg == MAL_SUCCEED && c->phase[MAL_SCENARIO_OPTIMIZE])
@@ -322,6 +325,7 @@ compileString(Symbol *fcn, Client cntxt,
 
        *fcn = c->curprg;
        c->curprg = 0;
+       c->usermodule= 0;
        /* restore IO channel */
        MCcloseClient(c);
        GDKfree(qry);
@@ -355,26 +359,20 @@ callString(Client cntxt, str s, int list
                GDKfree(qry);
                throw(MAL,"mal.call","Can not create user context");
        }
-       c->curmodule = c->usermodule = userModule();
+       c->curmodule = c->usermodule =  cntxt->usermodule;
        c->promptlength = 0;
        c->listing = listing;
 
     if ( (msg = defaultScenario(c)) ) {
+               c->usermodule = 0;
                MCcloseClient(c);
                throw(MAL,"mal.call","%s",msg);
        }
 
        MSinitClientPrg(c, "user", "main");  /* create new context */
-       msg = (str) (*c->phase[MAL_SCENARIO_READER])(c);
-       if(msg == MAL_SUCCEED && c->phase[MAL_SCENARIO_PARSER])
-               msg = (str) (*c->phase[MAL_SCENARIO_PARSER])(c);
-       if(msg == MAL_SUCCEED && c->phase[MAL_SCENARIO_OPTIMIZE])
-               msg = (str) (*c->phase[MAL_SCENARIO_OPTIMIZE])(c);
-       if(msg == MAL_SUCCEED && c->phase[MAL_SCENARIO_SCHEDULER])
-               msg = (str) (*c->phase[MAL_SCENARIO_SCHEDULER])(c);
-       if(msg == MAL_SUCCEED && c->phase[MAL_SCENARIO_ENGINE])
-               msg = (str) (*c->phase[MAL_SCENARIO_ENGINE])(c);
-       MCcloseClient(c);
+       runScenario(c,1);
+       c->usermodule = 0;
+       //MCcloseClient(c);
        GDKfree(qry);
        GDKfree(b);
        return msg;
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -18,6 +18,7 @@
 #include "mal_debugger.h"   /* for mdbStep() */
 #include "mal_type.h"
 #include "mal_private.h"
+  
 
 /*
  * The struct alignment leads to 40% gain in simple instructions when set.
@@ -840,7 +841,10 @@ str runMALsequence(Client cntxt, MalBlkP
 
                /* Exception handling */
                if (localGDKerrbuf && localGDKerrbuf[0]) {
-                       ret = catchKernelException(mb,stkpc);
+                       if( ret == 0)
+                               ret = 
createException(MAL,"mal.interpreter",GDK_EXCEPTION);
+                       // TODO take properly care of the GDK exception
+                       localGDKerrbuf[0]=0;
                }
 
                if (ret != MAL_SUCCEED) {
@@ -1296,14 +1300,6 @@ str runMALsequence(Client cntxt, MalBlkP
  * encoding of the exceptional state encountered. This message
  * starts with the exception identifer, followed by contextual details.
  */
-str catchKernelException(MalBlkPtr mb, int pc)
-{
-       str msg= MAL_SUCCEED;
-       if (GDKerrbuf && GDKerrbuf[0]) 
-               msg = createException(MAL,"gdk.exception","%s.%s[%d]:%s\n", 
-                               getModuleId(getInstrPtr(mb,0)),  
getFunctionId(getInstrPtr(mb,0)), pc, GDKerrbuf);
-       return msg;
-}
 
 /*
  * Garbage collection
diff --git a/monetdb5/mal/mal_interpreter.h b/monetdb5/mal/mal_interpreter.h
--- a/monetdb5/mal/mal_interpreter.h
+++ b/monetdb5/mal/mal_interpreter.h
@@ -34,7 +34,6 @@ mal_export void garbageElement(Client cn
 mal_export void garbageCollector(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
int flag);
 mal_export str malCommandCall(MalStkPtr stk, InstrPtr pci);
 mal_export int isNotUsedIn(InstrPtr p, int start, int a);
-mal_export str catchKernelException(MalBlkPtr mb, int pc);
 
 mal_export ptr getArgReference(MalStkPtr stk, InstrPtr pci, int k);
 #if !defined(NDEBUG) && defined(__GNUC__)
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
@@ -516,7 +516,7 @@ runPhase(Client c, int phase)
  * running a scenario should be explicitly permitted.
  */
 static str
-runScenarioBody(Client c)
+runScenarioBody(Client c, int once)
 {
        str msg= MAL_SUCCEED;
 
@@ -547,21 +547,22 @@ runScenarioBody(Client c)
                        mnstr_printf(c->fdout,"!GDKerror: %s\n",GDKerrbuf);
                assert(c->curprg->def->errors == NULL);
                c->actions++;
+               if( once) break;
        }
-       if (c->phase[MAL_SCENARIO_EXITCLIENT])
+       c->exception_buf_initialized = 0;
+       if (once == 0 && c->phase[MAL_SCENARIO_EXITCLIENT])
                msg = (*c->phase[MAL_SCENARIO_EXITCLIENT]) (c);
-       c->exception_buf_initialized = 0;
        return msg;
 }
 
 str
-runScenario(Client c)
+runScenario(Client c, int once)
 {
        str msg = MAL_SUCCEED;
 
        if (c == 0 || c->phase[MAL_SCENARIO_READER] == 0)
                return msg;
-       msg = runScenarioBody(c);
+       msg = runScenarioBody(c,once);
        if (msg != MAL_SUCCEED &&
                        strcmp(msg,"MALException:client.quit:Server stopped."))
                mnstr_printf(c->fdout,"!%s\n",msg);
diff --git a/monetdb5/mal/mal_scenario.h b/monetdb5/mal/mal_scenario.h
--- a/monetdb5/mal/mal_scenario.h
+++ b/monetdb5/mal/mal_scenario.h
@@ -58,7 +58,7 @@ typedef struct SCENARIO {
 } *Scenario;
 
 mal_export str setScenario(Client c, str nme);
-mal_export str runScenario(Client c);
+mal_export str runScenario(Client c, int once);
 mal_export str getScenarioLanguage(Client c);
 mal_export Scenario getFreeScenario(void);
 
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
@@ -487,7 +487,7 @@ MSserveClient(void *dummy)
        } else {
                do {
                        do {
-                               msg = runScenario(c);
+                               msg = runScenario(c,0);
                                freeException(msg);
                                if (c->mode == FINISHCLIENT)
                                        break;
diff --git a/monetdb5/modules/atoms/Tests/inet01.malC 
b/monetdb5/modules/atoms/Tests/inet01.malC
--- a/monetdb5/modules/atoms/Tests/inet01.malC
+++ b/monetdb5/modules/atoms/Tests/inet01.malC
@@ -11,9 +11,9 @@ i4 := inet.new("192.168.0.3/24");
 io.print(i4);
 
 i5 := inet.new("/0");
-catch ParseException:str;
+catch AnyException:str;
 io.printf("Caught parse exception\n");
-exit ParseException;
+exit AnyException;
 io.print(i5);
 
 i6 := inet.new("127/32");
diff --git a/monetdb5/modules/mal/language.c b/monetdb5/modules/mal/language.c
--- a/monetdb5/modules/mal/language.c
+++ b/monetdb5/modules/mal/language.c
@@ -184,8 +184,9 @@ CMDregisterFunction(Client cntxt, MalBlk
 
        msg= compileString(&sym, cntxt,*code);
        if( sym) {
-               mnstr_printf(cntxt->fdout,"#register FUNCTION %s.%s\n",
-                       getModuleId(sym->def->stmt[0]), 
getFunctionId(sym->def->stmt[0]));
+               assert(cntxt->usermodule);
+               //mnstr_printf(cntxt->fdout,"#register FUNCTION %s.%s\n",
+                       //getModuleId(sym->def->stmt[0]), 
getFunctionId(sym->def->stmt[0]));
                mb= sym->def;
                if( help)
                        mb->help= GDKstrdup(*help);
diff --git a/monetdb5/optimizer/Tests/tst4630.stable.out 
b/monetdb5/optimizer/Tests/tst4630.stable.out
--- a/monetdb5/optimizer/Tests/tst4630.stable.out
+++ b/monetdb5/optimizer/Tests/tst4630.stable.out
@@ -29,7 +29,7 @@ Ready.
 # 21:55:32 >  "mclient" "-lmal" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-1801" "--port=39930"
 # 21:55:32 >  
 
-function user.qry(a:bat[:any_2], b:bat[:any_3], c:bat[:any_4]):bat[:any_4];    
#[0] (0)  0 <- 1 2 3 
+function user.qry(a:bat[:any_2], b:bat[:any_3], c:bat[:any_4]):bat[:any_4];    
#[0] (0)  0 <- 1 2 3  type check needed 
     a1:bat[:any_2] := a:bat[:any_2];           #[1] (0)  4 <- 1 
     b1:bat[:any_3] := b:bat[:any_3];           #[2] (0)  5 <- 2 
     c1:bat[:any_4] := c:bat[:any_4];           #[3] (0)  6 <- 3 
diff --git a/monetdb5/optimizer/opt_evaluate.c 
b/monetdb5/optimizer/opt_evaluate.c
--- a/monetdb5/optimizer/opt_evaluate.c
+++ b/monetdb5/optimizer/opt_evaluate.c
@@ -243,9 +243,9 @@ OPTevaluateImplementation(Client cntxt, 
 
     /* Defense line against incorrect plans */
        /* Plan is unaffected */
-       //chkTypes(cntxt->usermodule, mb, FALSE);
-       //chkFlow(mb);
-       //chkDeclarations(mb);
+       chkTypes(cntxt->usermodule, mb, FALSE);
+       chkFlow(mb);
+       chkDeclarations(mb);
     
     /* keep all actions taken as a post block comment */
        usec = GDKusec()- usec;
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
@@ -447,6 +447,7 @@ compileOptimizer(Client cntxt, str name)
                                MT_lock_unset(&pipeLock);
                                throw(MAL, "optimizer.addOptimizerPipe", 
"failed to create client thread");
                        }
+                       c.curmodule = c.usermodule = userModule();
                        for (j = 0; j < MAXOPTPIPES && pipes[j].def; j++) {
                                if (pipes[j].mb == NULL) {
                                        if (pipes[j].prerequisite && 
getAddress(pipes[j].prerequisite) == NULL)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to