Changeset: 2a66c068d118 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2a66c068d118
Added Files:
        sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.sql
        sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.stable.err
        sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.stable.out
Modified Files:
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/mal/mal_mapi.c
        sql/test/BugTracker-2018/Tests/All
Branch: default
Log Message:

Merge with Aug2018 branch.


diffs (257 lines):

diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -3614,7 +3614,7 @@ str
 MTIMEdate_to_str(str *s, const date *d, const char * const *format)
 {
        struct tm t;
-       char buf[BUFSIZ + 1];
+       char buf[512];
        size_t sz;
        int mon, year;
 
@@ -3628,8 +3628,9 @@ MTIMEdate_to_str(str *s, const date *d, 
        fromdate(*d, &t.tm_mday, &mon, &year);
        t.tm_mon = mon - 1;
        t.tm_year = year - 1900;
+       t.tm_isdst = -1;
        (void)mktime(&t); /* corrects the tm_wday etc */
-       if ((sz = strftime(buf, BUFSIZ, *format, &t)) == 0)
+       if ((sz = strftime(buf, sizeof(buf), *format, &t)) == 0)
                throw(MAL, "mtime.date_to_str", "failed to convert date to 
string using format '%s'\n", *format);
        *s = GDKmalloc(sz + 1);
        if (*s == NULL)
@@ -3658,7 +3659,7 @@ str
 MTIMEtime_to_str(str *s, const daytime *d, const char * const *format)
 {
        struct tm t;
-       char buf[BUFSIZ + 1];
+       char buf[512];
        size_t sz;
        int msec;
 
@@ -3671,8 +3672,9 @@ MTIMEtime_to_str(str *s, const daytime *
        memset(&t, 0, sizeof(struct tm));
        fromtime(*d, &t.tm_hour, &t.tm_min, &t.tm_sec, &msec);
        (void)msec;
+       t.tm_isdst = -1;
        (void)mktime(&t); /* corrects the tm_wday etc */
-       if ((sz = strftime(buf, BUFSIZ, *format, &t)) == 0)
+       if ((sz = strftime(buf, sizeof(buf), *format, &t)) == 0)
                throw(MAL, "mtime.time_to_str", "failed to convert time to 
string using format '%s'\n", *format);
        *s = GDKmalloc(sz + 1);
        if (*s == NULL)
@@ -3702,7 +3704,7 @@ str
 MTIMEtimestamp_to_str(str *s, const timestamp *ts, const char * const *format)
 {
        struct tm t;
-       char buf[BUFSIZ + 1];
+       char buf[512];
        size_t sz;
        int mon, year, msec;
 
@@ -3717,9 +3719,10 @@ MTIMEtimestamp_to_str(str *s, const time
        t.tm_mon = mon - 1;
        t.tm_year = year - 1900;
        fromtime(ts->msecs, &t.tm_hour, &t.tm_min, &t.tm_sec, &msec);
+       t.tm_isdst = -1;
        (void)mktime(&t); /* corrects the tm_wday etc */
        (void)msec;
-       if ((sz = strftime(buf, BUFSIZ, *format, &t)) == 0)
+       if ((sz = strftime(buf, sizeof(buf), *format, &t)) == 0)
                throw(MAL, "mtime.timestamp_to_str", "failed to convert 
timestampt to string using format '%s'\n", *format);
        *s = GDKmalloc(sz + 1);
        if (*s == NULL)
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -290,6 +290,7 @@ SERVERlistenThread(SOCKET *Sock)
        SOCKET msgsock = INVALID_SOCKET;
        struct challengedata *data;
        MT_Id tid;
+       stream *s;
 
        if (*Sock) {
                sock = Sock[0];
@@ -458,6 +459,7 @@ SERVERlistenThread(SOCKET *Sock)
                data->in = socket_rastream(msgsock, "Server read");
                data->out = socket_wastream(msgsock, "Server write");
                if (data->in == NULL || data->out == NULL) {
+                 stream_alloc_fail:
                        mnstr_destroy(data->in);
                        mnstr_destroy(data->out);
                        GDKfree(data);
@@ -466,17 +468,16 @@ SERVERlistenThread(SOCKET *Sock)
                                                  "cannot allocate stream");
                        continue;
                }
-               data->in = block_stream(data->in);
-               data->out = block_stream(data->out);
-               if (data->in == NULL || data->out == NULL) {
-                       mnstr_destroy(data->in);
-                       mnstr_destroy(data->out);
-                       GDKfree(data);
-                       closesocket(msgsock);
-                       showException(GDKstdout, MAL, "initClient",
-                                                 "cannot allocate stream");
-                       continue;
+               s = block_stream(data->in);
+               if (s == NULL) {
+                       goto stream_alloc_fail;
                }
+               data->in = s;
+               s = block_stream(data->out);
+               if (s == NULL) {
+                       goto stream_alloc_fail;
+               }
+               data->out = s;
                if (MT_create_thread(&tid, doChallenge, data, MT_THR_DETACHED)) 
{
                        mnstr_destroy(data->in);
                        mnstr_destroy(data->out);
diff --git a/sql/test/BugTracker-2018/Tests/All 
b/sql/test/BugTracker-2018/Tests/All
--- a/sql/test/BugTracker-2018/Tests/All
+++ b/sql/test/BugTracker-2018/Tests/All
@@ -82,3 +82,4 @@ multi-column-hash-wrongly-NIL.Bug-6638
 comment-on-table-is-null.Bug-6639
 crash-after-call-non-existing-loader
 timestamp-as-boolean.Bug-6642
+timestamp-roundtrip.Bug-6640
diff --git a/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.sql 
b/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.sql
@@ -0,0 +1,2 @@
+select timestamp_to_str('2008-03-31 00:00:00', '%Y-%m-%d %H:%M:%S');
+select timestamp_to_str('2008-01-31 00:00:00', '%Y-%m-%d %H:%M:%S');
diff --git 
a/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.stable.err 
b/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.stable.err
@@ -0,0 +1,37 @@
+stderr of test 'timestamp-roundtrip.Bug-6640` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 13:59:02 >  
+# 13:59:02 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=37269" "--set" 
"mapi_usock=/var/tmp/mtest-9555/.s.monetdb.37269" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/ufs/sjoerd/@Monet-stable/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_r=yes" "--set" "embedded_py=true" "--set" "embedded_c=true"
+# 13:59:02 >  
+
+# builtin opt  gdk_dbpath = /ufs/sjoerd/@Monet-stable/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 37269
+# cmdline opt  mapi_usock = /var/tmp/mtest-9555/.s.monetdb.37269
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/ufs/sjoerd/@Monet-stable/var/MonetDB/mTests_sql_test_BugTracker-2018
+# cmdline opt  embedded_r = yes
+# cmdline opt  embedded_py = true
+# cmdline opt  embedded_c = true
+# cmdline opt  gdk_debug = 553648138
+
+# 13:59:03 >  
+# 13:59:03 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-9555" "--port=37269"
+# 13:59:03 >  
+
+
+# 13:59:03 >  
+# 13:59:03 >  "Done."
+# 13:59:03 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.stable.out 
b/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2018/Tests/timestamp-roundtrip.Bug-6640.stable.out
@@ -0,0 +1,85 @@
+stdout of test 'timestamp-roundtrip.Bug-6640` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 13:59:02 >  
+# 13:59:02 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=37269" "--set" 
"mapi_usock=/var/tmp/mtest-9555/.s.monetdb.37269" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/ufs/sjoerd/@Monet-stable/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_r=yes" "--set" "embedded_py=true" "--set" "embedded_c=true"
+# 13:59:02 >  
+
+# MonetDB 5 server v11.31.8 (hg id: 15c31e010a8d+)
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2018', using 8 threads
+# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers
+# Found 62.694 GiB available main-memory.
+# Copyright (c) 1993 - July 2008 CWI.
+# Copyright (c) August 2008 - 2018 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on 
mapi:monetdb://methuselah.da.cwi.nl:37269/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-9555/.s.monetdb.37269
+# MonetDB/GIS module loaded
+# SQL catalog created, loading sql scripts once
+# loading sql script: 09_like.sql
+# loading sql script: 10_math.sql
+# loading sql script: 11_times.sql
+# loading sql script: 12_url.sql
+# loading sql script: 13_date.sql
+# loading sql script: 14_inet.sql
+# loading sql script: 15_querylog.sql
+# loading sql script: 16_tracelog.sql
+# loading sql script: 17_temporal.sql
+# loading sql script: 18_index.sql
+# loading sql script: 20_vacuum.sql
+# loading sql script: 21_dependency_views.sql
+# loading sql script: 22_clients.sql
+# loading sql script: 23_skyserver.sql
+# loading sql script: 25_debug.sql
+# loading sql script: 26_sysmon.sql
+# loading sql script: 27_rejects.sql
+# loading sql script: 39_analytics.sql
+# loading sql script: 39_analytics_hge.sql
+# loading sql script: 40_geom.sql
+# loading sql script: 40_json.sql
+# loading sql script: 40_json_hge.sql
+# loading sql script: 41_md5sum.sql
+# loading sql script: 45_uuid.sql
+# loading sql script: 46_profiler.sql
+# loading sql script: 51_sys_schema_extension.sql
+# loading sql script: 60_wlcr.sql
+# loading sql script: 72_fits.sql
+# loading sql script: 74_netcdf.sql
+# loading sql script: 75_lidar.sql
+# loading sql script: 75_shp.sql
+# loading sql script: 75_storagemodel.sql
+# loading sql script: 80_statistics.sql
+# loading sql script: 80_udf.sql
+# loading sql script: 80_udf_hge.sql
+# loading sql script: 85_bam.sql
+# loading sql script: 90_generator.sql
+# loading sql script: 90_generator_hge.sql
+# loading sql script: 99_system.sql
+# MonetDB/SQL module loaded
+# MonetDB/Python2 module loaded
+# MonetDB/R   module loaded
+
+Ready.
+
+# 13:59:03 >  
+# 13:59:03 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-9555" "--port=37269"
+# 13:59:03 >  
+
+#select timestamp_to_str('2008-03-31 00:00:00', '%Y-%m-%d %H:%M:%S');
+% .L2 # table_name
+% L2 # name
+% clob # type
+% 19 # length
+[ "2008-03-31 00:00:00"        ]
+#select timestamp_to_str('2008-01-31 00:00:00', '%Y-%m-%d %H:%M:%S');
+% .L2 # table_name
+% L2 # name
+% clob # type
+% 19 # length
+[ "2008-01-31 00:00:00"        ]
+
+# 13:59:03 >  
+# 13:59:03 >  "Done."
+# 13:59:03 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to