Changeset: e6317c345763 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e6317c345763
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        monetdb5/mal/mal_client.h
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_private.h
        monetdb5/mal/mal_scenario.c
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/clients.h
        monetdb5/modules/mal/clients.mal
        sql/backends/monet5/sql_datetrunc.c
        sql/backends/monet5/sql_execute.c
        sql/backends/monet5/sql_upgrades.c
        sql/jdbc/tests/Tests/Test_PSmetadata.stable.out
        sql/scripts/22_clients.sql
        sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.out
        sql/test/Tests/systemfunctions.stable.out
        sql/test/Tests/systemfunctions.stable.out.int128
        sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
        sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.32bit
        sql/test/emptydb/Tests/check.stable.out.int128
        sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.powerpc64.int128
Branch: default
Log Message:

Merge with Apr2019 branch.


diffs (truncated from 1202 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -10740,6 +10740,7 @@ Ready.
 [ "clients",   "setListing",   "pattern clients.setListing(flag:int):int ",    
"CLTsetListing;",       "Turn on/off echo of MAL instructions:\n\t1 - echo 
input,\n\t2 - show mal instruction,\n\t4 - show details of type resolutoin, 
\n\t8 - show binding information."       ]
 [ "clients",   "setPassword",  "pattern clients.setPassword(user:str, 
pass:str):void ",        "CLTsetPassword;",      "Set the password for the 
given user"   ]
 [ "clients",   "setScenario",  "pattern clients.setScenario(msg:str):str ",    
"CLTsetScenario;",      "Switch to other scenario handler, return previous 
one."        ]
+[ "clients",   "setprinttimeout",      "command 
clients.setprinttimeout(n:int):void ", "CLTsetPrintTimeout;",  "Print running 
query every so many seconds."    ]
 [ "clients",   "setsession",   "pattern clients.setsession(n:lng):void ",      
"CLTsetSessionTimeout;",        "Abort a session after  n seconds."     ]
 [ "clients",   "settimeout",   "pattern clients.settimeout(n:lng):void ",      
"CLTsetTimeout;",       "Abort a query after  n seconds."       ]
 [ "clients",   "settimeout",   "pattern clients.settimeout(q:lng, s:lng):void 
",       "CLTsetTimeout;",       "Abort a query after q seconds (q=0 means run 
undisturbed).\nThe session timeout aborts the connection after spending 
too\nmany seconds on query processing."   ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -15136,6 +15136,7 @@ Ready.
 [ "clients",   "setListing",   "pattern clients.setListing(flag:int):int ",    
"CLTsetListing;",       "Turn on/off echo of MAL instructions:\n\t1 - echo 
input,\n\t2 - show mal instruction,\n\t4 - show details of type resolutoin, 
\n\t8 - show binding information."       ]
 [ "clients",   "setPassword",  "pattern clients.setPassword(user:str, 
pass:str):void ",        "CLTsetPassword;",      "Set the password for the 
given user"   ]
 [ "clients",   "setScenario",  "pattern clients.setScenario(msg:str):str ",    
"CLTsetScenario;",      "Switch to other scenario handler, return previous 
one."        ]
+[ "clients",   "setprinttimeout",      "command 
clients.setprinttimeout(n:int):void ", "CLTsetPrintTimeout;",  "Print running 
query every so many seconds."    ]
 [ "clients",   "setsession",   "pattern clients.setsession(n:lng):void ",      
"CLTsetSessionTimeout;",        "Abort a session after  n seconds."     ]
 [ "clients",   "settimeout",   "pattern clients.settimeout(n:lng):void ",      
"CLTsetTimeout;",       "Abort a query after  n seconds."       ]
 [ "clients",   "settimeout",   "pattern clients.settimeout(q:lng, s:lng):void 
",       "CLTsetTimeout;",       "Abort a query after q seconds (q=0 means run 
undisturbed).\nThe session timeout aborts the connection after spending 
too\nmany seconds on query processing."   ]
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
@@ -912,6 +912,7 @@ str CLTripemd160sum(str *ret, str *pw);
 str CLTsessions(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTsetListing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTsetPassword(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+str CLTsetPrintTimeout(void *ret, int *secs);
 str CLTsetScenario(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTsetSessionTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
 str CLTsetTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -86,6 +86,7 @@ typedef struct CLIENT {
        lng             session;        /* usec since start of server */
        lng         qtimeout;   /* query abort after x usec*/
        lng             stimeout;       /* session abort after x usec */
+       lng         lastprint;  /* when we last printed the query */
        /*
         * Communication channels for the interconnect are stored here.
         * It is perfectly legal to have a client without input stream.
diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -360,7 +360,8 @@ DFLOWworker(void *T)
                                /* no more work to be done: exit */
                                break;
                        }
-                       MT_thread_setworking(fe->flow->cntxt->query);
+                       if (fe->flow->cntxt && fe->flow->cntxt->mythread)
+                               
MT_thread_setworking(fe->flow->cntxt->mythread->name);
                } else
                        fe = fnxt;
                if (ATOMIC_GET(&exiting)) {
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
@@ -19,6 +19,14 @@
 #include "mal_type.h"
 #include "mal_private.h"
 
+static lng qptimeout = 0; /* how often we print still running queries (usec) */
+static MT_Lock qptimeoutLock = MT_LOCK_INITIALIZER("qptimeoutLock");
+
+void
+setqptimeout(lng usecs)
+{
+       qptimeout = usecs;
+}
 
 inline
 ptr getArgReference(MalStkPtr stk, InstrPtr pci, int k)
@@ -289,6 +297,7 @@ str runMAL(Client cntxt, MalBlkPtr mb, M
         * enough
         */
        cntxt->lastcmd= time(0);
+       cntxt->lastprint = GDKusec();
        if (env != NULL) {
                int res = 1;
                stk = env;
@@ -551,6 +560,18 @@ str runMALsequence(Client cntxt, MalBlkP
                        lastcheck = runtimeProfile.ticks;
                }
 
+               if (qptimeout > 0) {
+                       MT_lock_set(&qptimeoutLock);
+                       lng t = GDKusec();
+                       if (cntxt->lastprint + qptimeout < t) {
+                               fprintf(stderr, "#%s: query already running 
"LLFMT"s: %.200s\n",
+                                               cntxt->mythread->name, (t - 
cntxt->lastprint)/1000000,
+                                               cntxt->query);
+                               cntxt->lastprint = t;
+                       }
+                       MT_lock_unset(&qptimeoutLock);
+               }
+
                /* The interpreter loop
                 * The interpreter is geared towards execution a MAL
                 * procedure together with all its descendant
diff --git a/monetdb5/mal/mal_private.h b/monetdb5/mal/mal_private.h
--- a/monetdb5/mal/mal_private.h
+++ b/monetdb5/mal/mal_private.h
@@ -48,6 +48,9 @@
 
 __hidden extern MT_Lock mal_namespaceLock;
 
+__hidden void setqptimeout(lng usecs)
+       __attribute__((__visibility__("hidden")));
+
 __hidden void mdbInit(void)
        __attribute__((__visibility__("hidden")));
 __hidden void mdbExit(void)
diff --git a/monetdb5/mal/mal_scenario.c b/monetdb5/mal/mal_scenario.c
--- a/monetdb5/mal/mal_scenario.c
+++ b/monetdb5/mal/mal_scenario.c
@@ -526,11 +526,12 @@ runPhase(Client c, int phase)
 static str
 runScenarioBody(Client c, int once)
 {
-       str msg= MAL_SUCCEED;
+       str msg;
 
        c->exception_buf_initialized = 1;
        if (setjmp( c->exception_buf) < 0)
                c->mode = FINISHCLIENT;
+       msg = MAL_SUCCEED;
        while (c->mode > FINISHCLIENT && !GDKexiting()) {
                // be aware that a MAL call  may initialize a different scenario
                if ( !c->state[0] && (msg = runPhase(c, 
MAL_SCENARIO_INITCLIENT)) ) 
diff --git a/monetdb5/modules/mal/clients.c b/monetdb5/modules/mal/clients.c
--- a/monetdb5/modules/mal/clients.c
+++ b/monetdb5/modules/mal/clients.c
@@ -367,6 +367,17 @@ CLTgetTimeout(Client cntxt, MalBlkPtr mb
 }
 
 str
+CLTsetPrintTimeout(void *ret, int *secs)
+{
+       (void) ret;
+       if (is_int_nil(*secs))
+               setqptimeout(0);
+       else
+               setqptimeout((lng) *secs * 1000000);
+       return MAL_SUCCEED;
+}
+
+str
 CLTwakeup(void *ret, int *id)
 {
     (void) ret;     /* fool compiler */
diff --git a/monetdb5/modules/mal/clients.h b/monetdb5/modules/mal/clients.h
--- a/monetdb5/modules/mal/clients.h
+++ b/monetdb5/modules/mal/clients.h
@@ -32,6 +32,7 @@ mal_export str CLTsuspend(Client cntxt, 
 mal_export str CLTsetTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 mal_export str CLTsetSessionTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 mal_export str CLTgetTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+mal_export str CLTsetPrintTimeout(void *ret, int *secs);
 mal_export str CLTwakeup(void *ret, int *id);
 
 mal_export str CLTshutdown(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
diff --git a/monetdb5/modules/mal/clients.mal b/monetdb5/modules/mal/clients.mal
--- a/monetdb5/modules/mal/clients.mal
+++ b/monetdb5/modules/mal/clients.mal
@@ -88,6 +88,10 @@ comment "A query is aborted after q mill
 The session timeout aborts the connection after spending too
 many seconds on query processing.";
 
+command setprinttimeout(n:int):void
+address CLTsetPrintTimeout
+comment "Print running query every so many seconds.";
+
 pattern shutdown(delay:int):str
 address CLTshutdown;
 pattern shutdown(delay:int, forced:bit):str
diff --git a/sql/backends/monet5/sql_datetrunc.c 
b/sql/backends/monet5/sql_datetrunc.c
--- a/sql/backends/monet5/sql_datetrunc.c
+++ b/sql/backends/monet5/sql_datetrunc.c
@@ -10,34 +10,37 @@
 #include "sql.h"
 #include "mal_instruction.h"
 
-#define date_trunc_time_loop(NAME, TYPE, DIVISOR)      \
-       if  ( strcmp(*scale, NAME) == 0){ \
-               for( ; lo < hi; lo++)           \
-                       if (is_timestamp_nil(bt[lo])) {                 \
-                                       dt[lo] = *timestamp_nil;                
\
-                                       nils++;         \
-                       } else {                                \
-                               ts = bt[0];                                     
\
-                               ts.msecs = (int) ((lng)ts.msecs / (lng)DIVISOR) 
* (lng)DIVISOR; \
-                               dt[lo] = ts;                                    
\
-       }               }
+#define date_trunc_time_loop(NAME, DIVISOR)                            \
+       do {                                                            \
+               if  ( strcmp(*scale, NAME) == 0){                       \
+                       for( ; lo < hi; lo++)                           \
+                               if (is_timestamp_nil(bt[lo])) {         \
+                                       dt[lo] = *timestamp_nil;        \
+                               } else {                                \
+                                       ts = bt[0];                     \
+                                       ts.msecs = (ts.msecs / (DIVISOR)) * 
(DIVISOR); \
+                                       dt[lo] = ts;                    \
+                               }                                       \
+               }                                                       \
+       } while (0)
 
-static int truncate_check(const str *scale){
-       (void) scale;
-       return 
-               strcmp(*scale, "millenium") == 0 ||
-               strcmp(*scale, "century") == 0  ||
-               strcmp(*scale, "decade") == 0 ||
-               strcmp(*scale, "year") == 0 ||
-               strcmp(*scale, "quarter" ) == 0 ||
-               strcmp(*scale, "month") == 0 ||
-               strcmp(*scale, "week") == 0 ||
-               strcmp(*scale, "day") == 0  ||
-               strcmp(*scale, "hour") == 0 ||
-               strcmp(*scale, "minute") == 0 ||
-               strcmp(*scale, "second") == 0 ||
-               strcmp(*scale, "milliseconds") == 0 ||
-               strcmp(*scale, "microseconds") == 0;
+static inline bool
+truncate_check(const char *scale)
+{
+       return
+               strcmp(scale, "millenium") == 0 ||
+               strcmp(scale, "century") == 0  ||
+               strcmp(scale, "decade") == 0 ||
+               strcmp(scale, "year") == 0 ||
+               strcmp(scale, "quarter" ) == 0 ||
+               strcmp(scale, "month") == 0 ||
+               strcmp(scale, "week") == 0 ||
+               strcmp(scale, "day") == 0  ||
+               strcmp(scale, "hour") == 0 ||
+               strcmp(scale, "minute") == 0 ||
+               strcmp(scale, "second") == 0 ||
+               strcmp(scale, "milliseconds") == 0 ||
+               strcmp(scale, "microseconds") == 0;
 }
 
 str
@@ -45,14 +48,13 @@ bat_date_trunc(bat *res, const str *scal
 {
        BAT *b, *bn;
        oid lo, hi;
-       timestamp *bt;
+       const timestamp *bt;
        timestamp *dt;
        char *msg = NULL;
-       lng nils = 0;
        timestamp ts;
        int dow, y, m, d, one = 1;
 
-       if ( truncate_check(scale) == 0)
+       if ( truncate_check(*scale) == 0)
                throw(SQL, "batcalc.truncate_timestamp", SQLSTATE(HY005) 
"Improper directive ");
 
        if ((b = BATdescriptor(*bid)) == NULL) {
@@ -64,140 +66,146 @@ bat_date_trunc(bat *res, const str *scal
                throw(SQL, "sql.truncate", SQLSTATE(HY001) MAL_MALLOC_FAIL);
        }
 
-       bt = (timestamp *) Tloc(b, 0);
+       bt = (const timestamp *) Tloc(b, 0);
        dt = (timestamp *) Tloc(bn, 0);
 
        lo = 0;
        hi = lo + BATcount(b);
 
-       date_trunc_time_loop("microseconds", TIMESTAMP, 1)
-       date_trunc_time_loop("milliseconds", TIMESTAMP, 1)
-       date_trunc_time_loop("second", TIMESTAMP, (1000 ))
-       date_trunc_time_loop("minute", TIMESTAMP, (1000 * 60))
-       date_trunc_time_loop("hour", TIMESTAMP, (1000 * 60 * 24))
+       date_trunc_time_loop("microseconds", 1);
+       date_trunc_time_loop("milliseconds", 1);
+       date_trunc_time_loop("second", 1000);
+       date_trunc_time_loop("minute", 1000 * 60);
+       date_trunc_time_loop("hour", 1000 * 60 * 24);
 
-       if  ( strcmp(*scale, "day") == 0){ 
-               for( ; lo < hi; lo++)           
-                       if (is_timestamp_nil(bt[lo])) {                 
-                               dt[lo] = *timestamp_nil;                
-                       } else {                                
-                               ts = bt[lo];                                    
+       if  ( strcmp(*scale, "day") == 0){
+               for( ; lo < hi; lo++)
+                       if (is_timestamp_nil(bt[lo])) {
+                               dt[lo] = *timestamp_nil;
+                       } else {
+                               ts = bt[lo];
                                ts.msecs = 0;
-                               dt[lo] = ts;                                    
-       }               }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to