Update of /cvsroot/monetdb/sql/src/server
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv10978
Modified Files:
Tag: Nov2009
rel_dump.mx sql_parser.mx
Log Message:
give PLAN a nice header, such that we can lift the interactive (mclient)
restriction
Index: sql_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_parser.mx,v
retrieving revision 1.322.2.3
retrieving revision 1.322.2.4
diff -u -d -r1.322.2.3 -r1.322.2.4
--- sql_parser.mx 27 Oct 2009 14:04:36 -0000 1.322.2.3
+++ sql_parser.mx 30 Oct 2009 11:45:52 -0000 1.322.2.4
@@ -746,10 +746,6 @@
m->sym = $$ = $3; YYACCEPT;
}
| SQL_PLAN { mvc *m = (mvc*)parm;
- if (m->scanner.mode == LINE_1) {
- yyerror("PLAN is only available in mclient due
to protocol restrictions");
- YYABORT;
- }
m->emode = m_plan;
m->scanner.as = m->scanner.yycur;
m->scanner.key = 0;
Index: rel_dump.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_dump.mx,v
retrieving revision 1.41
retrieving revision 1.41.2.1
diff -u -d -r1.41 -r1.41.2.1
--- rel_dump.mx 14 Sep 2009 18:21:35 -0000 1.41
+++ rel_dump.mx 30 Oct 2009 11:45:52 -0000 1.41.2.1
@@ -38,7 +38,7 @@
#include "rel_dump.h"
static void
-print_indent( mvc *sql, stream *fout, int depth)
+print_indent(mvc *sql, stream *fout, int depth)
{
char buf[LINESIZE+1];
int i;
@@ -47,8 +47,8 @@
depth *= TABSTOP;
if (depth > LINESIZE)
depth = LINESIZE;
- for(i=0; i<depth; i++){
- if ((i%TABSTOP) == 0)
+ for (i = 0; i < depth; i++){
+ if ((i % TABSTOP) == 0)
buf[i] = '|';
else
buf[i] = ' ';
@@ -195,7 +195,7 @@
stream_printf(fout, "(");
else
stream_printf(fout, " [ ");
- for( en = exps->h; en; en = en->next )
+ for (en = exps->h; en; en = en->next)
exp_print(sql, fout, en->data, depth+1, (en->next!=NULL),
alias);
if (brackets)
stream_printf(fout, ")");
@@ -462,8 +462,49 @@
rel_print(mvc *sql, sql_rel *rel, int depth)
{
list *refs = list_create(NULL);
- rel_print_refs(sql, sql->scanner.ws, rel, depth, refs);
- rel_print_(sql, sql->scanner.ws, rel, depth, refs);
- stream_printf(sql->scanner.ws, "\n");
+ size_t pos;
+ size_t nl = 0;
+ size_t len = 0, lastpos = 0;
+ stream *fd = sql->scanner.ws;
+ stream *s;
+ buffer *b = buffer_create(16364); /* hopefully enough */
+ if (!b)
+ return; /* signal somehow? */
+ s = buffer_wastream(b, "SQL Plan");
+ if (!s) {
+ buffer_destroy(b);
+ return; /* signal somehow? */
+ }
+
+ rel_print_refs(sql, s, rel, depth, refs);
+ rel_print_(sql, s, rel, depth, refs);
+ stream_printf(s, "\n");
+
+ /* count the number of lines in the output, skip the leading \n */
+ for (pos = 1; pos < b->pos; pos++) {
+ if (b->buf[pos] == '\n') {
+ nl++;
+ if (len < pos - lastpos)
+ len = pos - lastpos;
+ lastpos = pos + 1;
+ }
+ }
+ b->buf[b->pos - 1] = '\0'; /* should always end with a \n, can
overwrite */
+
+ /* craft a semi-professional header */
+ stream_printf(fd, "&1 0 %d 1 %d\n", /* type id rows columns tuples */
+ nl, nl);
+ stream_printf(fd, "%% .plan # table_name\n");
+ stream_printf(fd, "%% rel # name\n");
+ stream_printf(fd, "%% clob # type\n");
+ stream_printf(fd, "%% " SZFMT " # length\n", len - 2 /* remove = and \n
*/);
+
+ /* output the data */
+ stream_printf(fd, "%s\n", b->buf + 1 /* omit starting \n */);
+
+ stream_close(s);
+ stream_destroy(s);
+ buffer_destroy(b);
+
list_destroy(refs);
}
------------------------------------------------------------------------------
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