Changeset: c07cf8888bd3 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c07cf8888bd3 Modified Files: clients/mapilib/connect.c clients/mapilib/mapi.c clients/mapilib/mapi_intern.h clients/mapilib/msettings.h Branch: monetdburl Log Message:
Move more fields into msettings diffs (222 lines): diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c --- a/clients/mapilib/connect.c +++ b/clients/mapilib/connect.c @@ -606,10 +606,10 @@ mapi_handshake(Mapi mid) language, database); if (mid->handshake_options > MAPI_HANDSHAKE_AUTOCOMMIT) { - CHECK_SNPRINTF("auto_commit=%d", mid->auto_commit); + CHECK_SNPRINTF("auto_commit=%d", msetting_bool(mid->settings, MP_AUTOCOMMIT)); } if (mid->handshake_options > MAPI_HANDSHAKE_REPLY_SIZE) { - CHECK_SNPRINTF(",reply_size=%d", mid->cachelimit); + CHECK_SNPRINTF(",reply_size=%ld", msetting_long(mid->settings, MP_REPLYSIZE)); } if (mid->handshake_options > MAPI_HANDSHAKE_SIZE_HEADER) { CHECK_SNPRINTF(",size_header=%d", mid->sizeheader); // with underscore, despite X command without @@ -618,7 +618,7 @@ mapi_handshake(Mapi mid) CHECK_SNPRINTF(",columnar_protocol=%d", mid->columnar_protocol); } if (mid->handshake_options > MAPI_HANDSHAKE_TIME_ZONE) { - CHECK_SNPRINTF(",time_zone=%d", mid->time_zone); + CHECK_SNPRINTF(",time_zone=%ld", msetting_long(mid->settings, MP_TIMEZONE)); } if (mid->handshake_options > 0) { CHECK_SNPRINTF(":"); @@ -761,16 +761,18 @@ mapi_handshake(Mapi mid) /* use X commands to send options that couldn't be sent in the handshake */ /* tell server about auto_complete and cache limit if handshake options weren't used */ - if (mid->handshake_options <= MAPI_HANDSHAKE_AUTOCOMMIT && mid->auto_commit != MapiStructDefaults.auto_commit) { + bool autocommit = msetting_bool(mid->settings, MP_AUTOCOMMIT); + if (mid->handshake_options <= MAPI_HANDSHAKE_AUTOCOMMIT && autocommit != msetting_bool(msettings_default, MP_AUTOCOMMIT)) { char buf[2]; - sprintf(buf, "%d", !!mid->auto_commit); + sprintf(buf, "%d", !!autocommit); MapiMsg result = mapi_Xcommand(mid, "auto_commit", buf); if (result != MOK) return mid->error; } - if (mid->handshake_options <= MAPI_HANDSHAKE_REPLY_SIZE && mid->cachelimit != MapiStructDefaults.cachelimit) { + long replysize = msetting_long(mid->settings, MP_REPLYSIZE); + if (mid->handshake_options <= MAPI_HANDSHAKE_REPLY_SIZE && replysize != msetting_long(msettings_default, MP_REPLYSIZE)) { char buf[50]; - sprintf(buf, "%d", mid->cachelimit); + sprintf(buf, "%ld", replysize); MapiMsg result = mapi_Xcommand(mid, "reply_size", buf); if (result != MOK) return mid->error; @@ -786,7 +788,7 @@ mapi_handshake(Mapi mid) // The reason is that columnar_protocol is very new. If it isn't supported in the handshake it isn't supported at // all so sending the Xcommand would just give an error. if (mid->handshake_options <= MAPI_HANDSHAKE_TIME_ZONE) { - mapi_set_time_zone(mid, mid->time_zone); + mapi_set_time_zone(mid, msetting_long(mid->settings, MP_TIMEZONE)); } return mid->error; diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1170,7 +1170,7 @@ bool mapi_get_autocommit(Mapi mid) { mapi_check0(mid); - return mid->auto_commit; + return msetting_bool(mid->settings, MP_AUTOCOMMIT); } bool @@ -1184,7 +1184,7 @@ int mapi_get_time_zone(Mapi mid) { mapi_check0(mid); - return mid->time_zone; + return msetting_long(mid->settings, MP_TIMEZONE); } static int64_t @@ -1290,7 +1290,7 @@ new_result(MapiHdl hdl) .tableid = -1, .querytype = -1, .last_id = -1, - .cache.rowlimit = hdl->mid->cachelimit, + .cache.rowlimit = msetting_long(hdl->mid->settings, MP_REPLYSIZE), .cache.reader = -1, .commentonly = true, }; @@ -1663,9 +1663,7 @@ mapi_close_handle(MapiHdl hdl) } const struct MapiStruct MapiStructDefaults = { - .auto_commit = true, .error = MOK, - .cachelimit = 100, .redirmax = 10, .blk.eos = false, .blk.lim = BLOCK, @@ -1698,6 +1696,7 @@ mapi_new(void) mid->blk.buf[mid->blk.lim] = 0; /* also the current timezone, seconds EAST of UTC */ + long time_zone; #if defined(_MSC_VER) DYNAMIC_TIME_ZONE_INFORMATION tzinf; @@ -1708,30 +1707,33 @@ mapi_new(void) switch (GetDynamicTimeZoneInformation(&tzinf)) { case TIME_ZONE_ID_STANDARD: /* using standard time */ case TIME_ZONE_ID_UNKNOWN: /* no daylight saving time in this zone */ - mid->time_zone = -(int) tzinf.Bias * 60; + time_zone = -(int) tzinf.Bias * 60; break; case TIME_ZONE_ID_DAYLIGHT: /* using daylight saving time */ - mid->time_zone = -(int) (tzinf.Bias + tzinf.DaylightBias) * 60; + time_zone = -(int) (tzinf.Bias + tzinf.DaylightBias) * 60; break; default: /* aka TIME_ZONE_ID_INVALID */ /* call failed, we don't know the time zone */ - mid->time_zone = 0; + time_zone = 0; break; } #else time_t t = time(NULL); struct tm *local_tm = localtime_r(&t, &(struct tm){0}); #ifdef HAVE_TM_GMTOFF - mid->time_zone = (int) local_tm->tm_gmtoff; + time_zone = local_tm->tm_gmtoff; #else struct tm *gm_tm = gmtime_r(&t, &(struct tm){0}); time_t gt = mktime(gm_tm); 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); + time_zone = (long) (lt - gt); #endif #endif + msettings_error err = msetting_set_long(mid->settings, MP_TIMEZONE, time_zone); + if (err) + mapi_setError(mid, err, __func__, MERROR); return mid; } @@ -2634,13 +2636,15 @@ read_line(Mapi mid) MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit) { - if (mid->auto_commit == autocommit) + if (msetting_bool(mid->settings, MP_AUTOCOMMIT) == autocommit) return MOK; if (!msettings_lang_is_sql(mid->settings)) { mapi_setError(mid, "autocommit only supported in SQL", __func__, MERROR); return MERROR; } - mid->auto_commit = autocommit; + msettings_error err = msetting_set_bool(mid->settings, MP_AUTOCOMMIT, autocommit); + if (err) + return mapi_setError(mid, err, __func__, MERROR); if (!mid->connected) return MOK; if (autocommit) @@ -2652,7 +2656,9 @@ mapi_setAutocommit(Mapi mid, bool autoco MapiMsg mapi_set_time_zone(Mapi mid, int time_zone) { - mid->time_zone = time_zone; + msettings_error err = msetting_set_long(mid->settings, MP_TIMEZONE, time_zone); + if (err) + return mapi_setError(mid, err, __func__, MERROR); if (!mid->connected) return MOK; @@ -2946,7 +2952,7 @@ parse_header_line(MapiHdl hdl, char *lin result->sqloptimizertime = strtoll(nline, &nline, 10); break; case Q_TRANS: - hdl->mid->auto_commit = *nline != 'f'; + msetting_set_bool(hdl->mid->settings, MP_AUTOCOMMIT, *nline != 'f'); break; case Q_UPDATE: result->row_count = strtoll(nline, &nline, 10); @@ -3590,7 +3596,9 @@ MapiMsg mapi_cache_limit(Mapi mid, int limit) { /* clean out superflous space TODO */ - mid->cachelimit = limit; + msettings_error err = msetting_set_long(mid->settings, MP_REPLYSIZE, limit); + if (err) + return mapi_setError(mid, err, __func__, MERROR); if (!mid->connected) return MOK; mapi_check(mid); diff --git a/clients/mapilib/mapi_intern.h b/clients/mapilib/mapi_intern.h --- a/clients/mapilib/mapi_intern.h +++ b/clients/mapilib/mapi_intern.h @@ -235,14 +235,11 @@ struct MapiStruct { 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 */ - int cachelimit; /* default maximum number of rows to cache */ int redircnt; /* redirection count, used to cut of redirect loops */ int redirmax; /* maximum redirects before giving up */ #define MAXREDIR 50 diff --git a/clients/mapilib/msettings.h b/clients/mapilib/msettings.h --- a/clients/mapilib/msettings.h +++ b/clients/mapilib/msettings.h @@ -65,6 +65,7 @@ typedef const char *msettings_error; /* returns NULL if could not allocate */ msettings *msettings_create(void); msettings *msettings_clone(const msettings *mp); +extern const msettings *msettings_default; /* always returns NULL */ msettings *msettings_destroy(msettings *mp); _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org