Changeset: 6cf18c377268 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6cf18c377268
Modified Files:
        clients/Tests/exports.stable.out
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
Branch: default
Log Message:

Merge with Sep2022.


diffs (truncated from 754 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1268,7 +1268,6 @@ const char *putNameLen(const char *nme, 
 const char *putRef;
 const char *pyapi3Ref;
 const char *pyapi3mapRef;
-size_t qhead, qtail, qsize;
 const char *queryRef;
 const char *querylogRef;
 const char *raiseRef;
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2122,13 +2122,13 @@ dump_function(Mapi mid, stream *toConsol
 
        query_len = snprintf(query, query_size,
                      "SELECT f.id, "
-                            "f.func, "
-                            "f.language, "
-                            "f.type, "
-                            "s.name, "
-                            "f.name, "
-                            "ft.function_type_keyword, "
-                            "fl.language_keyword, "
+                                        "f.func, "
+                                        "f.language, "
+                                        "f.type, "
+                                        "s.name, "
+                                        "f.name, "
+                                        "ft.function_type_keyword, "
+                                        "fl.language_keyword, "
                             "c.remark "
                      "FROM sys.functions f "
                           "JOIN sys.schemas s ON f.schema_id = s.id "
@@ -2536,7 +2536,7 @@ dump_database(Mapi mid, stream *toConsol
                has_schema_path(mid) ?
                "SELECT ui.name, "
                       "ui.fullname, "
-                      "password_hash(ui.name), "
+                      "sys.password_hash(ui.name), "
                       "s.name, "
                           "ui.schema_path "
                "FROM sys.db_user_info ui, "
@@ -2547,7 +2547,7 @@ dump_database(Mapi mid, stream *toConsol
                "ORDER BY ui.name" :
                "SELECT ui.name, "
                       "ui.fullname, "
-                      "password_hash(ui.name), "
+                      "sys.password_hash(ui.name), "
                       "s.name, "
                           "cast(null as clob) "
                "FROM sys.db_user_info ui, "
diff --git a/monetdb5/mal/mal_internal.h b/monetdb5/mal/mal_internal.h
--- a/monetdb5/mal/mal_internal.h
+++ b/monetdb5/mal/mal_internal.h
@@ -14,3 +14,5 @@
 
 void setqptimeout(lng usecs)
        __attribute__((__visibility__("hidden")));
+
+extern size_t qsize;
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
@@ -692,10 +692,20 @@ openProfilerStream(Client cntxt, int m)
                        throw(MAL,"profiler.start","Profiler already running, 
stream not available");
                }
        }
-       profilerStatus = -1;
-       /* 4 activates minimal mode. 1 and 3 were used in prev MonetDB versions 
*/
-       /* else default is 0 of global var profilerMode */
-       if (m == 4) profilerMode = 1;
+       /* 4 activates profiler in minimal mode. 1 and 3 were used in prev 
MonetDB versions */
+       /* 0 activates profiler in detailed mode */
+       switch (m) {
+           case 0:
+                       profilerStatus = -1;
+                       break;
+           case 4:
+                       profilerStatus = -1;
+                       profilerMode = 1;
+                       break;
+           default:
+                       MT_lock_unset(&mal_profileLock);
+                       throw(MAL,"profiler.openstream","Undefined profiler 
mode option");
+       }
        maleventstream = cntxt->fdout;
        profilerUser = cntxt->user;
 
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -23,11 +23,12 @@
 #include "mal_listing.h"
 #include "mal_authorize.h"
 #include "mal_resource.h"
+#include "mal_internal.h"
 #include "mal_private.h"
 
 
 QueryQueue QRYqueue = NULL;
-size_t qsize = 0, qhead = 0, qtail = 0;
+size_t qsize = 0;
 static oid qtag= 1;            // A unique query identifier
 
 UserStats  USRstats = NULL;
@@ -153,34 +154,6 @@ clearQRYqueue(size_t idx)
 }
 
 static void
-advanceQRYqueue(void)
-{
-       bool found_empty_slot = false;
-
-       while (!found_empty_slot) {
-               qhead++;
-               if( qhead == qsize)
-                       qhead = 0;
-               if( qtail == qhead)
-                       qtail++;
-               if( qtail == qsize)
-                       qtail = 0;
-               /* clean out the element */
-               str s = QRYqueue[qhead].query;
-               if (!s || QRYqueue[qhead].status == 0 || 
(QRYqueue[qhead].status[0] != 'r' && QRYqueue[qhead].status[0] != 'p')) {
-                       /* don't wipe them when they are still running, 
prepared, or paused */
-                       /* The upper layer has assured there is at least one 
slot available */
-                       if (s) {
-                               GDKfree(s);
-                               GDKfree(QRYqueue[qhead].username);
-                               clearQRYqueue(qhead);
-                       }
-                       found_empty_slot = true;
-               }
-       }
-}
-
-static void
 dropQRYqueue(void)
 {
        size_t i;
@@ -194,8 +167,6 @@ dropQRYqueue(void)
        QRYqueue = NULL;
        qsize = 0;
        qtag = 1;
-       qhead = 0;
-       qtail = 0;
        MT_lock_unset(&mal_delayLock);
 }
 
@@ -212,6 +183,7 @@ runtimeProfileSetTag(Client cntxt) {
 void
 runtimeProfileInit(Client cntxt, MalBlkPtr mb, MalStkPtr stk)
 {
+       static size_t qlast = 0;
        size_t i, paused = 0;
        str q;
 
@@ -240,12 +212,8 @@ runtimeProfileInit(Client cntxt, MalBlkP
                        return;
                }
        }
-       assert(qhead < qsize);
-       i=qtail;
-       while (i != qhead){
+       for (i = 0; i < qsize; i++) {
                paused += QRYqueue[i].status && (QRYqueue[i].status[0] == 'p' 
|| QRYqueue[i].status[0] == 'r'); /* running, prepared or paused */
-               if (++i >= qsize)
-                       i = 0;
        }
        if( qsize - paused < (size_t) MAL_MAXCLIENTS){
                qsize += MAL_MAXCLIENTS;
@@ -264,24 +232,34 @@ runtimeProfileInit(Client cntxt, MalBlkP
 
        // add new invocation
        cntxt->idle = 0;
-       QRYqueue[qhead].mb = mb;
-       QRYqueue[qhead].tag = stk->tag = mb->tag;
-       QRYqueue[qhead].stk = stk;                              // for status 
pause 'p'/running '0'/ quiting 'q'
-       QRYqueue[qhead].finished = 0;
-       QRYqueue[qhead].start = time(0);
-       q = isaSQLquery(mb);
-       QRYqueue[qhead].query = q? GDKstrdup(q):0;
-       GDKfree(QRYqueue[qhead].username);
-       if (!GDKembedded())
-               QRYqueue[qhead].username = GDKstrdup(cntxt->username);
-       QRYqueue[qhead].idx = cntxt->idx;
-       /* give the MB upperbound by addition of 1 MB */
-       QRYqueue[qhead].memory = 1 + (int) (stk->memory / 
LL_CONSTANT(1048576)); /* Convert to MB */
-       QRYqueue[qhead].workers = (int) 1;      /* this is the first one */
-       QRYqueue[qhead].status = "running";
-       QRYqueue[qhead].cntxt = cntxt;
-       QRYqueue[qhead].ticks = GDKusec();
-       advanceQRYqueue();
+       for (i = 0; i < qsize; i++) {
+               size_t j = qlast;
+               if (++qlast >= qsize)
+                       qlast = 0;
+               if (QRYqueue[j].query == NULL ||
+                       QRYqueue[j].status == 0 ||
+                       (QRYqueue[j].status[0] != 'r' &&
+                        QRYqueue[j].status[0] != 'p')) {
+                       QRYqueue[j].mb = mb;
+                       QRYqueue[j].tag = stk->tag = mb->tag;
+                       QRYqueue[j].stk = stk;                          // for 
status pause 'p'/running '0'/ quiting 'q'
+                       QRYqueue[j].finished = 0;
+                       QRYqueue[j].start = time(0);
+                       q = isaSQLquery(mb);
+                       QRYqueue[j].query = q? GDKstrdup(q):0;
+                       GDKfree(QRYqueue[j].username);
+                       if (!GDKembedded())
+                               QRYqueue[j].username = 
GDKstrdup(cntxt->username);
+                       QRYqueue[j].idx = cntxt->idx;
+                       /* give the MB upperbound by addition of 1 MB */
+                       QRYqueue[j].memory = 1 + (int) (stk->memory / 
LL_CONSTANT(1048576)); /* Convert to MB */
+                       QRYqueue[j].workers = (int) 1;  /* this is the first 
one */
+                       QRYqueue[j].status = "running";
+                       QRYqueue[j].cntxt = cntxt;
+                       QRYqueue[j].ticks = GDKusec();
+                       break;
+               }
+       }
        MT_lock_unset(&mal_delayLock);
 }
 
@@ -301,8 +279,7 @@ runtimeProfileFinish(Client cntxt, MalBl
        if (stk->up)
                return;
        MT_lock_set(&mal_delayLock);
-       i=qtail;
-       while (i != qhead){
+       for (i = 0; i < qsize; i++) {
                if (QRYqueue[i].stk == stk){
                        QRYqueue[i].status = "finished";
                        QRYqueue[i].finished = time(0);
@@ -319,8 +296,6 @@ runtimeProfileFinish(Client cntxt, MalBl
                        found = true;
                        break;
                }
-               if (++i >= qsize)
-                       i = 0;
        }
 
        // every query that has been started has an entry in QRYqueue.  If this
@@ -330,8 +305,7 @@ runtimeProfileFinish(Client cntxt, MalBl
                assert(0);
                TRC_INFO_IF(MAL_SERVER) {
                        TRC_INFO_ENDIF(MAL_SERVER, "runtimeProfilerFinish: stk 
(%p) not found in QRYqueue", stk);
-                       i = qtail;
-                       while (i != qhead){
+                       for (i = 0; i < qsize; i++) {
                                // print some info. of queries not "finished"
                                if (strcmp(QRYqueue[i].status, "finished") != 
0) {
                                        TRC_INFO_ENDIF(MAL_SERVER, 
"QRYqueue[%zu]: stk(%p), tag("OIDFMT"), username(%s), start(%ld), status(%s), 
query(%s)",
@@ -339,8 +313,6 @@ runtimeProfileFinish(Client cntxt, MalBl
                                                                   
QRYqueue[i].username, QRYqueue[i].start,
                                                                   
QRYqueue[i].status, QRYqueue[i].query);
                                }
-                               if (++i >= qsize)
-                                       i = 0;
                        }
                }
        }
diff --git a/monetdb5/mal/mal_runtime.h b/monetdb5/mal/mal_runtime.h
--- a/monetdb5/mal/mal_runtime.h
+++ b/monetdb5/mal/mal_runtime.h
@@ -39,7 +39,6 @@ typedef struct QRYQUEUE{
        time_t start;
        time_t finished;
 } *QueryQueue;
-mal_export size_t qhead, qtail, qsize;
 
 /* We keep a few statistics per user to identify unexpected behavior */
 typedef struct USERSTAT{
diff --git a/monetdb5/modules/mal/profiler.c b/monetdb5/modules/mal/profiler.c
--- a/monetdb5/modules/mal/profiler.c
+++ b/monetdb5/modules/mal/profiler.c
@@ -51,9 +51,10 @@ CMDopenProfilerStream(Client cntxt, MalB
        (void) stk;
        (void) pc;
        int m = 0;
-       if (getArgType(mb, pc, 1) == TYPE_int && (pc->argc == 1 || pc->argc == 
2)) {
+       if (pc->argc == 2 && getArgType(mb, pc, 1) == TYPE_int)
                m = *getArgReference_int(stk, pc, 1);
-       }
+       else if (pc->argc > 2)
+               m = -1;
        return openProfilerStream(cntxt, m);
 }
 
diff --git a/monetdb5/modules/mal/sysmon.c b/monetdb5/modules/mal/sysmon.c
--- a/monetdb5/modules/mal/sysmon.c
+++ b/monetdb5/modules/mal/sysmon.c
@@ -14,6 +14,7 @@
 #include "mal_runtime.h"
 #include "gdk_time.h"
 #include "mal_exception.h"
+#include "mal_internal.h"
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to