Changeset: a01f6a1fe8d7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a01f6a1fe8d7 Modified Files: monetdb5/modules/atoms/mtime.c sql/backends/monet5/sql_user.c 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/subquery/Tests/subquery6.sql Branch: default Log Message:
Merge with Jun2020 branch. diffs (truncated from 332 to 300 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 @@ -768,28 +768,6 @@ MTIMElocal_timezone_msec(lng *ret) return MAL_SUCCEED; } -str -MTIMEstr_to_date(date *ret, const char *const *s, const char *const *format) -{ - struct tm tm = (struct tm) {0}; - time_t t; - - if (strNil(*s) || strNil(*format)) { - *ret = date_nil; - return MAL_SUCCEED; - } - t = time(NULL); - localtime_r(&t, &tm); - tm.tm_sec = tm.tm_min = tm.tm_hour = 0; - if (strptime(*s, *format, &tm) == NULL) - throw(MAL, "mtime.str_to_date", "format '%s', doesn't match date '%s'", - *format, *s); - *ret = date_create(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); - if (is_date_nil(*ret)) - throw(MAL, "mtime.str_to_date", "bad date '%s'", *s); - return MAL_SUCCEED; -} - static str timestamp_to_str(str *ret, const timestamp *d, const char *const *format, const char *type, const char *malfunc) @@ -825,44 +803,8 @@ timestamp_to_str(str *ret, const timesta return MAL_SUCCEED; } -str -MTIMEdate_to_str(str *ret, const date *d, const char *const *format) -{ - timestamp ts = timestamp_create(*d, timestamp_daytime(timestamp_current())); - return timestamp_to_str(ret, &ts, format, "date", "mtime.date_to_str"); -} - -str -MTIMEstr_to_time(daytime *ret, const char *const *s, const char *const *format) -{ - struct tm tm = (struct tm) {0}; - time_t t; - - if (strNil(*s) || strNil(*format)) { - *ret = daytime_nil; - return MAL_SUCCEED; - } - t = time(NULL); - localtime_r(&t, &tm); - tm.tm_sec = tm.tm_min = tm.tm_hour = 0; - if (strptime(*s, *format, &tm) == NULL) - throw(MAL, "mtime.str_to_time", "format '%s', doesn't match time '%s'", - *format, *s); - *ret = daytime_create(tm.tm_hour, tm.tm_min, tm.tm_sec == 60 ? 59 : tm.tm_sec, 0); - if (is_daytime_nil(*ret)) - throw(MAL, "mtime.str_to_time", "bad time '%s'", *s); - return MAL_SUCCEED; -} - -str -MTIMEtime_to_str(str *ret, const daytime *d, const char *const *format) -{ - timestamp ts = timestamp_create(timestamp_date(timestamp_current()), *d); - return timestamp_to_str(ret, &ts, format, "time", "mtime.time_to_str"); -} - -str -MTIMEstr_to_timestamp(timestamp *ret, const char *const *s, const char *const *format) +static str +str_to_timestamp(timestamp *ret, const char *const *s, const char *const *format, const char *type, const char *malfunc) { struct tm tm = (struct tm) {0}; time_t t; @@ -876,8 +818,8 @@ MTIMEstr_to_timestamp(timestamp *ret, co tm.tm_sec = tm.tm_min = tm.tm_hour = 0; tm.tm_isdst = -1; if (strptime(*s, *format, &tm) == NULL) - throw(MAL, "mtime.str_to_timestamp", - "format '%s', doesn't match timestamp '%s'", *format, *s); + throw(MAL, malfunc, + "format '%s', doesn't match %s '%s'", *format, type, *s); *ret = timestamp_create(date_create(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday), @@ -904,11 +846,53 @@ MTIMEstr_to_timestamp(timestamp *ret, co *ret = timestamp_add_usec(*ret, -tz * LL_CONSTANT(1000000)); } if (is_timestamp_nil(*ret)) - throw(MAL, "mtime.str_to_timestamp", "bad timestamp '%s'", *s); + throw(MAL, malfunc, "bad %s '%s'", type, *s); + return MAL_SUCCEED; +} + +str +MTIMEstr_to_date(date *ret, const char *const *s, const char *const *format) +{ + timestamp ts; + str msg = str_to_timestamp(&ts, s, format, "date", "mtime.str_to_date"); + if (msg != MAL_SUCCEED) + return msg; + *ret = timestamp_date(ts); return MAL_SUCCEED; } str +MTIMEdate_to_str(str *ret, const date *d, const char *const *format) +{ + timestamp ts = timestamp_create(*d, timestamp_daytime(timestamp_current())); + return timestamp_to_str(ret, &ts, format, "date", "mtime.date_to_str"); +} + +str +MTIMEstr_to_time(daytime *ret, const char *const *s, const char *const *format) +{ + timestamp ts; + str msg = str_to_timestamp(&ts, s, format, "time", "mtime.str_to_time"); + if (msg != MAL_SUCCEED) + return msg; + *ret = timestamp_daytime(ts); + return MAL_SUCCEED; +} + +str +MTIMEtime_to_str(str *ret, const daytime *d, const char *const *format) +{ + timestamp ts = timestamp_create(timestamp_date(timestamp_current()), *d); + return timestamp_to_str(ret, &ts, format, "time", "mtime.time_to_str"); +} + +str +MTIMEstr_to_timestamp(timestamp *ret, const char *const *s, const char *const *format) +{ + return str_to_timestamp(ret, s, format, "timestamp", "mtime.str_to_timestamp"); +} + +str MTIMEtimestamp_to_str(str *ret, const timestamp *d, const char *const *format) { return timestamp_to_str(ret, d, format, diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c --- a/sql/backends/monet5/sql_user.c +++ b/sql/backends/monet5/sql_user.c @@ -522,8 +522,12 @@ monet5_user_set_def_schema(mvc *m, oid u users_schema = find_sql_column(user_info, "default_schema"); rid = table_funcs.column_find_row(m->session->tr, users_name, username, NULL); - if (is_oid_nil(rid)) + if (is_oid_nil(rid)) { + if (m->session->tr->active && (other = mvc_rollback(m, 0, NULL, false)) != MAL_SUCCEED) + freeException(other); + GDKfree(username); return NULL; + } p = table_funcs.column_find_value(m->session->tr, users_schema, rid); assert(p); diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 @@ -6440,8 +6440,8 @@ set schema "sys"; # 15:17:55 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128 b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128 --- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128 +++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128 @@ -6440,8 +6440,8 @@ set schema "sys"; # 15:17:55 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out @@ -5626,8 +5626,8 @@ set schema "sys"; # 15:55:37 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit @@ -5626,8 +5626,8 @@ set schema "sys"; # 16:02:52 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 @@ -6486,8 +6486,8 @@ set schema "sys"; # 16:53:35 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64 b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64 --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64 +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64 @@ -5626,8 +5626,8 @@ set schema "sys"; # 15:55:37 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 @@ -6486,8 +6486,8 @@ set schema "sys"; # 15:43:25 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 @@ -6440,8 +6440,8 @@ set schema "sys"; # 15:17:04 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade/Tests/upgrade.stable.out b/sql/test/emptydb-upgrade/Tests/upgrade.stable.out --- a/sql/test/emptydb-upgrade/Tests/upgrade.stable.out +++ b/sql/test/emptydb-upgrade/Tests/upgrade.stable.out @@ -5626,8 +5626,8 @@ set schema "sys"; # 21:10:45 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type % 1 # length [ 1 ] diff --git a/sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit b/sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit --- a/sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit +++ b/sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit @@ -5626,8 +5626,8 @@ set schema "sys"; # 16:02:52 > #select 1; -% . # table_name -% single_value # name +% .%2 # table_name +% %2 # name % tinyint # type _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list