Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26472/src/backends/monet5
Modified Files:
sql_scenario.mx
Log Message:
propagated changes of Saturday Oct 24 2009 - Monday Oct 26 2009
from the Nov2009 branch to the development trunk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/24 - mlkersten: src/backends/monet5/sql_scenario.mx,1.356.2.3
Move optimizer pipeline decisions and admin into one place. Take care of
idempotency
sequences, such as 'off','off','on','on';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/24 - mlkersten: src/backends/monet5/sql_scenario.mx,1.356.2.4
The SQL trace command now collects the events in BATs, which are printed
at the end of the query block. The properties to be traced can be set
using the SQL variable trace. (see documentation)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/25 - mlkersten: src/backends/monet5/sql_scenario.mx,1.356.2.5
Introduce the trace global variable. Allow for keeping the result of
a traced call for querying as if it was a SQL table.[todo]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/25 - mlkersten: src/backends/monet5/sql_scenario.mx,1.356.2.6
Make the profile information accessible for inspection using SQL.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: sql_scenario.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_scenario.mx,v
retrieving revision 1.358
retrieving revision 1.359
diff -u -d -r1.358 -r1.359
--- sql_scenario.mx 23 Oct 2009 22:43:49 -0000 1.358
+++ sql_scenario.mx 26 Oct 2009 10:12:53 -0000 1.359
@@ -306,8 +306,9 @@
SQLglobal("current_role", user);
optimizer= GDKgetenv("sql_optimizer");
if (optimizer == NULL)
- optimizer= "none";
+ optimizer= "default_pipe";
SQLglobal("optimizer", setOptimizers(optimizer));
+ SQLglobal("trace","show,ticks,stmt");
typename = "sec_interval";
sql_find_subtype(&ctype, typename, 0, 0);
@@ -317,6 +318,7 @@
sql_find_subtype(&ctype, typename, 0, 0);
SQLglobal("cache", &T);
SQLglobal("history", &F);
+
return 0;
}
@@ -857,22 +859,63 @@
}
}
+...@-
+The trace operation collects the events in the BATs
+and creates a secondary result set upon termination
+of the query. This feature is extended with
+a SQL variable to identify which trace flags are needed.
+The control term 'keep' avoids clearing the performance tables,
+which makes it possible to inspect the results later using
+SQL itself. (Script needed to bind the BATs to a SQL table.)
+...@c
void
-SQLsetTrace(Client c, bit onoff)
+SQLsetTrace(backend *be, Client c, bit onoff)
{
- InstrPtr q;
+ int i = 0;
+ InstrPtr q,r;
+ MalBlkPtr mb = c->curprg->def;
+ str traceFlag, t,s, def= GDKstrdup("show,ticks,stmt");
- c->itrace='c';
- q = newStmt(c->curprg->def,"mdb","setTimer");
- pushBit(c->curprg->def,q,onoff);
- if( GDKnr_threads > 1){
- q = newStmt(c->curprg->def,"mdb","setThread");
- pushBit(c->curprg->def,q,onoff);
+ traceFlag = stack_get_string(be->mvc, "trace");
+ if ( traceFlag && *traceFlag){
+ GDKfree(def);
+ def= GDKstrdup(traceFlag);
}
-/*
- q = newStmt(c->curprg->def,"mdb","setCount");
- pushBit(c->curprg->def,q,onoff);
-*/
+ t= def;
+
+ if (onoff){
+ if ( strstr(def,"keep") == 0)
+ q = newStmt(mb,"profiler","reset");
+ q = newStmt(mb,"profiler","setFilter");
+ q = pushStr(mb,q, "*");
+ q = pushStr(mb,q, "*");
+ q = newStmt(mb,"profiler","start");
+ } else
+ if ( def && strstr(def,"show") ) {
+ r= newInstruction(mb,ASSIGNsymbol);
+ setModuleId(r,putName("io",2));
+ getArg(r,0)= newTmpVariable(mb,TYPE_void);
+
+ q = newStmt(mb,"profiler","stop");
+ do {
+ s= t;
+ t= strchr(t+1,',');
+ if ( t )
+ *t = 0;
+ if ( strcmp("keep",s) && strcmp("show",s) ) {
+ q = newStmt(mb,"profiler","getTrace");
+ q = pushStr(mb, q, s);
+ r= pushArgument(mb,r, getArg(q,0));
+ i++;
+ }
+ } while (t++);
+ if ( i > 1)
+ setFunctionId(r,putName("table",5));
+ else
+ setFunctionId(r,putName("print",5));
+ pushInstruction(mb,r);
+ }
+ GDKfree(def);
}
void
@@ -1019,7 +1062,7 @@
if (m->emod & mod_debug)
SQLsetDebugger(c, m, TRUE);
if (m->emod & mod_trace)
- SQLsetTrace(c, TRUE);
+ SQLsetTrace(be, c, TRUE);
if (m->emode != m_explain && !(m->emod & (mod_debug|mod_trace)))
m->emode = m_inplace;
scanner_query_processed(&(m->scanner));
@@ -1039,7 +1082,7 @@
if (m->emode == m_explain)
SQLshowPlan(c);
if (m->emod & mod_trace)
- SQLsetTrace(c, TRUE);
+ SQLsetTrace(be, c, TRUE);
if (m->emod & mod_debug)
SQLsetDebugger(c, m, TRUE);
if ((m->emode != m_inplace && m->emode != m_prepare &&
!m->cache && m->emode != m_explain) || s->type == st_none) {
@@ -1084,7 +1127,7 @@
In the final phase we add any debugging control
@c
if (m->emod & mod_trace)
- SQLsetTrace(c, FALSE);
+ SQLsetTrace(be, c, FALSE);
if (m->emod & mod_debug)
SQLsetDebugger(c, m, FALSE);
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins