Changeset: 1f87e39706c2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1f87e39706c2
Modified Files:
monetdb5/mal/mal_client.c
monetdb5/mal/mal_function.c
monetdb5/mal/mal_function.h
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_instruction.h
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_prelude.c
monetdb5/mal/mal_session.c
monetdb5/modules/mal/manifold.c
monetdb5/modules/mal/orderidx.c
monetdb5/modules/mal/remote.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_gencode.c
tools/monetdbe/monetdbe.c
Branch: resource_management
Log Message:
revert changes as each mal blk needs its own allocator
diffs (truncated from 319 to 300 lines):
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -458,7 +458,7 @@ MCcloseClient(Client c)
c->mode = FREECLIENT;
c->idx = -1;
}
- ma_destroy(c->ta);
+ c->ta = NULL;
ma_destroy(c->alloc);
MT_lock_unset(&mal_contextLock);
}
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
@@ -23,14 +23,14 @@
#include "mal_private.h"
Symbol
-newFunctionArgs(allocator *pa, const char *mod, const char *nme, int kind, int
args)
+newFunctionArgs(const char *mod, const char *nme, int kind, int args)
{
Symbol s;
if (mod == NULL || nme == NULL)
return NULL;
- s = newSymbol(pa, nme, kind);
+ s = newSymbol(nme, kind);
if (s == NULL)
return NULL;
@@ -61,9 +61,9 @@ newFunctionArgs(allocator *pa, const cha
}
Symbol
-newFunction(allocator *pa, const char *mod, const char *nme, int kind)
+newFunction(const char *mod, const char *nme, int kind)
{
- return newFunctionArgs(pa, mod, nme, kind, MAXARG);
+ return newFunctionArgs(mod, nme, kind, MAXARG);
}
int
@@ -331,7 +331,7 @@ cloneFunction(Module scope, Symbol proc,
InstrPtr pp;
str msg = MAL_SUCCEED;
- new = newFunctionArgs(NULL, scope->name, proc->name, proc->kind, -1);
+ new = newFunctionArgs(scope->name, proc->name, proc->kind, -1);
if (new == NULL) {
return NULL;
}
diff --git a/monetdb5/mal/mal_function.h b/monetdb5/mal/mal_function.h
--- a/monetdb5/mal/mal_function.h
+++ b/monetdb5/mal/mal_function.h
@@ -21,9 +21,8 @@
#define getEndScope(L,I) ((L)->var[I].eolife)
#define getBeginScope(L,I) ((L)->var[I].declared)
-mal_export Symbol newFunction(allocator *pa, const char *mod, const char *nme,
int kind);
-mal_export Symbol newFunctionArgs(allocator *pa, const char *mod, const char
*nme, int kind,
- int args);
+mal_export Symbol newFunction(const char *mod, const char *nme, int kind);
+mal_export Symbol newFunctionArgs(const char *mod, const char *nme, int kind,
int args);
mal_export int getPC(MalBlkPtr mb, InstrPtr p);
mal_export str chkFlow(MalBlkPtr mb);
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
@@ -40,7 +40,7 @@ addMalException(MalBlkPtr mb, str msg)
}
Symbol
-newSymbol(allocator *pa, const char *nme, int kind)
+newSymbol(const char *nme, int kind)
{
Symbol cur;
@@ -59,7 +59,7 @@ newSymbol(allocator *pa, const char *nme
return NULL;
}
if (kind == FUNCTIONsymbol) {
- cur->def = newMalBlk(pa, STMT_INCREMENT);
+ cur->def = newMalBlk(STMT_INCREMENT);
if (cur->def == NULL) {
GDKfree(cur);
return NULL;
@@ -114,12 +114,10 @@ newMalBlkStmt(MalBlkPtr mb, int maxstmts
}
MalBlkPtr
-newMalBlk(allocator *pa, int elements)
+newMalBlk(int elements)
{
MalBlkPtr mb;
VarRecord *v;
- // TODO why I cannot pass pa as parent
- (void) pa;
allocator *ma = ma_create(NULL);
if (!ma)
diff --git a/monetdb5/mal/mal_instruction.h b/monetdb5/mal/mal_instruction.h
--- a/monetdb5/mal/mal_instruction.h
+++ b/monetdb5/mal/mal_instruction.h
@@ -153,12 +153,12 @@ mal_export InstrPtr copyInstructionArgs(
mal_export void clrInstruction(InstrPtr p);
mal_export void freeInstruction(MalBlkPtr mb, InstrPtr p);
mal_export void clrFunction(InstrPtr p);
-mal_export Symbol newSymbol(allocator *pa, const char *nme, int kind);
+mal_export Symbol newSymbol(const char *nme, int kind);
mal_export void freeSymbol(Symbol s);
mal_export void freeSymbolList(Symbol s);
mal_export void printSignature(stream *fd, Symbol s, int flg);
-mal_export MalBlkPtr newMalBlk(allocator *pa, int elements);
+mal_export MalBlkPtr newMalBlk(int elements);
mal_export void resetMalBlk(MalBlkPtr mb);
mal_export void resetMalTypes(MalBlkPtr mb, int stop);
mal_export int newMalBlkStmt(MalBlkPtr mb, int elements);
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
@@ -1560,7 +1560,7 @@ parseCommandPattern(Client cntxt, int ki
return NULL;
}
- Symbol curPrg = newFunctionArgs(cntxt->alloc, modnme, curFunc->fcn,
kind, -1);
+ Symbol curPrg = newFunctionArgs(modnme, curFunc->fcn, kind, -1);
if (!curPrg) {
mf_destroy(curFunc);
parseError(cntxt, SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -1692,7 +1692,7 @@ fcnHeader(Client cntxt, int kind)
if (nargs < 0)
return 0;
/* one extra for argument/return manipulation */
- cntxt->curprg = newFunctionArgs(cntxt->alloc, modnme, fnme, kind, nargs
+ 1);
+ cntxt->curprg = newFunctionArgs(modnme, fnme, kind, nargs + 1);
if (cntxt->curprg == NULL) {
/* reinstate curprg to have a place for the error */
cntxt->curprg = cntxt->backup;
diff --git a/monetdb5/mal/mal_prelude.c b/monetdb5/mal/mal_prelude.c
--- a/monetdb5/mal/mal_prelude.c
+++ b/monetdb5/mal/mal_prelude.c
@@ -217,7 +217,7 @@ addFunctions(mel_func *fcn)
if (c == NULL && (c = globalModule(mod)) == NULL)
throw(LOADER, __func__, "Module %s can not be created",
mod);
- s = newSymbol(NULL, fcn->fcn, (fcn->command) ? COMMANDsymbol :
PATTERNsymbol);
+ s = newSymbol(fcn->fcn, (fcn->command) ? COMMANDsymbol :
PATTERNsymbol);
if (s == NULL)
throw(LOADER, __func__, "Can not create symbol for
%s.%s missing", mod,
fcn->fcn);
@@ -298,7 +298,7 @@ melFunction(bool command, const char *mo
if (c == NULL && (c = globalModule(mod)) == NULL)
return MEL_ERR;
- s = newSymbol(NULL, fcn, command ? COMMANDsymbol : PATTERNsymbol);
+ s = newSymbol(fcn, command ? COMMANDsymbol : PATTERNsymbol);
if (s == NULL)
return MEL_ERR;
fcn = s->name;
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
@@ -121,7 +121,7 @@ MSinitClientPrg(Client cntxt, const char
if (cntxt->curprg && idcmp(nme, cntxt->curprg->name) == 0)
return MSresetClientPrg(cntxt, putName(mod), putName(nme));
- cntxt->curprg = newFunction(cntxt->alloc, putName(mod), putName(nme),
FUNCTIONsymbol);
+ cntxt->curprg = newFunction(putName(mod), putName(nme), FUNCTIONsymbol);
if (cntxt->curprg == 0)
throw(MAL, "initClientPrg", SQLSTATE(HY013) MAL_MALLOC_FAIL);
if ((idx = findVariable(cntxt->curprg->def, mainRef)) >= 0)
diff --git a/monetdb5/modules/mal/manifold.c b/monetdb5/modules/mal/manifold.c
--- a/monetdb5/modules/mal/manifold.c
+++ b/monetdb5/modules/mal/manifold.c
@@ -234,7 +234,7 @@ MANIFOLDtypecheck(Client cntxt, MalBlkPt
if (pci->retc > 1 || pci->argc > 8 || getModuleId(pci) == NULL) //
limitation on MANIFOLDjob
return NULL;
// We need a private MAL context to resolve the function call
- nmb = newMalBlk(cntxt->alloc, 2);
+ nmb = newMalBlk(2);
if (nmb == NULL) {
mb->errors = createException(MAL, "mal.manifold",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
return NULL;
diff --git a/monetdb5/modules/mal/orderidx.c b/monetdb5/modules/mal/orderidx.c
--- a/monetdb5/modules/mal/orderidx.c
+++ b/monetdb5/modules/mal/orderidx.c
@@ -101,7 +101,7 @@ OIDXcreateImplementation(Client cntxt, i
/* create a temporary MAL function to sort the BAT in parallel */
snprintf(name, IDLENGTH, "sort%d", rand() % 1000);
- snew = newFunction(cntxt->alloc, userRef, putName(name),
FUNCTIONsymbol);
+ snew = newFunction(userRef, putName(name), FUNCTIONsymbol);
if (snew == NULL) {
throw(MAL, "bat.orderidx", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -1212,7 +1212,7 @@ RMTregisterInternal(Client cntxt, char *
}
Symbol prg;
- if ((prg = newFunctionArgs(cntxt->alloc, putName(mod),
putName(*fcn_id), FUNCTIONsymbol, -1)) == NULL) {
+ if ((prg = newFunctionArgs(putName(mod), putName(*fcn_id),
FUNCTIONsymbol, -1)) == NULL) {
MT_lock_unset(&c->lock);
throw(MAL, "Remote register", MAL_MALLOC_FAIL);
}
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -4947,7 +4947,7 @@ SQLunionfunc(Client cntxt, MalBlkPtr mb,
int arg = pci->retc;
str mod, fcn, ret = MAL_SUCCEED;
InstrPtr npci;
- MalBlkPtr nmb = newMalBlk(cntxt->alloc, 1), omb = NULL;
+ MalBlkPtr nmb = newMalBlk(1), omb = NULL;
if (!nmb)
return createException(MAL, "sql.unionfunc", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
diff --git a/sql/backends/monet5/sql_gencode.c
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -292,7 +292,7 @@ static int
sql_rel *nr = relational_func_create_result_part1(m, r, &nargs);
nargs += (call && call->type == st_list) ? list_length(call->op4.lval)
: rel_ops ? list_length(rel_ops) : 0;
- c->curprg = newFunctionArgs(c->alloc, putName(mod), putName(name),
FUNCTIONsymbol, nargs);
+ c->curprg = newFunctionArgs(putName(mod), putName(name),
FUNCTIONsymbol, nargs);
if (c->curprg == NULL) {
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto bailout;
@@ -949,7 +949,7 @@ static int
sql_rel *rel2 = relational_func_create_result_part1(m, rel, &nargs);
if (call && call->type == st_list)
nargs += list_length(call->op4.lval);
- c->curprg = newFunctionArgs(c->alloc, putName(mod), putName(name),
FUNCTIONsymbol, nargs);
+ c->curprg = newFunctionArgs(putName(mod), putName(name),
FUNCTIONsymbol, nargs);
if (c->curprg == NULL) {
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto bailout;
@@ -1181,7 +1181,7 @@ backend_dumpproc(backend *be, Client c,
if (argc < MAXARG)
argc = MAXARG;
assert(cq && strlen(cq->name) < IDLENGTH);
- c->curprg = newFunctionArgs(c->alloc, sql_private_module, cq->name =
putName(cq->name), FUNCTIONsymbol, argc);
+ c->curprg = newFunctionArgs(sql_private_module, cq->name =
putName(cq->name), FUNCTIONsymbol, argc);
if (c->curprg == NULL) {
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto bailout;
@@ -1650,7 +1650,7 @@ backend_create_sql_func(backend *be, sql
(void) snprintf(befname, IDLENGTH, "f_" LLFMT,
store_function_counter(m->store));
TRC_INFO(SQL_PARSER, "Mapping SQL name '%s' to MAL name '%s'\n",
f->base.name, befname);
nargs = (f->res && f->type == F_UNION ? list_length(f->res) : 1) +
(f->vararg && ops ? list_length(ops) : f->ops ? list_length(f->ops) : 0);
- c->curprg = newFunctionArgs(c->alloc, modname, putName(befname),
FUNCTIONsymbol, nargs);
+ c->curprg = newFunctionArgs(modname, putName(befname), FUNCTIONsymbol,
nargs);
if ((fimp = _STRDUP(befname)) == NULL) {
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -816,7 +816,7 @@ monetdbe_open_remote(monetdbe_database_i
const char mod[] = "user";
char nme[16];
const char *name = number2name(nme, sizeof(nme), ++((backend*)
c->sqlcontext)->remote);
- c->curprg = newFunction(c->alloc, putName(mod), putName(name),
FUNCTIONsymbol);
+ c->curprg = newFunction(putName(mod), putName(name), FUNCTIONsymbol);
if (c->curprg == NULL) {
set_error(mdbe, createException(MAL,
"monetdbe.monetdbe_open_remote", MAL_MALLOC_FAIL));
@@ -1278,7 +1278,7 @@ monetdbe_prepare_cb(void* context, char*
assert (((backend*) mdbe->c->sqlcontext)->remote < INT_MAX);
char nme[16] = {0};
const char* name = number2name(nme, sizeof(nme),
++((backend*) mdbe->c->sqlcontext)->remote);
- prg =
newFunctionArgs(mdbe->c->alloc, userRef, putName(name), FUNCTIONsymbol, (int)
nparams + 1);
+ prg =
newFunctionArgs(userRef, putName(name), FUNCTIONsymbol, (int) nparams + 1);
}
resizeMalBlk(prg->def, (int) nparams + 3 /*function declaration +
remote.exec + return statement*/);
@@ -1396,7 +1396,7 @@ monetdbe_prepare_cb(void* context, char*
*/
prg->def = NULL;
freeSymbol(prg);
- if ((prg = newFunctionArgs(mdbe->c->alloc, userRef,
putName(be->q->name), FUNCTIONsymbol, -1)) == NULL) {
+ if ((prg = newFunctionArgs(userRef, putName(be->q->name),
FUNCTIONsymbol, -1)) == NULL) {
msg = createException(MAL, "monetdbe.monetdbe_prepare_cb",
MAL_MALLOC_FAIL);
goto cleanup;
}
@@ -1439,7 +1439,7 @@ monetdbe_query_remote(monetdbe_database_
Client c = mdbe->c;
const char *name = number2name(nme, sizeof(nme), ++((backend*)
c->sqlcontext)->remote);
- Symbol prg = newFunction(c->alloc, putName(mod), putName(name),
FUNCTIONsymbol);
+ Symbol prg = newFunction(putName(mod), putName(name), FUNCTIONsymbol);
if (prg == NULL) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]