Changeset: 039a2b238d13 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=039a2b238d13 Modified Files: sql/backends/monet5/sql_optimizer.c sql/backends/monet5/sql_optimizer.h sql/backends/monet5/sql_scenario.c Branch: default Log Message:
use same optimizer pipe for inlined queries. diffs (107 lines): diff --git a/sql/backends/monet5/sql_optimizer.c b/sql/backends/monet5/sql_optimizer.c --- a/sql/backends/monet5/sql_optimizer.c +++ b/sql/backends/monet5/sql_optimizer.c @@ -215,8 +215,8 @@ addOptimizers(Client c, MalBlkPtr mb, ch addtoMalBlkHistory(mb, "getStatistics"); } -void -addQueryToCache(Client c) +str +optimizeQuery(Client c) { MalBlkPtr mb; backend *be; @@ -226,13 +226,12 @@ addQueryToCache(Client c) assert(be && be->mvc); /* SQL clients should always have their state set */ pipe = getSQLoptimizer(be->mvc); - insertSymbol(c->nspace, c->curprg); trimMalBlk(c->curprg->def); c->blkmode = 0; mb = c->curprg->def; chkProgram(c->fdout, c->nspace, mb); #ifdef _SQL_OPTIMIZER_DEBUG - mnstr_printf(GDKout, "ADD QUERY TO CACHE\n"); + mnstr_printf(GDKout, "Optimize query\n"); printFunction(GDKout, mb, 0, LIST_MAL_ALL); #endif /* @@ -250,23 +249,34 @@ addQueryToCache(Client c) if (msg != MAL_SUCCEED) GDKfree(msg); /* ignore error */ } - return; + return NULL; } addOptimizers(c, mb, pipe); msg = optimizeMALBlock(c, mb); - if (msg != MAL_SUCCEED) { - showScriptException(c->fdout, mb, 0, MAL, "%s", msg); - GDKfree(msg); - return; - } + if (msg) + return msg; /* time to execute the optimizers */ if (c->debug) optimizerCheck(c, mb, "sql.baseline", -1, 0); #ifdef _SQL_OPTIMIZER_DEBUG - mnstr_printf(GDKout, "ADD optimized QUERY TO CACHE\n"); + mnstr_printf(GDKout, "End Optimize Query\n"); printFunction(GDKout, mb, 0, LIST_MAL_ALL); #endif + return NULL; +} + +void +addQueryToCache(Client c) +{ + str msg = NULL; + + insertSymbol(c->nspace, c->curprg); + msg = optimizeQuery(c); + if (msg != MAL_SUCCEED) { + showScriptException(c->fdout, c->curprg->def, 0, MAL, "%s", msg); + GDKfree(msg); + } } /* diff --git a/sql/backends/monet5/sql_optimizer.h b/sql/backends/monet5/sql_optimizer.h --- a/sql/backends/monet5/sql_optimizer.h +++ b/sql/backends/monet5/sql_optimizer.h @@ -12,6 +12,7 @@ //#define _SQL_OPTIMIZER_DEBUG +sql5_export str optimizeQuery(Client c); sql5_export void addQueryToCache(Client c); sql5_export str SQLoptimizer(Client c); sql5_export void SQLsetAccessMode(Client c); diff --git a/sql/backends/monet5/sql_scenario.c b/sql/backends/monet5/sql_scenario.c --- a/sql/backends/monet5/sql_scenario.c +++ b/sql/backends/monet5/sql_scenario.c @@ -1263,17 +1263,20 @@ recompilequery: chkTypes(c->fdout, c->nspace, c->curprg->def, TRUE); /* resolve types */ if (opt) { + str msg = optimizeQuery(c); + /* MalBlkPtr mb = c->curprg->def; trimMalBlk(mb); chkProgram(c->fdout, c->nspace, mb); addOptimizers(c, mb, "default_pipe"); // TODO change to active pipe! msg = optimizeMALBlock(c, mb); + */ if (msg != MAL_SUCCEED) { sqlcleanup(m, err); goto finalize; } - c->curprg->def = mb; + //c->curprg->def = mb; } //printFunction(c->fdout, c->curprg->def, 0, LIST_MAL_ALL); /* we know more in this case than chkProgram(c->fdout, c->nspace, c->curprg->def); */ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list