Changeset: 3a8834e39b51 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3a8834e39b51
Modified Files:
        sql/include/sql_mem.h
        sql/server/sql_mvc.c
Branch: tracer
Log Message:

Reverted 'debug' var in sql_mvc.c


diffs (truncated from 763 to 300 lines):

diff --git a/sql/include/sql_mem.h b/sql/include/sql_mem.h
--- a/sql/include/sql_mem.h
+++ b/sql/include/sql_mem.h
@@ -106,7 +106,7 @@ extern size_t sa_size( sql_allocator *sa
                void *_ptr = (ptr);                                 \
                size_t _sz = (sz);                                  \
                size_t _osz = (osz);                                \
-               void *_res = sa_realloc(_sa, _ptr, _sz, _osz)       \
+               void *_res = sa_realloc(_sa, _ptr, _sz, _osz);      \
                DEBUG(ALLOC,                                        \
                        "sa_realloc(%p, %p, %zu, %zu) -> %p",           \
                        _sa, _ptr, _sz, _osz, _res);                    \
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
@@ -28,8 +28,7 @@
 #include "wlc.h"
 
 #include "mal_authorize.h"
-
-static int mvc_debug = 0;
+#include "gdk_tracer.h"
 
 static void
 sql_create_comments(mvc *m, sql_schema *s)
@@ -87,51 +86,49 @@ 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);                                         \
-               fprintf(stderr, "!mvc_init: %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);                                         \
+               INFO(SQL_ALL, "Initialization: %s\n", output);          \
+               freeException(output);                                  \
+               return -1;                                              \
        }
 
 int
 mvc_init(int debug, store_type store, int ro, int su, backend_stack stk)
 {
+       (void) debug;
        int first = 0;
        sql_schema *s;
        sql_table *t;
        sqlid tid = 0, ntid, cid = 0, ncid;
        mvc *m;
        str msg;
-
-       mvc_debug = debug&4;
-       if (mvc_debug) {
-               fprintf(stderr, "#mvc_init\n");
-       }
+       
+       DEBUG(SQL_MVC, "Initialization\n");
        keyword_init();
        if(scanner_init_keywords() != 0) {
-               fprintf(stderr, "!mvc_init: malloc failure\n");
+               CRITICAL(ALL, "Malloc failure\n");
                return -1;
        }
 
-       if ((first = store_init(debug, store, ro, su, stk)) < 0) {
-               fprintf(stderr, "!mvc_init: unable to create system tables\n");
+       if ((first = store_init(store, ro, su, stk)) < 0) {
+               CRITICAL(ALL, "Unable to create system tables\n");
                return -1;
        }
 
        m = mvc_create(0, stk, 0, NULL, NULL);
        if (!m) {
-               fprintf(stderr, "!mvc_init: malloc failure\n");
+               CRITICAL(ALL, "Malloc failure\n");
                return -1;
        }
 
        m->sa = sa_create();
        if (!m->sa) {
                mvc_destroy(m);
-               fprintf(stderr, "!mvc_init: malloc failure\n");
+               CRITICAL(ALL, "Malloc failure\n");
                return -1;
        }
 
@@ -143,7 +140,7 @@ mvc_init(int debug, store_type store, in
        if (first || catalog_version) {
                if (mvc_trans(m) < 0) {
                        mvc_destroy(m);
-                       fprintf(stderr, "!mvc_init: failed to start 
transaction\n");
+                       CRITICAL(ALL, "Failed to start transaction\n");
                        return -1;
                }
 
@@ -159,7 +156,7 @@ mvc_init(int debug, store_type store, in
                t = mvc_init_create_view(m, s, "tables", "SELECT \"id\", 
\"name\", \"schema_id\", \"query\", CAST(CASE WHEN \"system\" THEN \"type\" + 
10 /* system table/view */ ELSE (CASE WHEN \"commit_action\" = 0 THEN \"type\" 
/* table/view */ ELSE \"type\" + 20 /* global temp table */ END) END AS 
SMALLINT) AS \"type\", \"system\", \"commit_action\", \"access\", CASE WHEN 
(NOT \"system\" AND \"commit_action\" > 0) THEN 1 ELSE 0 END AS \"temporary\" 
FROM \"sys\".\"_tables\" WHERE \"type\" <> 2 UNION ALL SELECT \"id\", \"name\", 
\"schema_id\", \"query\", CAST(\"type\" + 30 /* local temp table */ AS 
SMALLINT) AS \"type\", \"system\", \"commit_action\", \"access\", 1 AS 
\"temporary\" FROM \"tmp\".\"_tables\";");
                if (!t) {
                        mvc_destroy(m);
-                       fprintf(stderr, "!mvc_init: failed to create 'tables' 
view\n");
+                       CRITICAL(ALL, "Failed to create 'tables' view\n");
                        return -1;
                }
 
@@ -195,7 +192,7 @@ mvc_init(int debug, store_type store, in
                t = mvc_init_create_view(m, s, "columns", "SELECT * FROM 
(SELECT p.* FROM \"sys\".\"_columns\" AS p UNION ALL SELECT t.* FROM 
\"tmp\".\"_columns\" AS t) AS columns;");
                if (!t) {
                        mvc_destroy(m);
-                       fprintf(stderr, "!mvc_init: failed to create 'columns' 
view\n");
+                       CRITICAL(ALL, "Failed to create 'columns' view\n");
                        return -1;
                }
                ncid = t->base.id;
@@ -236,7 +233,7 @@ mvc_init(int debug, store_type store, in
                assert(m->session->schema != NULL);
 
                if ((msg = mvc_commit(m, 0, NULL, false)) != MAL_SUCCEED) {
-                       fprintf(stderr, "!mvc_init: unable to commit system 
tables: %s\n", (msg + 6));
+                       CRITICAL(ALL, "Unable to commit system tables: %s\n", 
(msg + 6));
                        freeException(msg);
                        return -1;
                }
@@ -244,7 +241,7 @@ mvc_init(int debug, store_type store, in
 
        if(mvc_trans(m) < 0) {
                mvc_destroy(m);
-               fprintf(stderr, "!mvc_init: failed to start transaction\n");
+               CRITICAL(ALL, "Failed to start transaction\n");
                return -1;
        }
 
@@ -257,8 +254,7 @@ mvc_init(int debug, store_type store, in
                                if(isPartitionedByColumnTable(tt) || 
isPartitionedByExpressionTable(tt)) {
                                        char *err;
                                        if((err = initialize_sql_parts(m, tt)) 
!= NULL) {
-                                               fprintf(stderr, "!mvc_init: 
unable to start partitioned table: %s.%s: %s\n",
-                                                               ss->base.name, 
tt->base.name, err);
+                                               CRITICAL(ALL, "Unable to start 
partitioned table: %s.%s: %s\n", ss->base.name, tt->base.name, err);
                                                freeException(err);
                                                return -1;
                                        }
@@ -268,7 +264,7 @@ mvc_init(int debug, store_type store, in
        }
 
        if ((msg = mvc_commit(m, 0, NULL, false)) != MAL_SUCCEED) {
-               fprintf(stderr, "!mvc_init: unable to commit system tables: 
%s\n", (msg + 6));
+               CRITICAL(ALL, "Unable to commit system tables: %s\n", (msg + 
6));
                freeException(msg);
                return -1;
        }
@@ -280,9 +276,7 @@ mvc_init(int debug, store_type store, in
 void
 mvc_exit(void)
 {
-       if (mvc_debug)
-               fprintf(stderr, "#mvc_exit\n");
-
+       DEBUG(SQL_MVC, "MVC exit\n");
        store_exit();
        keyword_exit();
 }
@@ -349,11 +343,8 @@ mvc_trans(mvc *m)
 {
        int schema_changed = 0, err = m->session->status;
        assert(!m->session->tr->active);        /* can only start a new 
transaction */
-
        store_lock();
-       if (GDKverbose >= 1)
-               fprintf(stderr, "#%s: starting transaction\n",
-                       MT_thread_getname());
+       INFO(SQL_ALL, "%s: starting transaction\n", MT_thread_getname());
        schema_changed = sql_trans_begin(m->session);
        if (m->qc && (schema_changed || m->qc->nr > m->cache || err)){
                if (schema_changed || err) {
@@ -451,10 +442,7 @@ mvc_commit(mvc *m, int chain, const char
 
        assert(tr);
        assert(m->session->tr->active); /* only commit an active transaction */
-
-       if (mvc_debug)
-               fprintf(stderr, "#mvc_commit %s\n", (name) ? name : "");
-
+       DEBUG(SQL_MVC,"Commit: %s\n", (name) ? name : "");
        if(enabling_auto_commit)
                snprintf(operation, BUFSIZ, "Commit failed while enabling 
auto_commit: ");
        else if(name)
@@ -472,8 +460,7 @@ mvc_commit(mvc *m, int chain, const char
        /* savepoint then simply make a copy of the current transaction */
        if (name && name[0] != '\0') {
                sql_trans *tr = m->session->tr;
-               if (mvc_debug)
-                       fprintf(stderr, "#mvc_savepoint\n");
+               DEBUG(SQL_MVC, "Savepoint\n");
                store_lock();
                m->session->tr = sql_trans_create(m->session->stk, tr, name, 
true);
                if(!m->session->tr) {
@@ -495,11 +482,7 @@ mvc_commit(mvc *m, int chain, const char
 build up the hash (not copied in the trans dup)) */
                        qc_clean(m->qc);
                m->session->schema = find_sql_schema(m->session->tr, 
m->session->schema_name);
-               if (mvc_debug)
-                       fprintf(stderr, "#mvc_commit %s done\n", name);
-               if (GDKverbose >= 1)
-                       fprintf(stderr, "#%s: savepoint commit %s done\n",
-                               MT_thread_getname(), name);
+               INFO(SQL_ALL, "%s: savepoint commit '%s' done\n", 
MT_thread_getname(), name);
                return msg;
        }
 
@@ -534,13 +517,11 @@ build up the hash (not copied in the tra
                                freeException(other);
                        return msg;
                }
-               if (mvc_debug)
-                       fprintf(stderr, "#mvc_commit done\n");
-               if (GDKverbose >= 1)
-                       fprintf(stderr, "#%s: commit done (no 
changes)%s%.200s\n",
-                               MT_thread_getname(),
-                               GDKverbose >= 2 && m->query ? ", query: " : "",
-                               GDKverbose >= 2 && m->query ? m->query : "");
+               INFO(SQL_ALL, 
+                       "%s: commit done (no changes)%s%.200s\n", 
+                       MT_thread_getname(),
+                       m->query ? ", query: " : "",
+                       m->query ? m->query : "");
                return msg;
        }
 
@@ -596,13 +577,11 @@ build up the hash (not copied in the tra
                sql_trans_begin(m->session);
        store_unlock();
        m->type = Q_TRANS;
-       if (mvc_debug)
-               fprintf(stderr, "#mvc_commit done\n");
-       if (GDKverbose >= 1)
-               fprintf(stderr, "#%s: commit done%s%.200s\n",
-                       MT_thread_getname(),
-                       GDKverbose >= 2 && m->query ? ", query: " : "",
-                       GDKverbose >= 2 && m->query ? m->query : "");
+       INFO(SQL_ALL, 
+               "%s: commit done%s%.200s\n",
+               MT_thread_getname(),
+               m->query ? ", query: " : "",
+               m->query ? m->query : "");
        return msg;
 }
 
@@ -612,9 +591,7 @@ mvc_rollback(mvc *m, int chain, const ch
        sql_trans *tr = m->session->tr;
        str msg;
 
-       if (mvc_debug)
-               fprintf(stderr, "#mvc_rollback %s\n", (name) ? name : "");
-
+       DEBUG(SQL_MVC, "Rollback: %s\n", (name) ? name : "");
        assert(tr);
        assert(m->session->tr->active); /* only abort an active transaction */
        (void) disabling_auto_commit;
@@ -663,14 +640,12 @@ mvc_rollback(mvc *m, int chain, const ch
                return msg;
        }
        m->type = Q_TRANS;
-       if (mvc_debug)
-               fprintf(stderr, "#mvc_rollback %s done\n", (name) ? name : "");
-       if (GDKverbose >= 1)
-               fprintf(stderr, "#%s: commit%s%s rolled back%s%s%.200s\n",
-                       MT_thread_getname(), name ? " " : "", name ? name : "",
-                       tr->wtime == 0 ? " (no changes)" : "",
-                       GDKverbose >= 2 && m->query ? ", query: " : "",
-                       GDKverbose >= 2 && m->query ? m->query : "");
+       INFO(SQL_ALL, 
+               "%s: commit%s%s rolled back%s%s%.200s\n",
+               MT_thread_getname(), name ? " " : "", name ? name : "",
+               tr->wtime == 0 ? " (no changes)" : "",
+               m->query ? ", query: " : "",
+               m->query ? m->query : "");
        return msg;
 }
 
@@ -687,8 +662,7 @@ mvc_release(mvc *m, const char *name)
        assert(tr);
        assert(m->session->tr->active); /* only release active transactions */
 
-       if (mvc_debug)
-               fprintf(stderr, "#mvc_release %s\n", (name) ? name : "");
+       DEBUG(SQL_MVC, "Release: %s\n", (name) ? name : "");
 
        if (!name && (msg = mvc_rollback(m, 0, name, false)) != MAL_SUCCEED) {
                m->session->status = -1;
@@ -729,8 +703,8 @@ mvc_create(int clientid, backend_stack s
        if(!m) {
                return NULL;
        }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to