Changeset: 5d63007c9489 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5d63007c9489 Modified Files: monetdb5/optimizer/opt_pipes.c monetdb5/optimizer/opt_pipes.h monetdb5/optimizer/optimizer.c Branch: default Log Message:
Cleanup: unexport some optimizer functions, and remove unused ones. diffs (287 lines): 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 @@ -303,126 +303,6 @@ static struct PIPELINES { static MT_Lock pipeLock = MT_LOCK_INITIALIZER(pipeLock); -/* the session_pipe is the one defined by the user */ -str -addPipeDefinition(Client cntxt, const char *name, const char *pipe) -{ - int i; - str msg; - struct PIPELINES oldpipe; - - MT_lock_set(&pipeLock); - for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) - if (strcmp(name, pipes[i].name) == 0) - break; - - if (i == MAXOPTPIPES) { - MT_lock_unset(&pipeLock); - throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(HY013) "Out of slots"); - } - if (pipes[i].name && pipes[i].builtin) { - MT_lock_unset(&pipeLock); - throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(42000) "No overwrite of built in allowed"); - } - - /* save old value */ - oldpipe = pipes[i]; - pipes[i].name = GDKstrdup(name); - pipes[i].def = GDKstrdup(pipe); - pipes[i].status = GDKstrdup("experimental"); - if(pipes[i].name == NULL || pipes[i].def == NULL || pipes[i].status == NULL) { - GDKfree(pipes[i].name); - GDKfree(pipes[i].def); - GDKfree(pipes[i].status); - pipes[i].name = oldpipe.name; - pipes[i].def = oldpipe.def; - pipes[i].status = oldpipe.status; - MT_lock_unset(&pipeLock); - throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(HY013) MAL_MALLOC_FAIL); - } - pipes[i].mb = NULL; - MT_lock_unset(&pipeLock); - msg = compileOptimizer(cntxt, name); - if (msg) { - /* failed: restore old value */ - MT_lock_set(&pipeLock); - GDKfree(pipes[i].name); - GDKfree(pipes[i].def); - GDKfree(pipes[i].status); - pipes[i] = oldpipe; - MT_lock_unset(&pipeLock); - } else { - /* succeeded: destroy old value */ - if (oldpipe.name) - GDKfree(oldpipe.name); - if (oldpipe.def) - GDKfree(oldpipe.def); - if (oldpipe.mb) - freeMalBlk(oldpipe.mb); - if (oldpipe.status) - GDKfree(oldpipe.status); - } - return msg; -} - -int -isOptimizerPipe(const char *name) -{ - int i; - - for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) - if (strcmp(name, pipes[i].name) == 0) - return TRUE; - return FALSE; -} - -str -getPipeDefinition(str name) -{ - int i; - - for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) - if (strcmp(name, pipes[i].name) == 0) - return GDKstrdup(pipes[i].def); - return NULL; -} - -str -getPipeCatalog(bat *nme, bat *def, bat *stat) -{ - BAT *b, *bn, *bs; - int i; - - b = COLnew(0, TYPE_str, 20, TRANSIENT); - bn = COLnew(0, TYPE_str, 20, TRANSIENT); - bs = COLnew(0, TYPE_str, 20, TRANSIENT); - if (b == NULL || bn == NULL || bs == NULL) { - BBPreclaim(b); - BBPreclaim(bn); - BBPreclaim(bs); - throw(MAL, "optimizer.getpipeDefinition", SQLSTATE(HY013) MAL_MALLOC_FAIL); - } - - for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) { - if (BUNappend(b, pipes[i].name, false) != GDK_SUCCEED || - BUNappend(bn, pipes[i].def, false) != GDK_SUCCEED || - BUNappend(bs, pipes[i].status, false) != GDK_SUCCEED) { - BBPreclaim(b); - BBPreclaim(bn); - BBPreclaim(bs); - throw(MAL, "optimizer.getpipeDefinition", SQLSTATE(HY013) MAL_MALLOC_FAIL); - } - } - - *nme = b->batCacheid; - BBPkeepref(b); - *def = bn->batCacheid; - BBPkeepref(bn); - *stat = bs->batCacheid; - BBPkeepref(bs); - return MAL_SUCCEED; -} - static str validatePipe(MalBlkPtr mb) { @@ -500,7 +380,7 @@ validateOptimizerPipes(void) * Compile (the first time) an optimizer pipe string * then copy the statements to the end of the MAL plan */ -str +static str compileOptimizer(Client cntxt, const char *name) { int i, j; @@ -531,18 +411,115 @@ compileOptimizer(Client cntxt, const cha return msg; } +/* the session_pipe is the one defined by the user */ str -compileAllOptimizers(Client cntxt) +addPipeDefinition(Client cntxt, const char *name, const char *pipe) { int i; - str msg = MAL_SUCCEED; + str msg; + struct PIPELINES oldpipe; + + MT_lock_set(&pipeLock); + for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) + if (strcmp(name, pipes[i].name) == 0) + break; + + if (i == MAXOPTPIPES) { + MT_lock_unset(&pipeLock); + throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(HY013) "Out of slots"); + } + if (pipes[i].name && pipes[i].builtin) { + MT_lock_unset(&pipeLock); + throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(42000) "No overwrite of built in allowed"); + } - for(i=0;pipes[i].def && msg == MAL_SUCCEED; i++){ - msg =compileOptimizer(cntxt,pipes[i].name); + /* save old value */ + oldpipe = pipes[i]; + pipes[i].name = GDKstrdup(name); + pipes[i].def = GDKstrdup(pipe); + pipes[i].status = GDKstrdup("experimental"); + if(pipes[i].name == NULL || pipes[i].def == NULL || pipes[i].status == NULL) { + GDKfree(pipes[i].name); + GDKfree(pipes[i].def); + GDKfree(pipes[i].status); + pipes[i].name = oldpipe.name; + pipes[i].def = oldpipe.def; + pipes[i].status = oldpipe.status; + MT_lock_unset(&pipeLock); + throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(HY013) MAL_MALLOC_FAIL); + } + pipes[i].mb = NULL; + MT_lock_unset(&pipeLock); + msg = compileOptimizer(cntxt, name); + if (msg) { + /* failed: restore old value */ + MT_lock_set(&pipeLock); + GDKfree(pipes[i].name); + GDKfree(pipes[i].def); + GDKfree(pipes[i].status); + pipes[i] = oldpipe; + MT_lock_unset(&pipeLock); + } else { + /* succeeded: destroy old value */ + if (oldpipe.name) + GDKfree(oldpipe.name); + if (oldpipe.def) + GDKfree(oldpipe.def); + if (oldpipe.mb) + freeMalBlk(oldpipe.mb); + if (oldpipe.status) + GDKfree(oldpipe.status); } return msg; } +int +isOptimizerPipe(const char *name) +{ + int i; + + for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) + if (strcmp(name, pipes[i].name) == 0) + return TRUE; + return FALSE; +} + +str +getPipeCatalog(bat *nme, bat *def, bat *stat) +{ + BAT *b, *bn, *bs; + int i; + + b = COLnew(0, TYPE_str, 20, TRANSIENT); + bn = COLnew(0, TYPE_str, 20, TRANSIENT); + bs = COLnew(0, TYPE_str, 20, TRANSIENT); + if (b == NULL || bn == NULL || bs == NULL) { + BBPreclaim(b); + BBPreclaim(bn); + BBPreclaim(bs); + throw(MAL, "optimizer.getpipeDefinition", SQLSTATE(HY013) MAL_MALLOC_FAIL); + } + + for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) { + if (BUNappend(b, pipes[i].name, false) != GDK_SUCCEED || + BUNappend(bn, pipes[i].def, false) != GDK_SUCCEED || + BUNappend(bs, pipes[i].status, false) != GDK_SUCCEED) { + BBPreclaim(b); + BBPreclaim(bn); + BBPreclaim(bs); + throw(MAL, "optimizer.getpipeDefinition", SQLSTATE(HY013) MAL_MALLOC_FAIL); + } + } + + *nme = b->batCacheid; + BBPkeepref(b); + *def = bn->batCacheid; + BBPkeepref(bn); + *stat = bs->batCacheid; + BBPkeepref(bs); + return MAL_SUCCEED; +} + /* * Add a new components of the optimizer pipe to the plan */ diff --git a/monetdb5/optimizer/opt_pipes.h b/monetdb5/optimizer/opt_pipes.h --- a/monetdb5/optimizer/opt_pipes.h +++ b/monetdb5/optimizer/opt_pipes.h @@ -13,13 +13,10 @@ #include "opt_prelude.h" #include "opt_support.h" -extern str getPipeDefinition(str name); mal_export str getPipeCatalog(bat *nme, bat *def, bat *stat); mal_export str addPipeDefinition(Client cntxt, const char *name, const char *pipe); mal_export int isOptimizerPipe(const char *name); mal_export str addOptimizerPipe(Client cntxt, MalBlkPtr mb, const char *name); -extern str compileOptimizer(Client cntxt, const char *name); -extern str compileAllOptimizers(Client cntxt); mal_export void opt_pipes_reset(void); #endif diff --git a/monetdb5/optimizer/optimizer.c b/monetdb5/optimizer/optimizer.c --- a/monetdb5/optimizer/optimizer.c +++ b/monetdb5/optimizer/optimizer.c @@ -37,7 +37,6 @@ optimizer_prelude(void) { updateScenario("mal", "MALoptimizer", (MALfcn) MALoptimizer); optimizerInit(); - //return compileAllOptimizers(cntxt); causes problems return MAL_SUCCEED; } _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org