Changeset: fc4f04fec020 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fc4f04fec020
Modified Files:
        sql/backends/monet5/sql_scenario.c
        sql/server/sql_mvc.c
        sql/server/sql_mvc.h
Branch: gdk_tracer
Log Message:

Updates


diffs (242 lines):

diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -212,49 +212,42 @@ SQLepilogue(void *ret)
        return MAL_SUCCEED;
 }
 
-#define SQLglobal(name, val, failure)                                          
                                   \
+#define SQLglobal(name, val) \
        if (!stack_push_var(sql, name, &ctype) || !stack_set_var(sql, name, 
VALset(&src, ctype.type->localtype, (char*)(val)))) \
                failure--;
 
-#define NR_GLOBAL_VARS 9
-/* NR_GLOBAL_VAR should match exactly the number of variables created
-   in global_variables */
+/* NR_GLOBAL_VAR should match exactly the number of variables created in 
global_variables */
 /* initialize the global variable, ie make mvc point to these */
 static int
 global_variables(mvc *sql, const char *user, const char *schema)
 {
        sql_subtype ctype;
-       const char *typename;
        lng sec = 0;
        ValRecord src;
        const char *opt;
        int failure = 0;
 
-       typename = "int";
-       sql_find_subtype(&ctype, typename, 0, 0);
-       SQLglobal("debug", &sql->debug, failure);
-       SQLglobal("cache", &sql->cache, failure);
+       sql_find_subtype(&ctype, "int", 0, 0);
+       SQLglobal("debug", &sql->debug);
+       SQLglobal("cache", &sql->cache);
 
-       typename = "varchar";
-       sql_find_subtype(&ctype, typename, 1024, 0);
-       SQLglobal("current_schema", schema, failure);
-       SQLglobal("current_user", user, failure);
-       SQLglobal("current_role", user, failure);
+       sql_find_subtype(&ctype,  "varchar", 1024, 0);
+       SQLglobal("current_schema", schema);
+       SQLglobal("current_user", user);
+       SQLglobal("current_role", user);
 
        /* inherit the optimizer from the server */
        opt = GDKgetenv("sql_optimizer");
        if (!opt)
                opt = "default_pipe";
-       SQLglobal("optimizer", opt, failure);
+       SQLglobal("optimizer", opt);
 
-       typename = "sec_interval";
-       sql_find_subtype(&ctype, typename, inttype2digits(ihour, isec), 0);
-       SQLglobal("current_timezone", &sec, failure);
+       sql_find_subtype(&ctype, "sec_interval", inttype2digits(ihour, isec), 
0);
+       SQLglobal("current_timezone", &sec);
 
-       typename = "bigint";
-       sql_find_subtype(&ctype, typename, 0, 0);
-       SQLglobal("last_id", &sql->last_id, failure);
-       SQLglobal("rowcnt", &sql->rowcnt, failure);
+       sql_find_subtype(&ctype, "bigint", 0, 0);
+       SQLglobal("last_id", &sql->last_id);
+       SQLglobal("rowcnt", &sql->rowcnt);
        return failure;
 }
 
@@ -303,7 +296,7 @@ SQLprepareClient(Client c, int login)
                */
                if (m->session->tr->active)
                        return NULL;
-               if (mvc_reset(m, c->fdin, c->fdout, SQLdebug, NR_GLOBAL_VARS) < 
0)
+               if (mvc_reset(m, c->fdin, c->fdout, SQLdebug) < 0)
                        throw(SQL,"sql.initClient", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                backend_reset(be);
        }
@@ -440,8 +433,6 @@ SQLinit(Client c)
        }
        if ((msg = SQLprepareClient(c, 0)) != NULL) {
                MT_lock_unset(&sql_contextLock);
-               /* CHECK */
-               // Not sure if this is an info msg
                TRC_INFO(SQL_SCENARIO, "%s\n", msg);
                return msg;
        }
@@ -744,8 +735,6 @@ SQLexitClient(Client c)
 {
        str err;
 
-       TRC_DEBUG(SQL_SCENARIO, "Enter SQLexitClient\n");
-
        MT_lock_set(&sql_contextLock);
        if (SQLinitialized == FALSE) {
                MT_lock_unset(&sql_contextLock);
@@ -875,13 +864,9 @@ SQLreader(Client c)
                return MAL_SUCCEED;
        }
        if (!be || c->mode <= FINISHCLIENT) {
-               TRC_DEBUG(SQL_SCENARIO, "SQL client finished\n");
                c->mode = FINISHCLIENT;
                return MAL_SUCCEED;
        }
-
-       TRC_DEBUG(SQL_SCENARIO, "Start reading SQL %s\n", (blocked ? "Blocked 
read" : ""));
-
        language = be->language;        /* 'S' for SQL, 'D' from debugger */
        m = be->mvc;
        m->errstr[0] = 0;
@@ -889,8 +874,6 @@ SQLreader(Client c)
         * Continue processing any left-over input from the previous round.
         */
 
-       TRC_DEBUG(SQL_SCENARIO, "Pos %zu len %zu eof %d \n", in->pos, in->len, 
in->eof);
-
        while (more) {
                more = false;
 
@@ -912,7 +895,6 @@ SQLreader(Client c)
                        ssize_t rd;
 
                        if (c->bak) {
-                               TRC_DEBUG(SQL_SCENARIO, "Switch to backup 
stream\n");
                                in = c->fdin;
                                blocked = isa_block_stream(in->s);
                                m->scanner.rs = c->fdin;
@@ -941,7 +923,6 @@ SQLreader(Client c)
                                more = false;
                                go = false;
                        } else if (go && (rd = bstream_next(in)) <= 0) {
-                               TRC_DEBUG(SQL_SCENARIO, "Read %zu language %d 
eof %d\n", rd, language, in->eof);
                                if (be->language == 'D' && !in->eof) {
                                        in->pos++;// skip 's' or 'S'
                                        return msg;
@@ -970,8 +951,6 @@ SQLreader(Client c)
                        } else if (go && language == 'D' && !in->eof) {
                                in->pos++;// skip 's' or 'S'
                        }
-
-                       TRC_DEBUG(SQL_SCENARIO, "SQL blk: %s\n", in->buf + 
in->pos);
                }
        }
        if ( (c->sessiontimeout && (GDKusec() - c->session) > 
c->sessiontimeout) || !go || (strncmp(CURRENT(c), "\\q", 2) == 0)) {
diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c
--- a/sql/server/sql_mvc.c
+++ b/sql/server/sql_mvc.c
@@ -83,14 +83,14 @@ bailout:
        return t;
 }
 
-#define MVC_INIT_DROP_TABLE(SQLID, TNAME)                       \
-       t = mvc_bind_table(m, s, TNAME);                            \
-       SQLID = t->base.id;                                         \
-       if((output = mvc_drop_table(m, s, t, 0)) != MAL_SUCCEED) {  \
-               mvc_destroy(m);                                         \
-               TRC_INFO(SQL_MVC, "Initialization: %s\n", output);          \
-               freeException(output);                                  \
-               return -1;                                              \
+#define MVC_INIT_DROP_TABLE(SQLID, TNAME)                              \
+       t = mvc_bind_table(m, s, TNAME);                                \
+       SQLID = t->base.id;                                             \
+       if((output = mvc_drop_table(m, s, t, 0)) != MAL_SUCCEED) {      \
+               mvc_destroy(m);                                         \
+               TRC_INFO(SQL_MVC, "Initialization: %s\n", output);      \
+               freeException(output);                                  \
+               return -1;                                              \
        }
 
 int
@@ -102,7 +102,7 @@ mvc_init(int debug, store_type store, in
        sqlid tid = 0, ntid, cid = 0, ncid;
        mvc *m;
        str msg;
-       
+
        TRC_DEBUG(SQL_MVC, "Initialization\n");
        keyword_init();
        if(scanner_init_keywords() != 0) {
@@ -355,6 +355,7 @@ mvc_trans(mvc *m)
                        }
                } else { /* clean all but the prepared statements */
                        qc_clean(m->qc, false);
+                       stack_pop_until(m, NR_GLOBAL_VARS);
                }
        }
        store_unlock();
@@ -477,6 +478,7 @@ mvc_commit(mvc *m, int chain, const char
                if (m->qc) /* clean query cache, protect against concurrent 
access on the hash tables (when functions already exists, concurrent mal will
 build up the hash (not copied in the trans dup)) */
                        qc_clean(m->qc, false);
+               stack_pop_until(m, NR_GLOBAL_VARS);
                m->session->schema = find_sql_schema(m->session->tr, 
m->session->schema_name);
                TRC_INFO(SQL_MVC, "Savepoint commit '%s' done\n", name);
                return msg;
@@ -593,6 +595,7 @@ mvc_rollback(mvc *m, int chain, const ch
        store_lock();
        if (m->qc) 
                qc_clean(m->qc, false);
+       stack_pop_until(m, NR_GLOBAL_VARS);
        if (name && name[0] != '\0') {
                while (tr && (!tr->name || strcmp(tr->name, name) != 0))
                        tr = tr->parent;
@@ -770,7 +773,7 @@ mvc_create(int clientid, backend_stack s
 }
 
 int
-mvc_reset(mvc *m, bstream *rs, stream *ws, int debug, int globalvars)
+mvc_reset(mvc *m, bstream *rs, stream *ws, int debug)
 {
        int i, res = 1;
        sql_trans *tr;
@@ -798,7 +801,7 @@ mvc_reset(mvc *m, bstream *rs, stream *w
 
        m->params = NULL;
        /* reset topvars to the set of global variables */
-       stack_pop_until(m, globalvars);
+       stack_pop_until(m, NR_GLOBAL_VARS);
        m->frame = 1;
        m->argc = 0;
        m->sym = NULL;
diff --git a/sql/server/sql_mvc.h b/sql/server/sql_mvc.h
--- a/sql/server/sql_mvc.h
+++ b/sql/server/sql_mvc.h
@@ -142,6 +142,9 @@ typedef struct mvc {
        char *query;            /* string, identify whatever we're working on */
 } mvc;
 
+/* NR_GLOBAL_VAR should match exactly the number of variables created in 
global_variables */
+#define NR_GLOBAL_VARS 9
+
 extern sql_table *mvc_init_create_view(mvc *sql, sql_schema *s, const char 
*name, const char *query);
 extern int mvc_init(int debug, store_type store, int ro, int su, backend_stack 
stk);
 extern void mvc_exit(void);
@@ -149,7 +152,7 @@ extern void mvc_logmanager(void);
 extern void mvc_idlemanager(void);
 
 extern mvc *mvc_create(int clientid, backend_stack stk, int debug, bstream 
*rs, stream *ws);
-extern int mvc_reset(mvc *m, bstream *rs, stream *ws, int debug, int 
globalvars);
+extern int mvc_reset(mvc *m, bstream *rs, stream *ws, int debug);
 extern void mvc_destroy(mvc *c);
 
 extern int mvc_status(mvc *c);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to