Changeset: c35b6882aed4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c35b6882aed4
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk_logger.c
        sql/backends/monet5/sql_scenario.c
        sql/server/rel_optimizer.c
        sql/storage/bat/bat_logger.c
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.int128
Branch: unlock
Log Message:

merged default


diffs (truncated from 1649 to 300 lines):

diff --git a/NT/mkodbcwxs.py b/NT/mkodbcwxs.py
--- a/NT/mkodbcwxs.py
+++ b/NT/mkodbcwxs.py
@@ -84,6 +84,8 @@ def main():
                vcpkg.format(r'bin\bz2.dll'),
                vcpkg.format(r'bin\charset-1.dll'), # for iconv-2.dll
                vcpkg.format(r'bin\libcrypto-1_1{}.dll'.format(libcrypto)),
+               vcpkg.format(r'bin\lz4.dll'),
+               vcpkg.format(r'bin\lzma.dll'),
                vcpkg.format(r'bin\zlib1.dll')])
     print(r'            </Directory>')
     id = comp(features, id, 12,
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
@@ -626,6 +626,7 @@ int mapi_get_scale(MapiHdl hdl, int fnr)
 int64_t mapi_get_sqloptimizertime(MapiHdl hdl) __attribute__((__nonnull__(1)));
 char *mapi_get_table(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
 int mapi_get_tableid(MapiHdl hdl) __attribute__((__nonnull__(1)));
+int mapi_get_time_zone(Mapi mid) __attribute__((__nonnull__(1)));
 stream *mapi_get_to(Mapi mid) __attribute__((__nonnull__(1)));
 bool mapi_get_trace(Mapi mid) __attribute__((__nonnull__(1)));
 char *mapi_get_type(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
@@ -665,6 +666,7 @@ MapiHdl mapi_send(Mapi mid, const char *
 MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit) 
__attribute__((__nonnull__(1)));
 MapiMsg mapi_set_columnar_protocol(Mapi mid, bool columnar_protocol) 
__attribute__((__nonnull__(1)));
 MapiMsg mapi_set_size_header(Mapi mid, bool value) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_set_time_zone(Mapi mid, int seconds_east_of_utc) 
__attribute__((__nonnull__(1)));
 MapiMsg mapi_set_timeout(Mapi mid, unsigned int timeout, bool (*callback)(void 
*), void *callback_data) __attribute__((__nonnull__(1)));
 void mapi_setfilecallback(Mapi mid, char *(*getfunc)(void *priv, const char 
*filename, bool binary, uint64_t offset, size_t *size), char *(*putfunc)(void 
*priv, const char *filename, const void *data, size_t size), void *priv) 
__attribute__((__nonnull__(1)));
 int mapi_split_line(MapiHdl hdl) __attribute__((__nonnull__(1)));
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2893,75 +2893,6 @@ doFile(Mapi mid, stream *fp, bool useins
        return errseen;
 }
 
-static void
-set_timezone(Mapi mid)
-{
-       char buf[128];
-       int tzone;
-       MapiHdl hdl;
-
-       /* figure out our current timezone */
-#if defined HAVE_GETDYNAMICTIMEZONEINFORMATION
-       DYNAMIC_TIME_ZONE_INFORMATION tzinf;
-
-       /* documentation says: UTC = localtime + Bias (in minutes),
-        * but experimentation during DST period says, UTC = localtime
-        * + Bias + DaylightBias, and presumably during non DST
-        * period, UTC = localtime + Bias */
-       switch (GetDynamicTimeZoneInformation(&tzinf)) {
-       case TIME_ZONE_ID_STANDARD:
-       case TIME_ZONE_ID_UNKNOWN:
-               tzone = (int) tzinf.Bias * 60;
-               break;
-       case TIME_ZONE_ID_DAYLIGHT:
-               tzone = (int) (tzinf.Bias + tzinf.DaylightBias) * 60;
-               break;
-       default:
-               /* call failed, we don't know the time zone */
-               tzone = 0;
-               break;
-       }
-#elif defined HAVE_STRUCT_TM_TM_ZONE
-       time_t t;
-       struct tm *tmp;
-
-       t = time(NULL);
-       tmp = localtime(&t);
-       tzone = (int) -tmp->tm_gmtoff;
-#else
-       time_t t, lt, gt;
-       struct tm *tmp;
-
-       t = time(NULL);
-       tmp = gmtime(&t);
-       gt = mktime(tmp);
-       tmp = localtime(&t);
-       tmp->tm_isdst=0; /* We need the difference without dst */
-       lt = mktime(tmp);
-       assert((int64_t) gt - (int64_t) lt >= (int64_t) INT_MIN && (int64_t) gt 
- (int64_t) lt <= (int64_t) INT_MAX);
-       tzone = (int) (gt - lt);
-#endif
-       if (tzone < 0)
-               snprintf(buf, sizeof(buf),
-                        "SET TIME ZONE INTERVAL '+%02d:%02d' HOUR TO MINUTE",
-                        -tzone / 3600, (-tzone % 3600) / 60);
-       else
-               snprintf(buf, sizeof(buf),
-                        "SET TIME ZONE INTERVAL '-%02d:%02d' HOUR TO MINUTE",
-                        tzone / 3600, (tzone % 3600) / 60);
-       if ((hdl = mapi_query(mid, buf)) == NULL) {
-               if (formatter == TABLEformatter) {
-                       mapi_noexplain(mid, "");
-               } else {
-                       mapi_noexplain(mid, NULL);
-               }
-               mapi_explain(mid, stderr);
-               errseen = true;
-               return;
-       }
-       mapi_close_handle(hdl);
-}
-
 struct privdata {
        stream *f;
        char *buf;
@@ -3538,6 +3469,12 @@ main(int argc, char **argv)
        if (dbname)
                free(dbname);
        dbname = NULL;
+
+       mapi_cache_limit(mid, -1);
+       mapi_setAutocommit(mid, autocommit);
+       if (mode == SQL && !settz)
+               mapi_set_time_zone(mid, 0);
+
        if (mid && mapi_error(mid) == MOK)
                mapi_reconnect(mid);    /* actually, initial connect */
 
@@ -3553,7 +3490,6 @@ main(int argc, char **argv)
                        mnstr_printf(stderr_stream, "%s\n", 
mapi_error_str(mid));
                exit(2);
        }
-       mapi_cache_limit(mid, -1);
        if (dump) {
                if (mode == SQL) {
                        exit(dump_database(mid, toConsole, 0, useinserts, 
false));
@@ -3567,9 +3503,6 @@ main(int argc, char **argv)
        priv = (struct privdata) {0};
        mapi_setfilecallback(mid, getfile, putfile, &priv);
 
-       if (!autocommit)
-               mapi_setAutocommit(mid, autocommit);
-
        if (logfile)
                mapi_log(mid, logfile);
 
@@ -3616,9 +3549,6 @@ main(int argc, char **argv)
                                     mapi_get_autocommit(mid) ? "on" : "off");
        }
 
-       if (mode == SQL && settz)
-               set_timezone(mid);
-
        if (command != NULL) {
 #if !defined(_MSC_VER) && defined(HAVE_ICONV)
                /* no need on Windows: using wmain interface */
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -198,7 +198,7 @@ main(int argc, char **argv)
        if (passwd == NULL)
                passwd = simple_prompt("password", BUFSIZ, 0, NULL);
 
-       mid = mapi_connect(host, port, user, passwd, "sql", dbname);
+       mid = mapi_mapi(host, port, user, passwd, "sql", dbname);
        if (user)
                free(user);
        if (passwd)
@@ -209,6 +209,8 @@ main(int argc, char **argv)
                fprintf(stderr, "failed to allocate Mapi structure\n");
                exit(2);
        }
+       mapi_set_time_zone(mid, 0);
+       mapi_reconnect(mid);
        if (mapi_error(mid)) {
                mapi_explain(mid, stderr);
                exit(2);
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -726,6 +726,37 @@
 # include <sys/time.h>         /* gettimeofday */
 #endif
 
+/* Copied from gdk_posix, but without taking a lock because we don't have 
access to
+ * MT_lock_set/unset here. We just have to hope for the best
+ */
+#ifndef HAVE_LOCALTIME_R
+struct tm *
+localtime_r(const time_t *restrict timep, struct tm *restrict result)
+{
+       struct tm *tmp;
+       tmp = localtime(timep);
+       if (tmp)
+               *result = *tmp;
+       return tmp ? result : NULL;
+}
+#endif
+
+/* Copied from gdk_posix, but without taking a lock because we don't have 
access to
+ * MT_lock_set/unset here. We just have to hope for the best
+ */
+#ifndef HAVE_GMTIME_R
+struct tm *
+gmtime_r(const time_t *restrict timep, struct tm *restrict result)
+{
+       struct tm *tmp;
+       tmp = gmtime(timep);
+       if (tmp)
+               *result = *tmp;
+       return tmp ? result : NULL;
+}
+#endif
+
+
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
@@ -879,8 +910,11 @@ struct MapiStruct {
        struct BlockCache blk;
        bool connected;
        bool trace;             /* Trace Mapi interaction */
+       int handshake_options;  /* which settings can be sent during 
challenge/response? */
        bool auto_commit;
        bool columnar_protocol;
+       bool sizeheader;
+       int time_zone;          /* seconds EAST of UTC */
        MapiHdl first;          /* start of doubly-linked list */
        MapiHdl active;         /* set when not all rows have been received */
 
@@ -995,6 +1029,7 @@ static int mapi_extend_bindings(MapiHdl 
 static int mapi_extend_params(MapiHdl hdl, int minparams);
 static void close_connection(Mapi mid);
 static MapiMsg read_into_cache(MapiHdl hdl, int lookahead);
+static MapiMsg mapi_Xcommand(Mapi mid, const char *cmdname, const char 
*cmdvalue);
 static int unquote(const char *msg, char **start, const char **next, int 
endchar, size_t *lenp);
 static int mapi_slice_row(struct MapiResultSet *result, int cr);
 static void mapi_store_bind(struct MapiResultSet *result, int cr);
@@ -1379,6 +1414,13 @@ mapi_get_columnar_protocol(Mapi mid)
        return mid->columnar_protocol;
 }
 
+int
+mapi_get_time_zone(Mapi mid)
+{
+       mapi_check0(mid);
+       return mid->time_zone;
+}
+
 static int64_t
 usec(void)
 {
@@ -1863,6 +1905,17 @@ mapi_close_handle(MapiHdl hdl)
        return MOK;
 }
 
+static const struct MapiStruct MapiStructDefaults = {
+       .auto_commit = true,
+       .error = MOK,
+       .languageId = LANG_SQL,
+       .mapiversion = "mapi 1.0",
+       .cachelimit = 100,
+       .redirmax = 10,
+       .blk.eos = false,
+       .blk.lim = BLOCK,
+};
+
 /* Allocate a new connection handle. */
 static Mapi
 mapi_new(void)
@@ -1875,17 +1928,8 @@ mapi_new(void)
                return NULL;
 
        /* then fill in some details */
-       *mid = (struct MapiStruct) {
-               .index = (uint32_t) ATOMIC_ADD(&index, 1),      /* for 
distinctions in log records */
-               .auto_commit = true,
-               .error = MOK,
-               .languageId = LANG_SQL,
-               .mapiversion = "mapi 1.0",
-               .cachelimit = 100,
-               .redirmax = 10,
-               .blk.eos = false,
-               .blk.lim = BLOCK,
-       };
+       *mid = MapiStructDefaults;
+       mid->index =  (uint32_t) ATOMIC_ADD(&index, 1); /* for distinctions in 
log records */
        if ((mid->blk.buf = malloc(mid->blk.lim + 1)) == NULL) {
                mapi_destroy(mid);
                return NULL;
@@ -1893,6 +1937,16 @@ mapi_new(void)
        mid->blk.buf[0] = 0;
        mid->blk.buf[mid->blk.lim] = 0;
 
+       /* also the current timezone, seconds EAST of UTC */
+       time_t t = time(NULL);
+       struct tm *gm_tm = gmtime_r(&t, &(struct tm){0});
+       time_t gt = mktime(gm_tm);
+       struct tm *local_tm = localtime_r(&t, &(struct tm){0});
+       local_tm->tm_isdst=0; /* We need the difference without dst */
+       time_t lt = mktime(local_tm);
+       assert((int64_t) gt - (int64_t) lt >= (int64_t) INT_MIN && (int64_t) gt 
- (int64_t) lt <= (int64_t) INT_MAX);
+       mid->time_zone = (int) (lt - gt);
+
        return mid;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to