Changeset: 2628fde54114 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2628fde54114
Modified Files:
monetdb5/mal/mal_interpreter.c
Branch: Apr2019
Log Message:
Some minor fixes.
diffs (158 lines):
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
@@ -458,7 +458,7 @@ str runMALsequence(Client cntxt, MalBlkP
int i, k;
InstrPtr pci = 0;
int exceptionVar;
- str ret = 0, localGDKerrbuf= GDKerrbuf;
+ str ret = MAL_SUCCEED, localGDKerrbuf= GDKerrbuf;
ValRecord backups[16];
ValPtr backup;
int garbages[16], *garbage;
@@ -477,11 +477,10 @@ str runMALsequence(Client cntxt, MalBlkP
pci = getInstrPtr(mb, startpc);
if (pci->argc > 16) {
backup = GDKmalloc(pci->argc * sizeof(ValRecord));
- if( backup == NULL)
- throw(MAL, "mal.interpreter", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
garbage = (int*)GDKzalloc(pci->argc * sizeof(int));
- if( garbage == NULL){
+ if( backup == NULL || garbage == NULL) {
GDKfree(backup);
+ GDKfree(garbage);
throw(MAL, "mal.interpreter", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
}
} else {
@@ -491,11 +490,10 @@ str runMALsequence(Client cntxt, MalBlkP
}
} else if ( mb->maxarg > 16 ){
backup = GDKmalloc(mb->maxarg * sizeof(ValRecord));
- if( backup == NULL)
- throw(MAL, "mal.interpreter", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
garbage = (int*)GDKzalloc(mb->maxarg * sizeof(int));
- if( garbage == NULL){
+ if( backup == NULL || garbage == NULL) {
GDKfree(backup);
+ GDKfree(garbage);
throw(MAL, "mal.interpreter", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
}
} else {
@@ -524,7 +522,7 @@ str runMALsequence(Client cntxt, MalBlkP
pci = getInstrPtr(mb, stkpc);
if (cntxt->mode == FINISHCLIENT){
stkpc = stoppc;
- if (ret == NULL)
+ if (ret == MAL_SUCCEED)
ret= createException(MAL, "mal.interpreter",
"prematurely stopped client");
break;
}
@@ -573,6 +571,12 @@ str runMALsequence(Client cntxt, MalBlkP
MT_lock_unset(&qptimeoutLock);
}
+ if (cntxt->qtimeout && mb->starttime && GDKusec() -
mb->starttime > cntxt->qtimeout) {
+ freeException(ret); /* in case it's set */
+ ret = createException(MAL, "mal.interpreter",
SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
+ break;
+ }
+
/* The interpreter loop
* The interpreter is geared towards execution a MAL
* procedure together with all its descendant
@@ -608,7 +612,7 @@ str runMALsequence(Client cntxt, MalBlkP
}
freeException(ret);
- ret = 0;
+ ret = MAL_SUCCEED;
switch (pci->token) {
case ASSIGNsymbol:
/* Assignment command
@@ -635,8 +639,6 @@ str runMALsequence(Client cntxt, MalBlkP
} else if (lhs->vtype == TYPE_bat &&
!is_bat_nil(lhs->val.bval))
BBPretain(lhs->val.bval);
}
- freeException(ret);
- ret = 0;
break;
case PATcall:
if (pci->fcn == NULL) {
@@ -762,7 +764,7 @@ str runMALsequence(Client cntxt, MalBlkP
} else if (lhs->vtype == TYPE_bat)
BBPretain(lhs->val.bval);
}
- if(!ret) {
+ if(ret == MAL_SUCCEED) {
ret = runMALsequence(cntxt, pci->blk,
1, pci->blk->stop, nstk, stk, pci);
for (ii = 0; ii < nstk->stktop; ii++)
if
(ATOMextern(nstk->stk[ii].vtype))
@@ -782,6 +784,7 @@ str runMALsequence(Client cntxt, MalBlkP
if (pcicaller && garbageControl(getInstrPtr(mb, 0)))
garbageCollector(cntxt, mb, stk, TRUE);
if (cntxt->qtimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->qtimeout){
+ freeException(ret); /* overrule exception */
ret= createException(MAL, "mal.interpreter",
SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
break;
}
@@ -800,10 +803,6 @@ str runMALsequence(Client cntxt, MalBlkP
} else {
ret = createException(MAL,"interpreter",
"failed instruction2str");
}
- if (cntxt->qtimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->qtimeout){
- ret= createException(MAL, "mal.interpreter",
SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
- break;
- }
stkpc= mb->stop;
continue;
} }
@@ -872,7 +871,7 @@ str runMALsequence(Client cntxt, MalBlkP
/* Exception handling */
if (localGDKerrbuf && localGDKerrbuf[0]) {
- if( ret == 0)
+ if( ret == MAL_SUCCEED)
ret =
createException(MAL,"mal.interpreter",GDK_EXCEPTION);
// TODO take properly care of the GDK exception
localGDKerrbuf[0]=0;
@@ -918,8 +917,6 @@ str runMALsequence(Client cntxt, MalBlkP
/* unknown exceptions lead to propagation */
if (exceptionVar == -1) {
- if (cntxt->qtimeout && mb->starttime &&
GDKusec()- mb->starttime > cntxt->qtimeout)
- ret= createException(MAL,
"mal.interpreter", SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
stkpc = mb->stop;
continue;
}
@@ -933,11 +930,12 @@ str runMALsequence(Client cntxt, MalBlkP
v->vtype = TYPE_str;
v->val.sval = ret;
v->len = (int)strlen(v->val.sval);
- ret = 0;
+ ret = MAL_SUCCEED;
MT_lock_unset(&mal_contextLock);
} else {
mnstr_printf(cntxt->fdout, "%s", ret);
freeException(ret);
+ ret = MAL_SUCCEED;
}
/* position yourself at the catch instruction for
further decisions */
/* skipToCatch(exceptionVar,@2,@3) */
@@ -1118,7 +1116,7 @@ str runMALsequence(Client cntxt, MalBlkP
case RAISEsymbol:
exceptionVar = getDestVar(pci);
//freeException(ret);
- ret = NULL;
+ ret = MAL_SUCCEED;
if (getVarType(mb, getDestVar(pci)) == TYPE_str) {
char nme[256];
snprintf(nme,256,"%s.%s[%d]",
getModuleId(getInstrPtr(mb,0)), getFunctionId(getInstrPtr(mb,0)), stkpc);
@@ -1205,7 +1203,7 @@ str runMALsequence(Client cntxt, MalBlkP
if (exceptionVar >= 0) {
char nme[256];
snprintf(nme,256,"%s.%s[%d]", getModuleId(getInstrPtr(mb,0)),
getFunctionId(getInstrPtr(mb,0)), stkpc);
- if (ret) {
+ if (ret != MAL_SUCCEED) {
str new, n;
n = createException(MAL,nme,"exception not caught");
if (n) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list