Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv15165/src/backends/monet5
Modified Files:
sql_scenario.mx
Log Message:
propagated changes of Tuesday Oct 27 2009 - Thursday Oct 29 2009
from the Nov2009 branch to the development trunk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/27 - mr-meltdown: src/backends/monet5/sql_scenario.mx,1.356.2.7
output a proper SQL resultset, instead of a random BAT dump
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/27 - mr-meltdown: src/backends/monet5/sql_scenario.mx,1.356.2.8
reenable MAPI-compatible output, e.g. do NOT violate the communication
protocol, as explain.SF-1739353 test is complaining about for ages now
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/27 - mr-meltdown: src/backends/monet5/sql_scenario.mx,1.356.2.9
Add a little note for the future
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: sql_scenario.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_scenario.mx,v
retrieving revision 1.359
retrieving revision 1.360
diff -u -d -r1.359 -r1.360
--- sql_scenario.mx 26 Oct 2009 10:12:53 -0000 1.359
+++ sql_scenario.mx 29 Oct 2009 08:42:59 -0000 1.360
@@ -82,6 +82,7 @@
#include <mtime.h>
#include "optimizer.h"
#include "opt_statistics.h"
+#include "opt_prelude.h"
#include <unistd.h>
static int SQLinitialized = 0;
@@ -871,8 +872,13 @@
void
SQLsetTrace(backend *be, Client c, bit onoff)
{
- int i = 0;
- InstrPtr q,r;
+ int i = 0, j = 0;
+ InstrPtr q;
+ int n, r;
+#define MAXCOLS 24
+ int rs[MAXCOLS];
+ str colname[MAXCOLS];
+ int coltype[MAXCOLS];
MalBlkPtr mb = c->curprg->def;
str traceFlag, t,s, def= GDKstrdup("show,ticks,stmt");
@@ -890,30 +896,82 @@
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);
+ } else if (def && strstr(def, "show")) {
+ q = newStmt(mb, "profiler", "stop");
- q = newStmt(mb,"profiler","stop");
do {
- s= t;
- t= strchr(t+1,',');
- if ( t )
+ s = t;
+ t = strchr(t + 1, ',');
+ if (t)
*t = 0;
- if ( strcmp("keep",s) && strcmp("show",s) ) {
- q = newStmt(mb,"profiler","getTrace");
+ if (strcmp("keep", s) && strcmp("show", s)) {
+ q = newStmt(mb, profilerRef, "getTrace");
q = pushStr(mb, q, s);
- r= pushArgument(mb,r, getArg(q,0));
+ n = getDestVar(q);
+ q = newStmt(mb, algebraRef, "markH");
+ q = pushArgument(mb, q, n);
+ rs[i] = getDestVar(q);
+ colname[i] = s;
+ /* FIXME: type for name should come from
+ * mal_profiler.mx, second FIXME: check the user
+ * supplied values */
+ if (
+ strcmp(s, "time") == 0 ||
+ strcmp(s, "pc") == 0 ||
+ strcmp(s, "stmt") == 0
+ ) {
+ coltype[i] = TYPE_str;
+ } else if (
+ strcmp(s, "ticks") == 0 ||
+ strcmp(s, "rbytes") == 0 ||
+ strcmp(s, "wbytes") == 0 ||
+ strcmp(s, "reads") == 0 ||
+ strcmp(s, "writes") == 0
+ ) {
+ coltype[i] = TYPE_lng;
+ } else if (
+ strcmp(s, "thread") == 0
+ ) {
+ coltype[i] = TYPE_int;
+ }
i++;
+ if (i == MAXCOLS) /* just ignore the rest */
+ break;
}
} while (t++);
- if ( i > 1)
- setFunctionId(r,putName("table",5));
- else
- setFunctionId(r,putName("print",5));
- pushInstruction(mb,r);
+
+ if (i > 0) {
+ q = newStmt(mb, sqlRef, "resultSet");
+ q = pushInt(mb, q, i);
+ q = pushInt(mb, q, 1);
+ q = pushArgument(mb, q, rs[0]);
+ r = getDestVar(q);
+
+ for (j = 0; j < i; j++) {
+ q = newStmt(mb, sqlRef, "rsColumn");
+ q = pushArgument(mb, q, r);
+ q = pushStr(mb, q, ".trace");
+ q = pushStr(mb, q, colname[j]);
+ if (coltype[j] == TYPE_str) {
+ q = pushStr(mb, q, "varchar");
+ q = pushInt(mb, q, 1024);
+ } else if (coltype[j] == TYPE_lng) {
+ q = pushStr(mb, q, "bigint");
+ q = pushInt(mb, q, 64);
+ } else if (coltype[j] == TYPE_int) {
+ q = pushStr(mb, q, "int");
+ q = pushInt(mb, q, 32);
+ }
+ q = pushInt(mb, q, 0);
+ q = pushArgument(mb, q, rs[j]);
+ }
+
+ q = newStmt(mb, ioRef, "stdout");
+ n = getDestVar(q);
+ q = newStmt(mb, sqlRef, "exportResult");
+ q = pushArgument(mb, q, n);
+ q = pushArgument(mb, q, r);
+ }
}
GDKfree(def);
}
@@ -922,6 +980,7 @@
SQLshowPlan(Client c)
{
/* we should determine rendering requirements first */
+ /* FIXME: unify this with direct printFunction() calls as used below */
newStmt(c->curprg->def, "mdb", "listMapi");
}
@@ -1163,7 +1222,7 @@
@c
finalize:
if (m->emode == m_explain && be->q && be->q->code)
- printFunction(GDKout, ((Symbol)(be->q->code))->def, 0,
LIST_MAL_STMT | LIST_MAL_UDF);
+ printFunction(GDKout, ((Symbol)(be->q->code))->def, 0,
LIST_MAL_STMT | LIST_MAL_UDF | LIST_MAPI);
@-
Gather the statistics for post analysis. It should preferably
be stored in an SQL table
------------------------------------------------------------------------------
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