Changeset: a0a80d9277ec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a0a80d9277ec
Modified Files:
        clients/mapiclient/mclient.c
        clients/mapiclient/stethoscope.c
        clients/mapilib/mapi.rc
        common/utils/matomic.h
        gdk/gdk_atoms.h
        monetdb5/mal/mal_profiler.c
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/sql_scenario.h
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
        sql/test/merge-partitions/Tests/All
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
Branch: cmake-monetdblite
Log Message:

Merge with cmake-fun.


diffs (truncated from 614 to 300 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1479,25 +1479,26 @@ SQLrenderer(MapiHdl hdl)
                char *s;
 
                len[i] = mapi_get_len(hdl, i);
-               if (len[i] == 0 &&
-                   ((s = mapi_get_type(hdl, i)) == NULL ||
-                    (strcmp(s, "varchar") != 0 &&
-                     strcmp(s, "clob") != 0 &&
-                     strcmp(s, "char") != 0 &&
-                     strcmp(s, "str") != 0 &&
-                     strcmp(s, "json") != 0))) {
-                       /* no table width known, use maximum, rely on
-                        * squeezing later on to fix it to whatever is
-                        * available; note that for a column type of
-                        * varchar, 0 means the complete column is
-                        * NULL or empty string, so MINCOLSIZE (below)
-                        * will work great */
-                       len[i] = pagewidth <= 0 ? DEFWIDTH : pagewidth;
-               } else if (len[i] == 0 &&
-                          strcmp(mapi_get_type(hdl, i), "uuid") == 0) {
-                       /* we know how large the UUID representation
-                        * is, even if the server doesn't */
-                       len[i] = 36;
+               if (len[i] == 0) {
+                       if ((s = mapi_get_type(hdl, i)) == NULL ||
+                           (strcmp(s, "varchar") != 0 &&
+                            strcmp(s, "clob") != 0 &&
+                            strcmp(s, "char") != 0 &&
+                            strcmp(s, "str") != 0 &&
+                            strcmp(s, "json") != 0)) {
+                               /* no table width known, use maximum,
+                                * rely on squeezing later on to fix
+                                * it to whatever is available; note
+                                * that for a column type of varchar,
+                                * 0 means the complete column is NULL
+                                * or empty string, so MINCOLSIZE
+                                * (below) will work great */
+                               len[i] = pagewidth <= 0 ? DEFWIDTH : pagewidth;
+                       } else if (strcmp(s, "uuid") == 0) {
+                               /* we know how large the UUID representation
+                                * is, even if the server doesn't */
+                               len[i] = 36;
+                       }
                }
                if (len[i] < MINCOLSIZE)
                        len[i] = MINCOLSIZE;
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -242,16 +242,21 @@ usageStethoscope(void)
 static void
 stopListening(int i)
 {
-       fprintf(stderr,"signal %d received\n",i);
+       fprintf(stderr,"stethoscope: signal %d received\n",i);
        if( dbh)
                doQ("profiler.stop();");
 stop_disconnect:
        // show follow up action only once
-       if(trace)
-               fclose(trace);
+       /*
+       if(trace) {
+               fflush(trace);
+               int res = fclose(trace);
+               assert(res==0);
+       }
+       */
        if(dbh)
                mapi_disconnect(dbh);
-       exit(0);
+       /* exit(0); */
 }
 
 int
@@ -389,7 +394,7 @@ main(int argc, char **argv)
 #endif
        signal(SIGINT, stopListening);
        signal(SIGTERM, stopListening);
-       close(0);
+       /* close(0); */
 
        if (user == NULL)
                user = simple_prompt("user", BUFSIZ, 1, prompt_getlogin());
@@ -418,7 +423,7 @@ main(int argc, char **argv)
                fprintf(stderr,"-- %s\n",buf);
        doQ(buf);
 
-       snprintf(buf, BUFSIZ, " profiler.openstream(%d);", stream_mode);
+       snprintf(buf, BUFSIZ, "profiler.openstream(%d);", stream_mode);
        if( debug)
                fprintf(stderr,"--%s\n",buf);
        doQ(buf);
@@ -451,6 +456,7 @@ main(int argc, char **argv)
                if(json) {
                        if(trace != NULL) {
                                fprintf(trace, "%s", response + len);
+                               fflush(trace);
                        } else {
                                printf("%s", response + len);
                                fflush(stdout);
diff --git a/clients/mapilib/mapi.rc b/clients/mapilib/mapi.rc
--- a/clients/mapilib/mapi.rc
+++ b/clients/mapilib/mapi.rc
@@ -23,7 +23,7 @@ BEGIN
       // Maintained via vertoo. Please don't modify by hand!
       // Contact monetdb-develop...@lists.sourceforge.net for details and/or 
assistance.
       VALUE "InternalName", "Mapi\0"
-      VALUE "LegalCopyright", "Copyright © MonetDB B.V. 2008-2018\0"
+      VALUE "LegalCopyright", "Copyright © MonetDB B.V. 2008-2019\0"
       VALUE "LegalTrademarks", "\0"
       VALUE "OriginalFilename", "Mapi.dll\0"
       VALUE "PrivateBuild", "\0"
diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -254,7 +254,7 @@ typedef volatile int ATOMIC_TYPE;
 
 #define ATOMIC_GET(var)                __atomic_load_n(var, __ATOMIC_SEQ_CST)
 #define ATOMIC_SET(var, val)   __atomic_store_n(var, (ATOMIC_BASE_TYPE) (val), 
__ATOMIC_SEQ_CST)
-#define ATOMIC_XCG(var, val)   __atomic_exchange_n(var, (ATOMIC_BASE_TYPE) 
(val), __ATOMIC_SEQ_CST
+#define ATOMIC_XCG(var, val)   __atomic_exchange_n(var, (ATOMIC_BASE_TYPE) 
(val), __ATOMIC_SEQ_CST)
 #define ATOMIC_CAS(var, exp, des)      __atomic_compare_exchange_n(var, exp, 
(ATOMIC_BASE_TYPE) (des), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
 #define ATOMIC_ADD(var, val)   __atomic_fetch_add(var, (ATOMIC_BASE_TYPE) 
(val), __ATOMIC_SEQ_CST)
 #define ATOMIC_SUB(var, val)   __atomic_fetch_sub(var, (ATOMIC_BASE_TYPE) 
(val), __ATOMIC_SEQ_CST)
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -196,7 +196,7 @@ gdk_export const ptr ptr_nil;
 #define ATOMdel(t,hp,src)      do if (BATatoms[t].atomDel) 
BATatoms[t].atomDel(hp,src); while (0)
 #define ATOMvarsized(t)                (BATatoms[t].atomPut != NULL)
 #define ATOMlinear(t)          BATatoms[t].linear
-#define ATOMtype(t)            ((t == TYPE_void)?TYPE_oid:t)
+#define ATOMtype(t)            ((t) == TYPE_void ? TYPE_oid : (t))
 #define ATOMfix(t,v)           do if (BATatoms[t].atomFix) 
BATatoms[t].atomFix(v); while (0)
 #define ATOMunfix(t,v)         do if (BATatoms[t].atomUnfix) 
BATatoms[t].atomUnfix(v); while (0)
 
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -175,6 +175,13 @@ renderProfilerEvent(MalBlkPtr mb, MalStk
        logadd("\"pc\":%d,%s", mb?getPC(mb,pci):0, prettify);
        logadd("\"tag\":%d,%s", stk?stk->tag:0, prettify);
        logadd("\"module\":\"%s\",%s", pci->modname ? pci->modname : "", 
prettify);
+       if (strcmp(pci->modname, "user") == 0) {
+               int caller_tag = 0;
+               if(stk && stk->up) {
+                       caller_tag = stk->up->tag;
+               }
+               logadd("\"caller\":%d,%s", caller_tag, prettify);
+       }
        logadd("\"instruction\":\"%s\",%s", pci->fcnname ? pci->fcnname : "", 
prettify);
        if (!GDKinmemory()) {
                char *uuid;
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -2114,6 +2114,8 @@ get_print_width(int mtype, sql_class ecl
                return count;
        } else if (eclass == EC_BIT) {
                return 5;       /* max(strlen("true"), strlen("false")) */
+       } else if (strcmp(ATOMname(mtype), "uuid") == 0) {
+               return 36;      /* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx */
        } else {
                return 0;
        }
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
@@ -136,8 +136,8 @@ SQLprelude(Client cntxt, MalBlkPtr mb, M
                .language = "msql",
                .exitSystem = "SQLexit",
                .exitSystemCmd = SQLexit,
-               .initClient = "SQLinitClient",
-               .initClientCmd = SQLinitClient,
+               .initClient = "SQLinitClientFromMAL",
+               .initClientCmd = SQLinitClientFromMAL,
                .exitClient = "SQLexitClient",
                .exitClientCmd = SQLexitClient,
                .reader = "MALreader",
@@ -306,6 +306,12 @@ SQLprepareClient(Client c, int login)
        } else {
                be = c->sqlcontext;
                m = be->mvc;
+               /* Only reset if there is no active transaction which
+                * can happen when we combine sql.init with msql.
+               */
+               if(m->session->tr->active) {
+                       return NULL;
+               }
                if(mvc_reset(m, c->fdin, c->fdout, SQLdebug, NR_GLOBAL_VARS) < 
0) {
                        throw(SQL,"sql.initClient", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
                }
@@ -600,7 +606,10 @@ SQLinit(Client c)
                } else if (maybeupgrade) {
                        SQLtrans(m);
                        SQLupgrades(c,m);
-                       msg = mvc_commit(m, 0, NULL, false);
+                       /* sometimes the upgrade ends in a COMMIT,
+                        * sometimes not */
+                       if (m->session->tr->active)
+                               msg = mvc_commit(m, 0, NULL, false);
                }
                maybeupgrade = 0;
        }
@@ -746,6 +755,34 @@ SQLinitClient(Client c)
 }
 
 str
+SQLinitClientFromMAL(Client c) {
+       str msg = MAL_SUCCEED;
+
+       if ( (msg = SQLinitClient(c)) != MAL_SUCCEED) {
+               return msg;
+       }
+
+       mvc* m = ((backend*) c->sqlcontext)->mvc;
+
+       /* Crucial step:
+        * MAL scripts that interact with the sql module
+        * must have a properly initialized transaction.
+        */
+       SQLtrans(m);
+
+       if(*m->errstr) {
+               if (strlen(m->errstr) > 6 && m->errstr[5] == '!')
+                       msg = createException(PARSE, "SQLinitClientFromMAL", 
"%s", m->errstr);
+               else
+                       msg = createException(PARSE, "SQLinitClientFromMAL", 
SQLSTATE(42000) "%s", m->errstr);
+               *m->errstr=0;
+               c->mode = FINISHCLIENT;
+       }
+
+       return msg;
+}
+
+str
 SQLexitClient(Client c)
 {
        str err;
diff --git a/sql/backends/monet5/sql_scenario.h 
b/sql/backends/monet5/sql_scenario.h
--- a/sql/backends/monet5/sql_scenario.h
+++ b/sql/backends/monet5/sql_scenario.h
@@ -26,6 +26,7 @@ sql5_export str SQLexit(Client c);
 sql5_export str SQLexitClient(Client c);
 sql5_export str SQLresetClient(Client c);
 sql5_export str SQLinitClient(Client c);
+sql5_export str SQLinitClientFromMAL(Client c);
 sql5_export str SQLreader(Client c);
 sql5_export str SQLparser(Client c);
 sql5_export str SQLengine(Client c);
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -42,6 +42,7 @@ delta_bind_del(sql_dbat *bat, int access
        assert(access != RD_UPD_ID && access != RD_UPD_VAL);
 
        b = temp_descriptor(bat->dbid);
+       assert(BATcount(b) == bat->cnt);
        return b;
 }
 
@@ -787,6 +788,7 @@ dup_dbat( sql_trans *tr, sql_dbat *obat,
                } else {
                        bat->dbid = ebat_copy(bat->dbid, 0, temp);
                }
+               assert(BATcount(quick_descriptor(bat->dbid)) == bat->cnt);
                if (bat->dbid == BID_NIL) 
                        return LOG_ERR;
        }
@@ -944,11 +946,13 @@ delta_delete_bat( sql_dbat *bat, BAT *i 
                        return LOG_ERR;
        }
        assert(b->theap.storage != STORE_PRIV);
+       assert(BATcount(b) == bat->cnt);
        if (BATappend(b, i, NULL, true) != GDK_SUCCEED) {
                bat_destroy(b);
                return LOG_ERR;
        }
        BATkey(b, true);
+       assert(BATcount(b) == bat->cnt+ BATcount(i));
        bat_destroy(b);
 
        bat->cnt += BATcount(i);
@@ -971,6 +975,7 @@ delta_delete_val( sql_dbat *bat, oid rid
                        return LOG_ERR;
        }
        assert(b->theap.storage != STORE_PRIV);
+       assert(BATcount(b) == bat->cnt);
        if (BUNappend(b, (ptr)&rid, true) != GDK_SUCCEED) {
                bat_destroy(b);
                return LOG_ERR;
@@ -2258,12 +2263,15 @@ gtr_update_dbat(sql_trans *tr, sql_dbat 
                        assert(!isEbat(cdb));
                        if (append_inserted(cdb, idb) == BUN_NONE)
                                ok = LOG_ERR;
+                       else
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to