Changeset: 3cf1dd61f451 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3cf1dd61f451
Added Files:
        sql/backends/monet5/sql_datetrunc.c
        sql/test/BugTracker-2019/Tests/date_trunc.sql
        sql/test/BugTracker-2019/Tests/date_trunc.stable.err
        sql/test/BugTracker-2019/Tests/date_trunc.stable.out
        sql/test/BugTracker-2019/Tests/date_trunc_bulk.sql
        sql/test/BugTracker-2019/Tests/date_trunc_bulk.stable.err
        sql/test/BugTracker-2019/Tests/date_trunc_bulk.stable.out
        sql/test/FeatureRequests/Tests/enhanced_date_operators.sql
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        gdk/gdk_imprints.c
        gdk/gdk_system.c
        gdk/gdk_system.h
        gdk/gdk_system_private.h
        gdk/gdk_utils.c
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_client.h
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_scenario.c
        monetdb5/mal/mal_session.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/atoms/mtime.h
        monetdb5/modules/mal/mal_mapi.c
        sql/backends/monet5/Makefile.ag
        sql/backends/monet5/sql.h
        sql/backends/monet5/sql.mal
        sql/backends/monet5/sql_bat2time.c
        sql/backends/monet5/sql_execute.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/sql_upgrades.c
        sql/backends/monet5/wlr.c
        sql/scripts/17_temporal.sql
        sql/storage/store.c
        sql/test/BugTracker-2019/Tests/All
        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 1919 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
@@ -11675,6 +11675,8 @@ Ready.
 [ "sql",       "cume_dist",    "pattern sql.cume_dist(b:any_1, p:bit, 
o:bit):dbl ",    "SQLcume_dist;",        "return the accumulated distribution 
of the number of rows per group to the total number of partition rows"     ]
 [ "sql",       "current_time", "pattern sql.current_time():daytime ",  
"SQLcurrent_daytime;",  "Get the clients current daytime"       ]
 [ "sql",       "current_timestamp",    "pattern 
sql.current_timestamp():timestamp ",   "SQLcurrent_timestamp;",        "Get the 
clients current timestamp"     ]
+[ "sql",       "date_trunc",   "command sql.date_trunc(scale:str, 
v:bat[:timestamp]):bat[:timestamp] ",        "bat_date_trunc;",      "Truncate 
a timestamp to (millenium, 
century,decade,year,quarter,month,week,day,hour,minute,second, 
milliseconds,microseconds)" ]
+[ "sql",       "date_trunc",   "command sql.date_trunc(scale:str, 
v:timestamp):timestamp ",    "date_trunc;",  "Truncate a timestamp to 
(millenium, century,decade,year,quarter,month,week,day,hour,minute,second, 
milliseconds,microseconds)" ]
 [ "sql",       "db_users",     "pattern sql.db_users():bat[:str] ",    
"db_users_wrap;",       "return table of users with sql scenario"       ]
 [ "sql",       "dec_round",    "command sql.dec_round(v:bte, r:bte):bte ",     
"bte_dec_round_wrap;",  "round off the value v to nearests multiple of r"       
]
 [ "sql",       "dec_round",    "command sql.dec_round(v:dbl, r:dbl):dbl ",     
"dbl_dec_round_wrap;",  "round off the value v to nearests multiple of r"       
]
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
@@ -16088,6 +16088,8 @@ Ready.
 [ "sql",       "cume_dist",    "pattern sql.cume_dist(b:any_1, p:bit, 
o:bit):dbl ",    "SQLcume_dist;",        "return the accumulated distribution 
of the number of rows per group to the total number of partition rows"     ]
 [ "sql",       "current_time", "pattern sql.current_time():daytime ",  
"SQLcurrent_daytime;",  "Get the clients current daytime"       ]
 [ "sql",       "current_timestamp",    "pattern 
sql.current_timestamp():timestamp ",   "SQLcurrent_timestamp;",        "Get the 
clients current timestamp"     ]
+[ "sql",       "date_trunc",   "command sql.date_trunc(scale:str, 
v:bat[:timestamp]):bat[:timestamp] ",        "bat_date_trunc;",      "Truncate 
a timestamp to (millenium, 
century,decade,year,quarter,month,week,day,hour,minute,second, 
milliseconds,microseconds)" ]
+[ "sql",       "date_trunc",   "command sql.date_trunc(scale:str, 
v:timestamp):timestamp ",    "date_trunc;",  "Truncate a timestamp to 
(millenium, century,decade,year,quarter,month,week,day,hour,minute,second, 
milliseconds,microseconds)" ]
 [ "sql",       "db_users",     "pattern sql.db_users():bat[:str] ",    
"db_users_wrap;",       "return table of users with sql scenario"       ]
 [ "sql",       "dec_round",    "command sql.dec_round(v:bte, r:bte):bte ",     
"bte_dec_round_wrap;",  "round off the value v to nearests multiple of r"       
]
 [ "sql",       "dec_round",    "command sql.dec_round(v:dbl, r:dbl):dbl ",     
"dbl_dec_round_wrap;",  "round off the value v to nearests multiple of r"       
]
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
@@ -318,6 +318,7 @@ bool MT_thread_init(void);
 void MT_thread_setdata(void *data);
 void MT_thread_setlockwait(MT_Lock *lock);
 void MT_thread_setsemawait(MT_Sema *sema);
+void MT_thread_setworking(const char *work);
 void OIDXdestroy(BAT *b);
 ssize_t OIDfromStr(const char *src, size_t *len, oid **dst, bool external);
 ssize_t OIDtoStr(str *dst, size_t *len, const oid *src, bool external);
@@ -1499,6 +1500,7 @@ str MTIMEdate_extract_quarter_bulk(bat *
 str MTIMEdate_extract_weekofyear(int *ret, const date *v);
 str MTIMEdate_extract_year(int *ret, const date *v);
 str MTIMEdate_extract_year_bulk(bat *ret, const bat *bid);
+str MTIMEdate_extract_ymd(int *year, int *month, int *day, const date *v);
 str MTIMEdate_fromstr(date *ret, const char *const *s);
 str MTIMEdate_sub_msec_interval_lng_wrap(date *ret, const date *t, const lng 
*msec);
 str MTIMEdate_sub_sec_interval_wrap(date *ret, const date *t, const int *sec);
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -360,7 +360,6 @@ BATimprints(BAT *b)
 
        if (BATcheckimprints(b))
                return GDK_SUCCEED;
-       assert(b->timprints == NULL);
 
        if (VIEWtparent(b)) {
                /* views always keep null pointer and need to obtain
@@ -370,7 +369,6 @@ BATimprints(BAT *b)
                assert(b);
                if (BATcheckimprints(b))
                        return GDK_SUCCEED;
-               assert(b->timprints == NULL);
        }
        MT_lock_set(&GDKimprintsLock(b->batCacheid));
        ACCELDEBUG t0 = GDKusec();
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -174,6 +174,7 @@ static struct winthread {
        MT_Lock *lockwait;      /* lock we're waiting for */
        MT_Sema *semawait;      /* semaphore we're waiting for */
        struct winthread *joinwait; /* process we are joining with */
+       const char *working;    /* what we're currently doing */
        ATOMIC_TYPE exited;
        bool detached:1, waiting:1;
        char threadname[16];
@@ -186,6 +187,23 @@ static struct winthread mainthread = {
 static CRITICAL_SECTION winthread_cs;
 static DWORD threadslot = TLS_OUT_OF_INDEXES;
 
+void
+dump_threads(void)
+{
+       EnterCriticalSection(&winthread_cs);
+       for (struct winthread *w = winthreads; w; w = w->next) {
+               fprintf(stderr, "%s, waiting for %s, working on %.200s\n",
+                       w->threadname,
+                       w->lockwait ? w->lockwait->name :
+                       w->semawait ? w->semawait->name :
+                       w->joinwait ? w->joinwait->threadname :
+                       "nothing",
+                       ATOMIC_GET(&w->exited) ? "exiting" :
+                       w->working ? w->working : "nothing");
+       }
+       LeaveCriticalSection(&winthread_cs);
+}
+
 bool
 MT_thread_init(void)
 {
@@ -250,6 +268,15 @@ MT_thread_setsemawait(MT_Sema *sema)
                w->semawait = sema;
 }
 
+void
+MT_thread_setworking(const char *work)
+{
+       struct winthread *w = TlsGetValue(threadslot);
+
+       if (w)
+               w->working = work;
+}
+
 void *
 MT_thread_getdata(void)
 {
@@ -398,6 +425,7 @@ MT_exiting_thread(void)
 
        if (w) {
                ATOMIC_SET(&w->exited, 1);
+               w->working = NULL;
        }
 }
 
@@ -459,6 +487,7 @@ static struct posthread {
        MT_Lock *lockwait;      /* lock we're waiting for */
        MT_Sema *semawait;      /* semaphore we're waiting for */
        struct posthread *joinwait; /* process we are joining with */
+       const char *working;    /* what we're currently doing */
        char threadname[16];
        pthread_t tid;
        MT_Id mtid;
@@ -475,6 +504,23 @@ static MT_Id MT_thread_id = 1;
 
 static pthread_key_t threadkey;
 
+void
+dump_threads(void)
+{
+       pthread_mutex_lock(&posthread_lock);
+       for (struct posthread *p = posthreads; p; p = p->next) {
+               fprintf(stderr, "%s, waiting for %s, working on %.200s\n",
+                       p->threadname,
+                       p->lockwait ? p->lockwait->name :
+                       p->semawait ? p->semawait->name :
+                       p->joinwait ? p->joinwait->threadname :
+                       "nothing",
+                       ATOMIC_GET(&p->exited) ? "exiting" :
+                       p->working ? p->working : "nothing");
+       }
+       pthread_mutex_unlock(&posthread_lock);
+}
+
 bool
 MT_thread_init(void)
 {
@@ -551,6 +597,15 @@ MT_thread_setsemawait(MT_Sema *sema)
                p->semawait = sema;
 }
 
+void
+MT_thread_setworking(const char *work)
+{
+       struct posthread *p = pthread_getspecific(threadkey);
+
+       if (p)
+               p->working = work;
+}
+
 #ifdef HAVE_PTHREAD_SIGMASK
 static void
 MT_thread_sigmask(sigset_t *new_mask, sigset_t *orig_mask)
@@ -732,6 +787,7 @@ MT_exiting_thread(void)
        p = pthread_getspecific(threadkey);
        if (p) {
                ATOMIC_SET(&p->exited, 1);
+               p->working = NULL;
        }
 }
 
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -637,6 +637,7 @@ typedef struct {
 
 gdk_export void MT_thread_setlockwait(MT_Lock *lock);
 gdk_export void MT_thread_setsemawait(MT_Sema *sema);
+gdk_export void MT_thread_setworking(const char *work);
 
 gdk_export int MT_check_nr_cores(void);
 
diff --git a/gdk/gdk_system_private.h b/gdk/gdk_system_private.h
--- a/gdk/gdk_system_private.h
+++ b/gdk/gdk_system_private.h
@@ -12,6 +12,8 @@
 #error this file should not be included outside its source directory
 #endif
 
+__hidden void dump_threads(void)
+       __attribute__((__visibility__("hidden")));
 __hidden void join_detached_threads(void)
        __attribute__((__visibility__("hidden")));
 __hidden int MT_kill_thread(MT_Id t)
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -706,6 +706,7 @@ GDKprepareExit(void)
        if (ATOMIC_ADD(&GDKstopped, 1) > 0)
                return;
 
+       THRDDEBUG dump_threads();
        MT_lock_set(&GDKthreadLock);
        for (st = serverthread; st; st = serverthread) {
                MT_lock_unset(&GDKthreadLock);
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -274,6 +274,7 @@ MCinitClientRecord(Client c, oid user, b
        c->protocol = PROTOCOL_9;
 
        c->filetrans = false;
+       c->query = NULL;
 
        char name[16];
        snprintf(name, sizeof(name), "Client%d->s", (int) (c - mal_clients));
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
@@ -191,6 +191,7 @@ typedef struct CLIENT {
        size_t blocksize;
        protocol_version protocol;
        bool filetrans;                         /* whether the client can read 
files for us */
+       const char *query;                      /* string, identify whatever 
we're working on */
 } *Client, ClientRec;
 
 mal_export void    MCinit(void);
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
@@ -345,6 +345,7 @@ DFLOWworker(void *T)
        }
        while (1) {
                if (fnxt == 0) {
+                       MT_thread_setworking(NULL);
                        MT_lock_set(&dataflowLock);
                        cntxt = t->cntxt;
                        MT_lock_unset(&dataflowLock);
@@ -363,6 +364,7 @@ DFLOWworker(void *T)
                                /* no more work to be done: exit */
                                break;
                        }
+                       MT_thread_setworking(fe->flow->cntxt->query);
                } else
                        fe = fnxt;
                if (ATOMIC_GET(&exiting)) {
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
@@ -1047,6 +1047,7 @@ static void profilerHeartbeat(void *dumm
        (void) dummy;
        for (;;) {
                /* wait until you need this info */
+               MT_thread_setworking("sleeping");
                while (ATOMIC_GET(&hbdelay) == 0 || eventstream == NULL) {
                        if (GDKexiting() || !ATOMIC_GET(&hbrunning))
                                return;
@@ -1057,6 +1058,7 @@ static void profilerHeartbeat(void *dumm
                                return;
                        MT_sleep_ms(t > timeout ? timeout : t);
                }
+               MT_thread_setworking("pinging");
                profilerHeartbeatEvent("ping");
        }
 }
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
@@ -498,12 +498,24 @@ resetScenario(Client c)
  * between speed and ability to analysis its behavior.
  *
  */
+static const char *phases[] = {
+       [MAL_SCENARIO_CALLBACK] = "scenario callback",
+       [MAL_SCENARIO_ENGINE] = "scenario engine",
+       [MAL_SCENARIO_EXITCLIENT] = "scenario exitclient",
+       [MAL_SCENARIO_INITCLIENT] = "scenario initclient",
+       [MAL_SCENARIO_OPTIMIZE] = "scenario optimize",
+       [MAL_SCENARIO_PARSER] = "scenario parser",
+       [MAL_SCENARIO_READER] = "scenario reader",
+       [MAL_SCENARIO_SCHEDULER] = "scenario scheduler",
+};
 static str
 runPhase(Client c, int phase)
 {
        str msg = MAL_SUCCEED;
-       if (c->phase[phase])
+       if (c->phase[phase]) {
+               MT_thread_setworking(phases[phase]);
            return msg = (str) (*c->phase[phase])(c);
+       }
        return msg;
 }
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to