Changeset: eb4c175d2332 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eb4c175d2332
Modified Files:
clients/Tests/exports.stable.out
monetdb5/mal/Tests/run
monetdb5/mal/mal_builder.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_instruction.h
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_session.c
sql/backends/monet5/sql_execute.c
sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out
Branch: default
Log Message:
More minor changes to fit the new MAL variable/instruction mgmt
diffs (truncated from 430 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2364,7 +2364,7 @@ str plusRef;
str postludeRef;
str preludeRef;
MalStkPtr prepareMALstack(MalBlkPtr mb, int size);
-void prepareMalBlk(MalBlkPtr mb, str s);
+int prepareMalBlk(MalBlkPtr mb, str s);
void printFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int flg);
void printInstruction(stream *fd, MalBlkPtr mb, MalStkPtr stk, InstrPtr p, int
flg);
str printRef;
@@ -2430,7 +2430,7 @@ str replaceRef;
str replicatorRef;
void resetMalBlk(MalBlkPtr mb, int stop);
void resetScenario(Client c);
-void resizeMalBlk(MalBlkPtr mb, int elements);
+int resizeMalBlk(MalBlkPtr mb, int elements);
int resolveType(int dsttype, int srctype);
str resultSetRef;
str reuseRef;
diff --git a/monetdb5/mal/Tests/run b/monetdb5/mal/Tests/run
--- a/monetdb5/mal/Tests/run
+++ b/monetdb5/mal/Tests/run
@@ -4,7 +4,7 @@
DBFARM=/ufs/mk/monet5/Linux/var/MonetDB/dbfarm
DBNAME=test
#MSERVER="Mtimeout -timeout 123 mserver --dbpath=$DBFARM/$DBNAME -c All.conf
--set monet_prompt="
-MSERVER="valgrind --leak-check=full --show-reachable=yes --num-callers=20
mserver5 --dbpath=$DBFARM/$DBNAME "
+MSERVER="valgrind -v --leak-check=full --show-reachable=yes --num-callers=20
mserver5 --dbpath=$DBFARM/$DBNAME "
echo "Initialize database"
rm -rf $DBFARM/$DBNAME
diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c
--- a/monetdb5/mal/mal_builder.c
+++ b/monetdb5/mal/mal_builder.c
@@ -25,7 +25,7 @@ newAssignment(MalBlkPtr mb)
{
InstrPtr q = newInstruction(mb,NULL,NULL);
- if (q == NULL)
+ if ( q == NULL)
return NULL;
if ((getArg(q,0)= newTmpVariable(mb,TYPE_any)) < 0) {
freeInstruction(q);
@@ -44,7 +44,7 @@ newStmt(MalBlkPtr mb, const char *module
{
InstrPtr q = newInstruction(mb, putName(module), putName(name));
- if (q == NULL)
+ if ( q == NULL)
return NULL;
setDestVar(q, newTmpVariable(mb, TYPE_any));
if (getDestVar(q) < 0) {
@@ -62,20 +62,20 @@ newStmt(MalBlkPtr mb, const char *module
InstrPtr
newReturnStmt(MalBlkPtr mb)
{
- InstrPtr q = newInstruction(mb, NULL,NULL);
+ InstrPtr q = newInstruction(mb, NULL, NULL);
- if (q == NULL)
+ if ( q == NULL)
return NULL;
if ((getArg(q,0)= newTmpVariable(mb,TYPE_any)) < 0) {
freeInstruction(q);
return NULL;
}
+ q->barrier= RETURNsymbol;
pushInstruction(mb, q);
if (mb->errors) {
freeInstruction(q);
return NULL;
}
- q->barrier= RETURNsymbol;
return q;
}
@@ -84,7 +84,7 @@ newFcnCall(MalBlkPtr mb, char *mod, char
{
InstrPtr q = newAssignment(mb);
- if (q == NULL || mod == NULL || fcn == NULL)
+ if ( q == NULL || mod == NULL || fcn == NULL)
return NULL;
setModuleId(q, putName(mod));
setFunctionId(q, putName(fcn));
@@ -94,10 +94,10 @@ newFcnCall(MalBlkPtr mb, char *mod, char
InstrPtr
newComment(MalBlkPtr mb, const char *val)
{
- InstrPtr q = newInstruction(mb, NULL,NULL);
+ InstrPtr q = newInstruction(mb, NULL, NULL);
ValRecord cst;
- if (q == NULL)
+ if ( q == NULL)
return NULL;
q->token = REMsymbol;
q->barrier = 0;
@@ -108,10 +108,6 @@ newComment(MalBlkPtr mb, const char *val
}
cst.len= (int) strlen(cst.val.sval);
getArg(q,0) = defConstant(mb,TYPE_str,&cst);
- if (getArg(q,0) < 0) {
- freeInstruction(q);
- return NULL;
- }
clrVarConstant(mb,getArg(q,0));
setVarDisabled(mb,getArg(q,0));
if (mb->errors) {
@@ -119,6 +115,10 @@ newComment(MalBlkPtr mb, const char *val
return NULL;
}
pushInstruction(mb, q);
+ if (mb->errors) {
+ freeInstruction(q);
+ return NULL;
+ }
return q;
}
@@ -128,7 +128,7 @@ newCatchStmt(MalBlkPtr mb, str nme)
InstrPtr q = newAssignment(mb);
int i= findVariable(mb,nme);
- if (q == NULL)
+ if ( q == NULL)
return NULL;
q->barrier = CATCHsymbol;
if ( i< 0) {
@@ -146,7 +146,7 @@ newRaiseStmt(MalBlkPtr mb, str nme)
InstrPtr q = newAssignment(mb);
int i= findVariable(mb,nme);
- if (q == NULL)
+ if ( q == NULL)
return NULL;
q->barrier = RAISEsymbol;
if ( i< 0) {
@@ -165,7 +165,7 @@ newExitStmt(MalBlkPtr mb, str nme)
InstrPtr q = newAssignment(mb);
int i= findVariable(mb,nme);
- if (q == NULL)
+ if ( q == NULL)
return NULL;
q->barrier = EXITsymbol;
if ( i< 0) {
@@ -175,22 +175,29 @@ newExitStmt(MalBlkPtr mb, str nme)
}
} else
getArg(q,0) = i;
+ pushInstruction(mb, q);
+ if (mb->errors) {
+ freeInstruction(q);
+ return NULL;
+ }
return q;
}
InstrPtr
pushEndInstruction(MalBlkPtr mb)
{
- InstrPtr p;
+ InstrPtr q;
- p = newInstruction(mb,NULL, NULL);
- p->token = ENDsymbol;
- p->barrier = 0;
- p->argc = 0;
- p->retc = 0;
- p->argv[0] = 0;
- pushInstruction(mb, p);
- return p;
+ q = newInstruction(mb,NULL, NULL);
+ if ( q == NULL)
+ return NULL;
+ q->token = ENDsymbol;
+ q->barrier = 0;
+ q->argc = 0;
+ q->retc = 0;
+ q->argv[0] = 0;
+ pushInstruction(mb, q);
+ return q;
}
int
@@ -349,6 +356,8 @@ pushSht(MalBlkPtr mb, InstrPtr q, sht va
int _t;
ValRecord cst;
+ if ( q == NULL)
+ return NULL;
cst.vtype= TYPE_sht;
cst.val.shval= val;
cst.len = 0;
@@ -378,6 +387,8 @@ pushHge(MalBlkPtr mb, InstrPtr q, hge va
int _t;
ValRecord cst;
+ if ( q == NULL)
+ return NULL;
cst.vtype= TYPE_hge;
cst.val.hval= val;
cst.len = 0;
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -86,15 +86,15 @@ newMalBlk(int elements)
MalBlkPtr mb;
VarRecord *v;
- /* each MAL instruction implies at least on variable */
- // TODO: this check/assignment makes little sense
mb = (MalBlkPtr) GDKmalloc(sizeof(MalBlkRecord));
if (mb == NULL) {
GDKerror("newMalBlk:" MAL_MALLOC_FAIL);
return NULL;
}
- v = (VarRecord *) GDKzalloc(sizeof(VarRecord) * elements);
+ /* each MAL instruction implies at least on variable
+ * we reserve some extra for constants */
+ v = (VarRecord *) GDKzalloc(sizeof(VarRecord) * (elements + 8) );
if (v == NULL) {
GDKfree(mb);
GDKerror("newMalBlk:" MAL_MALLOC_FAIL);
@@ -134,7 +134,7 @@ newMalBlk(int elements)
}
/* We only grow until the MAL block can be used */
-void
+int
resizeMalBlk(MalBlkPtr mb, int elements)
{
int i;
@@ -149,6 +149,7 @@ resizeMalBlk(MalBlkPtr mb, int elements)
} else {
mb->errors++;
showException(GDKout, MAL, "resizeMalBlk", "out of
memory (requested: "LLFMT" bytes)", (lng) elements * sizeof(InstrPtr));
+ return -1;
}
}
@@ -161,8 +162,10 @@ resizeMalBlk(MalBlkPtr mb, int elements)
} else{
mb->errors++;
showException(GDKout, MAL, "resizeMalBlk", "out of
memory (requested: "LLFMT" bytes)", (lng) elements * sizeof(InstrPtr));
+ return -1;
}
}
+ return 0;
}
/* The resetMalBlk code removes instructions, but without freeing the
* space. This way the structure is prepared for re-use */
@@ -316,7 +319,7 @@ getMalBlkHistory(MalBlkPtr mb, int idx)
* string length could been derived from the test cases. An error in
* the estimate is more expensive than just counting the lines.
*/
-void
+int
prepareMalBlk(MalBlkPtr mb, str s)
{
int cnt = STMT_INCREMENT;
@@ -329,7 +332,7 @@ prepareMalBlk(MalBlkPtr mb, str s)
}
}
cnt = (int) (cnt * 1.1);
- resizeMalBlk(mb, cnt);
+ return resizeMalBlk(mb, cnt);
}
/* The MAL records should be managed from a pool to
@@ -350,12 +353,10 @@ newInstruction(MalBlkPtr mb, str modnme,
* The hack is to re-use an already allocated instruction.
* The marking of the block as containing errors should protect
further actions.
*/
- showException(GDKout, MAL, "newEndInstruction",
MAL_MALLOC_FAIL);
+ showException(GDKout, MAL, "newInstruction", MAL_MALLOC_FAIL);
if( mb)
mb->errors ++;
- else
- return NULL;
- p = getInstrPtr(mb,0);
+ return NULL;
}
p->maxarg = MAXARG;
p->typechk = TYPE_UNKNOWN;
@@ -665,6 +666,7 @@ newVariable(MalBlkPtr mb, const char *na
if( len >= IDLENGTH)
return -1;
if (makeVarSpace(mb))
+ /* no space for a new variable */
return -1;
n = mb->vtop;
if( name == 0 || len == 0)
@@ -1352,11 +1354,8 @@ setPolymorphic(InstrPtr p, int tpe, int
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list