Changeset: 65159548356e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=65159548356e
Modified Files:
        monetdb5/extras/jaql/jaql.c
        monetdb5/extras/jaql/jaql.l
        monetdb5/extras/jaql/jaql.y
Branch: jacqueline
Log Message:

jaql: align EXPLAIN and PLAN with SQL

EXPLAIN now shows MAL-plan
PLAN shows JAQL-ish interpretation of parse tree
PLANF shows function call per pipe interpretation of parse tree used
for generating MAL code


diffs (93 lines):

diff --git a/monetdb5/extras/jaql/jaql.c b/monetdb5/extras/jaql/jaql.c
--- a/monetdb5/extras/jaql/jaql.c
+++ b/monetdb5/extras/jaql/jaql.c
@@ -575,9 +575,9 @@ JAQLexecute(Client cntxt, MalBlkPtr mb, 
                        continue;
 
                switch (j->explain) {
-                       case 0: {
+                       case 0: /* normal (execution) mode */
+                       case 1: /* explain: show MAL-plan */ {
                                str err;
-                               /* normal (execution) mode */
                                Symbol prg = newFunction(putName("user", 4), 
putName("jaql", 4),
                                                FUNCTIONsymbol);
                                /* we do not return anything */
@@ -590,20 +590,23 @@ JAQLexecute(Client cntxt, MalBlkPtr mb, 
                                        break;
 
                                chkProgram(cntxt->nspace, prg->def);
-                               printFunction(cntxt->fdout, prg->def, 0, 
LIST_MAL_STMT);
-                               err = (str)runMAL(cntxt, prg->def, 1, 0, 0, 0);
-                               freeMalBlk(prg->def);
-                               if (err != MAL_SUCCEED) {
-                                       snprintf(j->err, sizeof(j->err), "%s", 
err);
-                                       GDKfree(err);
-                                       break;
+                               if (j->explain == 1) {
+                                       printFunction(cntxt->fdout, prg->def, 0,
+                                                       LIST_MAL_STMT | 
LIST_MAPI);
+                               } else {
+                                       err = (str)runMAL(cntxt, prg->def, 1, 
0, 0, 0);
+                                       freeMalBlk(prg->def);
+                                       if (err != MAL_SUCCEED) {
+                                               snprintf(j->err, 
sizeof(j->err), "%s", err);
+                                               GDKfree(err);
+                                               break;
+                                       }
                                }
                        }       break;
-                       case 1: /* explain */
                        case 2: /* plan */
-                               printtree(j->p, 0, j->explain == 1);
+                       case 3: /* planf */
+                               printtree(j->p, 0, j->explain == 3);
                                break;
-                       /* case 3: trace? */
                }
                freetree(j->p);
                /* reset, j->buf has been reset by the lexer if EOF was found */
diff --git a/monetdb5/extras/jaql/jaql.l b/monetdb5/extras/jaql/jaql.l
--- a/monetdb5/extras/jaql/jaql.l
+++ b/monetdb5/extras/jaql/jaql.l
@@ -3,6 +3,7 @@
 %option bison-locations
 %option noyywrap
 %option yylineno
+%option case-insensitive
 %option extra-type="struct _jc *"
 
 %{
@@ -54,6 +55,7 @@ asc        return ASC;
  /* debugging aids */
 explain    return EXPLAIN;
 plan       return PLAN;
+planf      return PLANF;
 
  /* language constructs */
 "->"       return _ARROW;
diff --git a/monetdb5/extras/jaql/jaql.y b/monetdb5/extras/jaql/jaql.y
--- a/monetdb5/extras/jaql/jaql.y
+++ b/monetdb5/extras/jaql/jaql.y
@@ -21,7 +21,7 @@
 %token LEX_ERROR
 
 %token EACH FILTER TRANSFORM EXPAND GROUP INTO BY AS JOIN WHERE IN
-%token SORT TOP DESC ASC EXPLAIN PLAN
+%token SORT TOP DESC ASC EXPLAIN PLAN PLANF
 
 %token _ARROW _DOLLAR _ASSIGN _EQUALS _NEQUAL _TRUE _FALSE
 %token _GREATER _GEQUAL _LESS _LEQUAL _NOT _AND _OR _SCOLON _DOT
@@ -82,6 +82,12 @@ stmt: jaql _SCOLON
                j->explain = 2;
                YYACCEPT;
        }
+       | PLANF jaql _SCOLON
+       {
+               j->p = $$ = $2;
+               j->explain = 3;
+               YYACCEPT;
+       }
        | LEX_ERROR
        {
                j->p = $$ = NULL;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to