Changeset: 6b57206bf79a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6b57206bf79a
Modified Files:
monetdb5/mal/mal_scenario.c
monetdb5/mal/mal_scenario.h
sql/backends/monet5/sql_execute.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_scenario.h
sql/server/rel_optimize_proj.c
tools/monetdbe/monetdbe.c
Branch: simplify_scenario
Log Message:
for sql layer start the scenario simplification, ie reader/parser/engine (and
optmizer) in one.
Remove tactics from scenario
diffs (truncated from 1330 to 300 lines):
diff --git a/monetdb5/mal/mal_scenario.c b/monetdb5/mal/mal_scenario.c
--- a/monetdb5/mal/mal_scenario.c
+++ b/monetdb5/mal/mal_scenario.c
@@ -14,8 +14,8 @@
* In MonetDB multiple languages, optimizers, and execution engines can
* be combined at run time to satisfy a wide user-community.
* Such an assemblage of components is called a @emph{scenario}
- * and consists of a @emph{reader}, @emph{parser}, @emph{optimizer},
- * @emph{tactic scheduler} and @emph{engine}. These hooks allow
+ * and consists of a @emph{reader}, @emph{parser}, @emph{optimizer}
+ * and @emph{engine}. These hooks allow
* for both linked-in and external components.
*
* The languages supported are SQL, the Monet Assembly Language (MAL), and
profiler.
@@ -42,13 +42,6 @@
* at hand. Optimizers leave advice and their findings in properties
* in the symbol table, see @ref{Property Management}.
*
- * Once the program has thus been refined, the
- * MAL scheduler prepares for execution using tactical optimizations.
- * For example, it may parallelize the code, generate an ad-hoc
- * user-defined function, or prepare for efficient replication management.
- * In the default case, the program is handed over to the MAL interpreter
- * without any further modification.
- *
* The final stage is to choose an execution paradigm,
* i.e. interpretative (default), compilation of an ad-hoc user
* defined function, dataflow driven interpretation,
@@ -82,7 +75,7 @@
* each individual client. Sharing this information between clients
* should be dealt with in the implementation of the scenario managers.
* Upon need, the client can postpone a session scenario by
- * pushing a new one(language, optimize, tactic,
+ * pushing a new one(language, optimize,
* processor). Propagation of the state information is
* encapsulated a scenario2scenario() call. Not all transformations
* may be legal.
@@ -182,7 +175,6 @@ showScenario(stream *f, Scenario scen)
print_scenarioCommand(f, scen->exitClient, scen->exitClientCmd);
print_scenarioCommand(f, scen->parser, scen->parserCmd);
print_scenarioCommand(f, scen->optimizer, scen->optimizerCmd);
- print_scenarioCommand(f, scen->tactics, scen->tacticsCmd);
print_scenarioCommand(f, scen->callback, scen->callbackCmd);
print_scenarioCommand(f, scen->engine, scen->engineCmd);
mnstr_printf(f, "]\n");
@@ -239,10 +231,6 @@ updateScenario(str nme, str fnme, MALfcn
scen->optimizerCmd = fcn;
phase = MAL_SCENARIO_OPTIMIZE;
}
- if (scen->tactics && strcmp(scen->tactics, fnme) == 0) {
- scen->tacticsCmd = fcn;
- phase = MAL_SCENARIO_SCHEDULER;
- }
if (scen->callback && strcmp(scen->callback, fnme) == 0) {
scen->callbackCmd = fcn;
phase = MAL_SCENARIO_CALLBACK;
@@ -311,7 +299,6 @@ fillScenario(Client c, Scenario scen)
c->phase[MAL_SCENARIO_READER] = scen->readerCmd;
c->phase[MAL_SCENARIO_PARSER] = scen->parserCmd;
c->phase[MAL_SCENARIO_OPTIMIZE] = scen->optimizerCmd;
- c->phase[MAL_SCENARIO_SCHEDULER] = scen->tacticsCmd;
c->phase[MAL_SCENARIO_CALLBACK] = scen->callbackCmd;
c->phase[MAL_SCENARIO_ENGINE] = scen->engineCmd;
c->phase[MAL_SCENARIO_INITCLIENT] = scen->initClientCmd;
@@ -319,7 +306,6 @@ fillScenario(Client c, Scenario scen)
c->state[MAL_SCENARIO_READER] = 0;
c->state[MAL_SCENARIO_PARSER] = 0;
c->state[MAL_SCENARIO_OPTIMIZE] = 0;
- c->state[MAL_SCENARIO_SCHEDULER] = 0;
c->state[MAL_SCENARIO_ENGINE] = 0;
c->state[MAL_SCENARIO_INITCLIENT] = 0;
c->state[MAL_SCENARIO_EXITCLIENT] = 0;
@@ -421,11 +407,6 @@ resetScenario(Client c)
* The @sc{xyzoptimizer(Client c)} contains language specific optimizations
* using the MAL intermediate code as a starting point.
*
- * The @sc{xyztactics(Client c)} synchronizes the program execution with the
- * state of the machine, e.g., claiming resources, the history of the client
- * or alignment of the request with concurrent actions (e.g., transaction
- * coordination).
- *
* The @sc{xyzengine(Client c)} contains the applicable back-end engine.
* The default is the MAL interpreter, which provides good balance
* between speed and ability to analysis its behavior.
@@ -439,7 +420,6 @@ static const char *phases[] = {
[MAL_SCENARIO_OPTIMIZE] = "scenario optimize",
[MAL_SCENARIO_PARSER] = "scenario parser",
[MAL_SCENARIO_READER] = "scenario reader",
- [MAL_SCENARIO_SCHEDULER] = "scenario scheduler",
};
static str
runPhase(Client c, int phase)
@@ -470,8 +450,6 @@ runScenarioBody(Client c)
goto wrapup;
if ( c->mode <= FINISHCLIENT || (msg = runPhase(c,
MAL_SCENARIO_OPTIMIZE)) )
goto wrapup;
- if ( c->mode <= FINISHCLIENT || (msg = runPhase(c,
MAL_SCENARIO_SCHEDULER)))
- goto wrapup;
if ( c->mode <= FINISHCLIENT || (msg = runPhase(c,
MAL_SCENARIO_ENGINE)))
goto wrapup;
wrapup:
@@ -499,7 +477,7 @@ runScenario(Client c)
{
str msg = MAL_SUCCEED;
- if (c == 0 || c->phase[MAL_SCENARIO_READER] == 0)
+ if (c == 0 /*|| c->phase[MAL_SCENARIO_READER] == 0*/)
return msg;
msg = runScenarioBody(c);
if (msg != MAL_SUCCEED &&
diff --git a/monetdb5/mal/mal_scenario.h b/monetdb5/mal/mal_scenario.h
--- a/monetdb5/mal/mal_scenario.h
+++ b/monetdb5/mal/mal_scenario.h
@@ -16,11 +16,10 @@
#define MAL_SCENARIO_READER 0
#define MAL_SCENARIO_PARSER 1
#define MAL_SCENARIO_OPTIMIZE 2
-#define MAL_SCENARIO_SCHEDULER 3
-#define MAL_SCENARIO_ENGINE 4
-#define MAL_SCENARIO_INITCLIENT 5
-#define MAL_SCENARIO_EXITCLIENT 6
-#define MAL_SCENARIO_CALLBACK 7
+#define MAL_SCENARIO_ENGINE 3
+#define MAL_SCENARIO_INITCLIENT 4
+#define MAL_SCENARIO_EXITCLIENT 5
+#define MAL_SCENARIO_CALLBACK 6
/*#define MAL_SCENARIO_DEBUG*/
/*
@@ -48,8 +47,6 @@ typedef struct SCENARIO {
MALfcn parserCmd;
str optimizer;
MALfcn optimizerCmd;
- str tactics;
- MALfcn tacticsCmd;
str engine;
MALfcn engineCmd;
str callback;
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
@@ -38,19 +38,6 @@
#include "opt_inline.h"
#include <unistd.h>
-/*
- * The SQLcompile operation can be used by separate
- * front-ends to benefit from the SQL functionality.
- * It expects a string and returns the name of the
- * corresponding MAL block as it is known in the
- * SQL_cache, where it can be picked up.
- * The SQLstatement operation also executes the instruction upon request.
- *
- * In both cases the SQL string is handled like an ordinary
- * user query, following the same optimization paths and
- * caching.
- */
-
/* #define _SQL_COMPILE */
/*
@@ -287,43 +274,18 @@ SQLsetTrace(Client cntxt, MalBlkPtr mb)
str
SQLrun(Client c, mvc *m)
{
- str msg= MAL_SUCCEED;
- MalBlkPtr mb=c->curprg->def;
+ str msg = MAL_SUCCEED;
+ MalBlkPtr mb = c->curprg->def;
- if (*m->errstr){
- if (strlen(m->errstr) > 6 && m->errstr[5] == '!')
- msg = createException(PARSE, "SQLparser", "%s",
m->errstr);
- else
- msg = createException(PARSE, "SQLparser",
SQLSTATE(42000) "%s", m->errstr);
- *m->errstr=0;
- return msg;
- }
+ assert(!*m->errstr);
+
TRC_INFO(SQL_EXECUTION, "Executing: %s", c->query);
MT_thread_setworking(c->query);
- // JIT optimize the SQL query using all current information
- // This include template constants, BAT sizes.
- if( m->emod & mod_debug)
- mb->keephistory = TRUE;
- if ((m->emod & mod_exec) == 0) {
- msg = SQLoptimizeQuery(c, mb);
- if( msg != MAL_SUCCEED){
- MT_thread_setworking(NULL);
- return msg;
- }
- }
- mb->keephistory = FALSE;
-
- if (mb->errors){
- msg = mb->errors;
- mb->errors = 0;
- MT_thread_setworking(NULL);
- return msg;
- }
if (m->emod & mod_explain) {
if (c->curprg->def)
printFunction(c->fdout, mb, 0, LIST_MAL_NAME |
LIST_MAL_VALUE | LIST_MAL_TYPE | LIST_MAL_MAPI);
- } else if( m->emod & mod_debug) {
+ } else if (m->emod & mod_debug) {
c->idle = 0;
c->lastcmd = time(0);
#ifdef NDEBUG
@@ -333,7 +295,7 @@ SQLrun(Client c, mvc *m)
msg = runMALDebugger(c, mb);
#endif
} else {
- if( m->emod & mod_trace){
+ if (m->emod & mod_trace){
if((msg = SQLsetTrace(c,mb)) == MAL_SUCCEED) {
setVariableScope(mb);
MT_lock_set(&mal_contextLock);
@@ -422,9 +384,6 @@ SQLstatementIntern(Client c, const char
Symbol backup = NULL;
size_t len = strlen(expr);
-#ifdef _SQL_COMPILE
- mnstr_printf(c->fdout, "#SQLstatement:%s\n", expr);
-#endif
if (!sql) {
inited = 1;
msg = SQLinitClient(c, NULL, NULL, NULL);
@@ -562,97 +521,41 @@ SQLstatementIntern(Client c, const char
oldstop = c->curprg->def->stop;
oldvid = c->curprg->def->vid;
r = sql_symbol2relation(sql, m->sym);
-#ifdef _SQL_COMPILE
- mnstr_printf(c->fdout, "#SQLstatement:\n");
-#endif
- if (m->emode != m_prepare) {
- scanner_query_processed(&(m->scanner));
- if ((err = mvc_status(m)) ) {
- if (strlen(m->errstr) > 6 && m->errstr[5] ==
'!')
- msg = createException(PARSE,
"SQLparser", "%s", m->errstr);
- else
- msg = createException(PARSE,
"SQLparser", SQLSTATE(42000) "%s", m->errstr);
- *m->errstr=0;
- msg = handle_error(m, status, msg);
- sqlcleanup(sql, err);
- /* restore the state */
- MSresetInstructions(c->curprg->def, oldstop);
- freeVariables(c, c->curprg->def, c->glb,
oldvtop, oldvid);
- c->curprg->def->errors = 0;
- goto endofcompile;
- }
+ assert(m->emode != m_prepare);
+ scanner_query_processed(&(m->scanner));
+ if ((err = mvc_status(m)) ) {
+ if (strlen(m->errstr) > 6 && m->errstr[5] == '!')
+ msg = createException(PARSE, "SQLparser", "%s",
m->errstr);
+ else
+ msg = createException(PARSE, "SQLparser",
SQLSTATE(42000) "%s", m->errstr);
+ *m->errstr=0;
+ msg = handle_error(m, status, msg);
+ sqlcleanup(sql, err);
+ /* restore the state */
+ MSresetInstructions(c->curprg->def, oldstop);
+ freeVariables(c, c->curprg->def, c->glb, oldvtop,
oldvid);
+ c->curprg->def->errors = 0;
+ goto endofcompile;
+ }
/* generate MAL code */
-#ifdef _SQL_COMPILE
- mnstr_printf(c->fdout, "#SQLstatement:pre-compile\n");
- printFunction(c->fdout, c->curprg->def, 0,
LIST_MAL_NAME | LIST_MAL_VALUE | LIST_MAL_MAPI);
-#endif
- be->depth++;
- setVarType(c->curprg->def, 0, 0);
- if (backend_dumpstmt(be, c->curprg->def, r, 1, 1, NULL)
< 0)
- err = 1;
- be->depth--;
-#ifdef _SQL_COMPILE
- mnstr_printf(c->fdout, "#SQLstatement:post-compile\n");
- printFunction(c->fdout, c->curprg->def, 0,
LIST_MAL_NAME | LIST_MAL_VALUE | LIST_MAL_MAPI);
-#endif
- } else {
- // Do not directly execute prepared statements.
- execute = 0;
+ be->depth++;
+ setVarType(c->curprg->def, 0, 0);
+ if (backend_dumpstmt(be, c->curprg->def, r, 1, 1, NULL) < 0)
+ err = 1;
+ be->depth--;
- if ((c->query = query_cleaned(m->sa,
QUERY(m->scanner))) == NULL) {
+ if (err == 0) {
+ if (msg == MAL_SUCCEED)
+ msg = SQLoptimizeQuery(c, c->curprg->def);
+ if (msg)
err = 1;
- msg = createException(PARSE, "SQLparser",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
- }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]