Changeset: d55cf5149549 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d55cf5149549 Modified Files: clients/Tests/exports.stable.out monetdb5/mal/mal_debugger.c monetdb5/mal/mal_debugger.h monetdb5/modules/mal/mdb.c sql/backends/monet5/sql_execute.c sql/backends/monet5/sql_optimizer.c sql/backends/monet5/sql_scenario.c sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out Branch: default Log Message:
Remove mdb calls from query wrapper. diffs (214 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 @@ -2443,7 +2443,7 @@ str rsColumnRef; int rule_fromstr(const char *buf, int *len, rule **d); int rule_tostr(str *buf, int *len, const rule *r); str runMAL(Client c, MalBlkPtr mb, MalBlkPtr mbcaller, MalStkPtr env); -str runMALDebugger(Client cntxt, Symbol s); +str runMALDebugger(Client cntxt, MalBlkPtr mb); str runMALdataflow(Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk); str runMALsequence(Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller); str runScenario(Client c); diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c --- a/monetdb5/mal/mal_debugger.c +++ b/monetdb5/mal/mal_debugger.c @@ -1144,10 +1144,26 @@ mdbTrapClient(Client cntxt, MalBlkPtr mb * creation of a minimal execution environment first. */ str -runMALDebugger(Client cntxt, Symbol s) +runMALDebugger(Client cntxt, MalBlkPtr mb) { + str oldprompt= cntxt->prompt; + int oldtrace = cntxt->itrace; + int oldopt = cntxt->debugOptimizer; + int oldhist = cntxt->curprg->def->keephistory; + str msg; + cntxt->itrace = 'n'; - return runMAL(cntxt, s->def, 0, 0); + cntxt->debugOptimizer = TRUE; + cntxt->curprg->def->keephistory = TRUE; + + msg = runMAL(cntxt, mb, 0, 0); + + cntxt->curprg->def->keephistory = oldhist; + cntxt->prompt =oldprompt; + cntxt->itrace = oldtrace; + cntxt->debugOptimizer = oldopt; + mnstr_printf(cntxt->fdout, "mdb>#EOD\n"); + return msg; } /* Utilities diff --git a/monetdb5/mal/mal_debugger.h b/monetdb5/mal/mal_debugger.h --- a/monetdb5/mal/mal_debugger.h +++ b/monetdb5/mal/mal_debugger.h @@ -28,7 +28,7 @@ mal_export int mdbSession(void); mal_export void mdbDump(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); mal_export void printStack(stream *f, MalBlkPtr mb, MalStkPtr s); -mal_export str runMALDebugger(Client cntxt, Symbol s); +mal_export str runMALDebugger(Client cntxt, MalBlkPtr mb); mal_export str debugOptimizers(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); mal_export void debugLifespan(Client cntxt, MalBlkPtr mb, Lifespan span); diff --git a/monetdb5/modules/mal/mdb.c b/monetdb5/modules/mal/mdb.c --- a/monetdb5/modules/mal/mdb.c +++ b/monetdb5/modules/mal/mdb.c @@ -249,7 +249,7 @@ MDBinspect(Client cntxt, MalBlkPtr mb, M if (s == NULL) throw(MAL, "mdb.inspect", RUNTIME_SIGNATURE_MISSING); - return runMALDebugger(cntxt, s); + return runMALDebugger(cntxt, s->def); } /* diff --git a/sql/backends/monet5/sql_execute.c b/sql/backends/monet5/sql_execute.c --- a/sql/backends/monet5/sql_execute.c +++ b/sql/backends/monet5/sql_execute.c @@ -220,8 +220,13 @@ SQLstatementIntern(Client c, str *expr, if (!output) sql->out = NULL; /* no output stream */ - if (execute) - msg = runMAL(c, c->curprg->def, 0, 0); + if (execute){ + // first consider running in debug mode + if( m->emod & mod_debug) + msg = runMALDebugger(c, c->curprg->def); + else + msg = runMAL(c, c->curprg->def, 0, 0); + } MSresetInstructions(c->curprg->def, oldstop); freeVariables(c, c->curprg->def, NULL, oldvtop); @@ -442,7 +447,11 @@ SQLengineIntern(Client c, backend *be) if (MALcommentsOnly(c->curprg->def)) { msg = MAL_SUCCEED; } else { - msg = (str) runMAL(c, c->curprg->def, 0, 0); + // first consider running in debug mode + if( m->emod & mod_debug) + msg = runMALDebugger(c, c->curprg->def); + else + msg = runMAL(c, c->curprg->def, 0, 0); } cleanup_engine: @@ -521,8 +530,12 @@ RAstatement(Client cntxt, MalBlkPtr mb, msg = createException(SQL,"RAstatement","Program contains errors"); else { addQueryToCache(cntxt); - msg = (str) runMAL(cntxt, cntxt->curprg->def, 0, 0); - } + // first consider running in debug mode + if( m->emod & mod_debug) + msg = runMALDebugger(cntxt, cntxt->curprg->def); + else + msg = runMAL(cntxt, cntxt->curprg->def, 0, 0); + } if (!msg) { resetMalBlk(cntxt->curprg->def, oldstop); freeVariables(cntxt, cntxt->curprg->def, NULL, oldvtop); 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 @@ -178,7 +178,7 @@ optimizeQuery(Client c) if (c->listing) printFunction(c->fdout, mb, 0, c->listing); if (be->mvc->debug) { - msg = runMALDebugger(c, c->curprg); + msg = runMALDebugger(c, c->curprg->def); if (msg != MAL_SUCCEED) GDKfree(msg); /* ignore error */ } 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 @@ -865,22 +865,6 @@ SQLreader(Client c) * The current analysis is simple and fulfills our short-term needs. * A future version may analyze the parameter settings in more detail. */ -static void -SQLsetDebugger(Client c, mvc *m, int onoff) -{ - if (m == 0 || !(m->emod & mod_debug)) - return; - c->itrace = 'n'; - if (onoff) { - newStmt(c->curprg->def, "mdb", "start"); - c->debugOptimizer = TRUE; - c->curprg->def->keephistory = TRUE; - } else { - newStmt(c->curprg->def, "mdb", "stop"); - c->debugOptimizer = FALSE; - c->curprg->def->keephistory = FALSE; - } -} /* * The trace operation collects the events in the BATs @@ -1018,13 +1002,16 @@ caching(mvc *m) static int cachable(mvc *m, stmt *s) { - if (m->emode == m_prepare) + if (m->emode == m_prepare) /* prepared plans are always cached */ return 1; - if (m->emode == m_plan) + if (m->emode == m_plan) /* we plan to display without execution */ return 0; - if (m->type == Q_TRANS || /*m->type == Q_SCHEMA || cachable to make sure we have trace on alter statements */ - (s && s->type == st_none) || sa_size(m->sa) > MAX_QUERY) + if (m->type == Q_TRANS ) /* m->type == Q_SCHEMA || cachable to make sure we have trace on alter statements */ return 0; + /* we don't store empty sequences, nor queries with a large footprint */ + if( (s && s->type == st_none) || sa_size(m->sa) > MAX_QUERY) + return 0; + /* remainders covers: m_execute, m_inplace, m_normal*/ return 1; } @@ -1200,8 +1187,7 @@ SQLparser(Client c) m->emode = m_inplace; scanner_query_processed(&(m->scanner)); } else if (caching(m) && cachable(m, NULL) && m->emode != m_prepare && (be->q = qc_match(m->qc, m->sym, m->args, m->argc, m->scanner.key ^ m->session->schema->base.id)) != NULL) { - /* query template was found in the query cache be */ - SQLsetDebugger(c, m, TRUE); + /* query template was found in the query cache */ SQLsetTrace(c, m, TRUE); if (!(m->emod & (mod_explain | mod_debug | mod_trace ))) m->emode = m_inplace; @@ -1223,7 +1209,6 @@ SQLparser(Client c) /* generate the MAL prelude code in the query wrapper */ SQLsetTrace(c, m, TRUE); - SQLsetDebugger(c, m, TRUE); if (!caching(m) || !cachable(m, s)) { /* Query template should not be cached */ @@ -1281,7 +1266,6 @@ SQLparser(Client c) /* In the final phase we add any debugging control */ SQLsetTrace(c, m, FALSE); - SQLsetDebugger(c, m, FALSE); pushEndInstruction(c->curprg->def); /* check the query wrapper for errors */ diff --git a/sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out b/sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out --- a/sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out +++ b/sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out @@ -21,8 +21,8 @@ Ready. # 16:24:01 > #debug select * from tables; -mdb>#mdb.start(); -mdb>#X_2=0@0:void := user.s1_1(); +mdb>#X_1=0@0:void := user.s1_1(); +mdb>#X_159=0@0:void := querylog.define("debug select * from tables;","default_pipe",630); # 16:24:01 > # 16:24:01 > "Done." _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list