Changeset: 8586658b6ed9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8586658b6ed9
Modified Files:
        sql/backends/monet5/mal_backend.c
        sql/backends/monet5/mal_backend.h
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_execute.c
        sql/backends/monet5/sql_gencode.c
Branch: default
Log Message:

mark recursive sql within the backend. Used to control output.


diffs (111 lines):

diff --git a/sql/backends/monet5/mal_backend.c 
b/sql/backends/monet5/mal_backend.c
--- a/sql/backends/monet5/mal_backend.c
+++ b/sql/backends/monet5/mal_backend.c
@@ -15,6 +15,7 @@ backend_reset(backend *b)
 {
        b->out = b->client->fdout;
        b->language = 0;
+       b->depth = 0;
 
        b->vtop = 0;
        b->q = NULL;
diff --git a/sql/backends/monet5/mal_backend.h 
b/sql/backends/monet5/mal_backend.h
--- a/sql/backends/monet5/mal_backend.h
+++ b/sql/backends/monet5/mal_backend.h
@@ -32,8 +32,9 @@ typedef enum output_format {
 } ofmt;
 
 typedef struct backend {
-       int     console;
+       char    console;
        char    language;               /* 'S' or 's' or 'X' */
+       char    depth;
        mvc     *mvc;
        stream  *out;
        ofmt    output_format;  /* csv, json */
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2985,6 +2985,7 @@ sql_parse(backend *be, sql_allocator *sa
 
        m->caching = 0;
        m->emode = mode;
+       be->depth++;
 
        b = (buffer*)GDKmalloc(sizeof(buffer));
        if (b == 0)
@@ -3001,10 +3002,12 @@ sql_parse(backend *be, sql_allocator *sa
        buf = buffer_rastream(b, "sqlstatement");
        if(buf == NULL) {
                buffer_destroy(b);
+               be->depth--;
                return sql_error(m, 02, SQLSTATE(HY001) MAL_MALLOC_FAIL);
        }
        if((bst = bstream_create(buf, b->len)) == NULL) {
                close_stream(buf);
+               be->depth--;
                return sql_error(m, 02, SQLSTATE(HY001) MAL_MALLOC_FAIL);
        }
        scanner_init( &m->scanner, bst, NULL);
@@ -3023,6 +3026,7 @@ sql_parse(backend *be, sql_allocator *sa
                GDKfree(query);
                GDKfree(b);
                bstream_destroy(m->scanner.rs);
+               be->depth--;
                return sql_error(m, 02, SQLSTATE(HY001) MAL_MALLOC_FAIL);
        }
 
@@ -3042,6 +3046,7 @@ sql_parse(backend *be, sql_allocator *sa
        GDKfree(query);
        GDKfree(b);
        bstream_destroy(m->scanner.rs);
+       be->depth--;
        if (m->sa && m->sa != sa)
                sa_destroy(m->sa);
        m->sym = NULL;
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
@@ -491,6 +491,7 @@ SQLstatementIntern(Client c, str *expr, 
        if (!output) {
                sql->output_format = OFMT_NONE;
        }
+       sql->depth++;
        // and do it again
        m->qc = NULL;
        m->caching = 0;
@@ -608,9 +609,11 @@ SQLstatementIntern(Client c, str *expr, 
                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++;
                if (backend_callinline(be, c) < 0 ||
                    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);
@@ -636,8 +639,10 @@ SQLstatementIntern(Client c, str *expr, 
 
                if (!output)
                        sql->out = NULL;        /* no output stream */
+               be->depth++;
                if (execute)
                        msg = SQLrun(c,be,m);
+               be->depth--;
                MSresetInstructions(c->curprg->def, oldstop);
                freeVariables(c, c->curprg->def, NULL, oldvtop);
 
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -652,7 +652,7 @@ backend_dumpstmt(backend *be, MalBlkPtr 
 
        be->mvc_var = old_mv;
        be->mb = old_mb;
-       if (top && c->caching && (c->type == Q_SCHEMA || c->type == Q_TRANS)) {
+       if (top && c->clientid && !be->depth && (c->type == Q_SCHEMA || c->type 
== Q_TRANS)) {
                q = newStmt(mb, sqlRef, exportOperationRef);
                if (q == NULL)
                        return -1;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to