Changeset: 1c6c4b1ef943 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1c6c4b1ef943
Modified Files:
        .bumpversion.cfg
        MonetDB.spec
        clients/mapilib/mapi.rc
        clients/odbc/driver/driver.rc
        clients/odbc/winsetup/setup.rc
        cmake/monetdb-versions.cmake
        gdk/libbat.rc
        monetdb5/tools/libmonetdb5.rc
        sql/server/sql_parser.y
Branch: default
Log Message:

Merge with Sep2022 branch.


diffs (truncated from 912 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -783,3 +783,4 @@ ea797696d5e8d8d550f21f09b98d3bcade1d001d
 68c0e35095ad6a58766c6c1e77229d73148433e2 Sep2022_5
 47675351fec22d5d5dc81eec03dfa08f505afc99 Sep2022_7
 47675351fec22d5d5dc81eec03dfa08f505afc99 Sep2022_release
+44e45c9a451f6afd933773094ec25723f713d3be Jan2022_23
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -331,6 +331,42 @@ bailout:
 }
 
 static bool
+has_schema_max_memory(Mapi mid)
+{
+       MapiHdl hdl;
+       bool ret;
+       static int answer = -1;
+
+       if (answer >= 0)
+               return answer;
+
+       if ((hdl = mapi_query(mid, "select id from sys._columns where table_id 
= (select id from sys._tables where name = 'db_user_info' and schema_id = 
(select id from sys.schemas where name = 'sys')) and name = 'max_memory'")) == 
NULL ||
+           mapi_error(mid))
+               goto bailout;
+       ret = mapi_get_row_count(hdl) == 1;
+       while ((mapi_fetch_row(hdl)) != 0) {
+               if (mapi_error(mid))
+                       goto bailout;
+       }
+       if (mapi_error(mid))
+               goto bailout;
+       mapi_close_handle(hdl);
+       answer = ret;
+       return ret;
+
+bailout:
+       if (hdl) {
+               if (mapi_result_error(hdl))
+                       mapi_explain_result(hdl, stderr);
+               else
+                       mapi_explain_query(hdl, stderr);
+               mapi_close_handle(hdl);
+       } else
+               mapi_explain(mid, stderr);
+       return false;
+}
+
+static bool
 has_table_partitions(Mapi mid)
 {
        MapiHdl hdl;
@@ -2534,11 +2570,28 @@ dump_database(Mapi mid, stream *toConsol
                "ORDER BY s.name, t.sqlname";
        const char *users =
                has_schema_path(mid) ?
+               has_schema_max_memory(mid) ?
                "SELECT ui.name, "
                       "ui.fullname, "
                       "sys.password_hash(ui.name), "
                       "s.name, "
-                          "ui.schema_path "
+                          "ui.schema_path, "
+                          "ui.max_memory, "
+                          "ui.max_workers, "
+                          "ui.optimizer, "
+                          "au.name "
+               "FROM sys.db_user_info ui LEFT OUTER JOIN sys.auths au on 
ui.default_role = au.id, "
+                    "sys.schemas s "
+               "WHERE ui.default_schema = s.id "
+                 "AND ui.name <> 'monetdb' "
+                 "AND ui.name <> '.snapshot' "
+               "ORDER BY ui.name" :
+               "SELECT ui.name, "
+                      "ui.fullname, "
+                      "sys.password_hash(ui.name), "
+                      "s.name, "
+                          "ui.schema_path, "
+                          "0, 0, 'default_pipe', cast(null as clob) "
                "FROM sys.db_user_info ui, "
                     "sys.schemas s "
                "WHERE ui.default_schema = s.id "
@@ -2549,7 +2602,8 @@ dump_database(Mapi mid, stream *toConsol
                       "ui.fullname, "
                       "sys.password_hash(ui.name), "
                       "s.name, "
-                          "cast(null as clob) "
+                          "cast(null as clob), "
+                          "0, 0, 'default_pipe', cast(null as clob) "
                "FROM sys.db_user_info ui, "
                     "sys.schemas s "
                "WHERE ui.default_schema = s.id "
@@ -2824,6 +2878,10 @@ dump_database(Mapi mid, stream *toConsol
                        const char *pwhash = mapi_fetch_field(hdl, 2);
                        const char *sname = mapi_fetch_field(hdl, 3);
                        const char *spath = mapi_fetch_field(hdl, 4);
+                       const char *mmemory = mapi_fetch_field(hdl, 5);
+                       const char *mworkers = mapi_fetch_field(hdl, 6);
+                       const char *optimizer = mapi_fetch_field(hdl, 7);
+                       const char *defrole = mapi_fetch_field(hdl, 8);
 
                        mnstr_printf(toConsole, "CREATE USER ");
                        dquoted_print(toConsole, uname, " ");
@@ -2837,6 +2895,20 @@ dump_database(Mapi mid, stream *toConsol
                                mnstr_printf(toConsole, " SCHEMA PATH ");
                                squoted_print(toConsole, spath, '\'', false);
                        }
+                       if (mmemory && strcmp(mmemory, "0") != 0) {
+                               mnstr_printf(toConsole, " MAX_MEMORY %s", 
mmemory);
+                       }
+                       if (mworkers && strcmp(mworkers, "0") != 0) {
+                               mnstr_printf(toConsole, " MAX_WORKERS %s", 
mworkers);
+                       }
+                       if (optimizer && strcmp(optimizer, "default_pipe") != 
0) {
+                               mnstr_printf(toConsole, " OPTIMIZER ");
+                               squoted_print(toConsole, optimizer, '\'', 
false);
+                       }
+                       if (defrole && strcmp(defrole, uname) != 0) {
+                               mnstr_printf(toConsole, " DEFAULT ROLE ");
+                               dquoted_print(toConsole, defrole, NULL);
+                       }
                        mnstr_printf(toConsole, ";\n");
                }
                if (mapi_error(mid))
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -482,7 +482,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
        int stkpc = 0;
        RuntimeProfileRecord runtimeProfile, runtimeProfileFunction;
        lng lastcheck = 0;
-       int     startedProfileQueue = 0;
+       bool startedProfileQueue = false;
 #define CHECKINTERVAL 1000 /* how often do we check for client disconnect */
        runtimeProfile.ticks = runtimeProfileFunction.ticks = 0;
 
@@ -521,7 +521,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
 
        /* also produce event record for start of function */
        if (startpc == 1 &&  startpc < mb->stop ){
-               startedProfileQueue = 1;
+               startedProfileQueue = true;
                runtimeProfileInit(cntxt, mb, stk);
                runtimeProfileBegin(cntxt, mb, stk, getInstrPtr(mb,0), 
&runtimeProfileFunction);
                if (cntxt->sessiontimeout && mb->starttime - cntxt->session > 
cntxt->sessiontimeout) {
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
@@ -37,7 +37,7 @@ size_t usrstatscnt = 0;
 static inline void
 clearUSRstats(size_t idx)
 {
-       USRstats[idx] = (struct USERSTAT){0};
+       USRstats[idx] = (struct USERSTAT) {0};
 }
 
 /*
@@ -45,8 +45,7 @@ clearUSRstats(size_t idx)
  * For a new 'user' return a new free slot.
  * If USRstats is full, extend it.
  */
-static
-size_t
+static size_t
 getUSRstatsIdx(MalBlkPtr mb, oid user)
 {
        size_t i = 0;
@@ -71,8 +70,7 @@ getUSRstatsIdx(MalBlkPtr mb, oid user)
        return usrstatscnt - MAL_MAXCLIENTS;
 }
 
-static
-void
+static void
 updateUserStats(Client cntxt, MalBlkPtr mb, lng ticks, time_t started, time_t 
finished, str query)
 {
        // don't keep stats for context without username
@@ -95,7 +93,7 @@ updateUserStats(Client cntxt, MalBlkPtr 
        }
        USRstats[idx].querycount++;
        USRstats[idx].totalticks += ticks;
-       if( ticks >= USRstats[idx].maxticks && query){
+       if (ticks >= USRstats[idx].maxticks && query) {
                USRstats[idx].started = started;
                USRstats[idx].finished = finished;
                USRstats[idx].maxticks = ticks;
@@ -112,7 +110,7 @@ dropUSRstats(void)
 {
        size_t i;
        MT_lock_set(&mal_delayLock);
-       for(i = 0; i < usrstatscnt; i++){
+       for(i = 0; i < usrstatscnt; i++) {
                GDKfree(USRstats[i].username);
                GDKfree(USRstats[i].maxquery);
                clearUSRstats(i);
@@ -124,14 +122,14 @@ dropUSRstats(void)
 }
 
 static str
-isaSQLquery(MalBlkPtr mb){
-       int i;
-       InstrPtr p;
-       if (mb)
-       for ( i = 1; i< mb->stop; i++){
-               p = getInstrPtr(mb,i);
-               if ( getModuleId(p) && idcmp(getModuleId(p), "querylog") == 0 
&& idcmp(getFunctionId(p),"define")==0)
-                       return getVarConstant(mb,getArg(p,1)).val.sval;
+isaSQLquery(MalBlkPtr mb)
+{
+       if (mb) {
+               for (int i = 1; i< mb->stop; i++) {
+                       InstrPtr p = getInstrPtr(mb,i);
+                       if (getModuleId(p) && idcmp(getModuleId(p), "querylog") 
== 0 && idcmp(getFunctionId(p),"define")==0)
+                               return getVarConstant(mb,getArg(p,1)).val.sval;
+               }
        }
        return NULL;
 }
@@ -147,15 +145,14 @@ isaSQLquery(MalBlkPtr mb){
 static inline void
 clearQRYqueue(size_t idx)
 {
-       QRYqueue[idx] = (struct QRYQUEUE){0};
+       QRYqueue[idx] = (struct QRYQUEUE) {0};
 }
 
 static void
 dropQRYqueue(void)
 {
-       size_t i;
        MT_lock_set(&mal_delayLock);
-       for(i = 0; i < qsize; i++){
+       for(size_t i = 0; i < qsize; i++) {
                GDKfree(QRYqueue[i].query);
                GDKfree(QRYqueue[i].username);
                clearQRYqueue(i);
@@ -168,7 +165,8 @@ dropQRYqueue(void)
 }
 
 oid
-runtimeProfileSetTag(Client cntxt) {
+runtimeProfileSetTag(Client cntxt)
+{
        MT_lock_set(&mal_delayLock);
        cntxt->curprg->def->tag = qtag++;
        MT_lock_unset(&mal_delayLock);
@@ -190,20 +188,20 @@ runtimeProfileInit(Client cntxt, MalBlkP
                return;
        MT_lock_set(&mal_delayLock);
 
-       if(USRstats == NULL){
+       if (USRstats == NULL) {
                usrstatscnt = MAL_MAXCLIENTS;
                USRstats = (UserStats) GDKzalloc( sizeof (struct USERSTAT) * 
usrstatscnt);
-               if(USRstats == NULL) {
+               if (USRstats == NULL) {
                        addMalException(mb,"runtimeProfileInit" 
MAL_MALLOC_FAIL);
                        MT_lock_unset(&mal_delayLock);
                        return;
                }
        }
 
-       if ( QRYqueue == NULL) {
+       if (QRYqueue == NULL) {
                QRYqueue = (QueryQueue) GDKzalloc( sizeof (struct QRYQUEUE) * 
(qsize= MAL_MAXCLIENTS));
 
-               if ( QRYqueue == NULL){
+               if (QRYqueue == NULL) {
                        addMalException(mb,"runtimeProfileInit" 
MAL_MALLOC_FAIL);
                        MT_lock_unset(&mal_delayLock);
                        return;
@@ -212,11 +210,11 @@ runtimeProfileInit(Client cntxt, MalBlkP
        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( qsize - paused < (size_t) MAL_MAXCLIENTS){
+       if (qsize - paused < (size_t) MAL_MAXCLIENTS) {
                qsize += MAL_MAXCLIENTS;
                QueryQueue tmp;
                tmp = (QueryQueue) GDKrealloc( QRYqueue, sizeof (struct 
QRYQUEUE) * qsize);
-               if ( tmp == NULL){
+               if (tmp == NULL) {
                        addMalException(mb,"runtimeProfileInit" 
MAL_MALLOC_FAIL);
                        qsize -= MAL_MAXCLIENTS; /* undo increment */
                        MT_lock_unset(&mal_delayLock);
@@ -233,8 +231,8 @@ runtimeProfileInit(Client cntxt, MalBlkP
                size_t j = qlast;
                if (++qlast >= qsize)
                        qlast = 0;
-               if (QRYqueue[j].query == NULL ||
-                       QRYqueue[j].status == 0 ||
+               if (QRYqueue[j].stk == NULL ||
+                       QRYqueue[j].status == NULL ||
                        (QRYqueue[j].status[0] != 'r' &&
                         QRYqueue[j].status[0] != 'p')) {
                        QRYqueue[j].mb = mb;
@@ -278,15 +276,15 @@ runtimeProfileFinish(Client cntxt, MalBl
                return;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to