diff options
author | Sergei Golubchik <serg@mariadb.org> | 2020-01-21 15:17:43 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-01-21 21:15:10 +0100 |
commit | 8eec2d61fcb1d4ce4fcd56989c6fe13cd012ecad (patch) | |
tree | 40ff28a21b62c5f7e2acadb971e2788f9b5a7b79 | |
parent | 4e7f3fb8332c42c3beb2376ee0d90f559f1e7470 (diff) | |
download | mariadb-git-8eec2d61fcb1d4ce4fcd56989c6fe13cd012ecad.tar.gz |
MDEV-21249 MariaDB 10.3.10 When referring to bigint to generate timestamp data in the virtual generated column, the value of the generated column does not change when the time zone changes
FROM_UNIXTIME() depends on @@time_zone, so it's VCOL_SESSION_FUNC
-rw-r--r-- | mysql-test/r/default_session.result | 28 | ||||
-rw-r--r-- | mysql-test/t/default_session.test | 24 | ||||
-rw-r--r-- | sql/item_timefunc.h | 4 |
3 files changed, 56 insertions, 0 deletions
diff --git a/mysql-test/r/default_session.result b/mysql-test/r/default_session.result index 6c0bcad0cb3..1b0c5f3f67a 100644 --- a/mysql-test/r/default_session.result +++ b/mysql-test/r/default_session.result @@ -92,3 +92,31 @@ a STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI drop table t1; +set time_zone='+00:00'; +create table t1 (a int, b datetime default from_unixtime(a), c datetime); +insert t1 (a, c) values (1569495327, from_unixtime(1569495327)); +set time_zone='+01:00'; +insert t1 (a, c) values (1569495327, from_unixtime(1569495327)); +flush tables; +insert t1 (a, c) values (1569495327, from_unixtime(1569495327)); +select * from t1; +a b c +1569495327 2019-09-26 10:55:27 2019-09-26 10:55:27 +1569495327 2019-09-26 11:55:27 2019-09-26 11:55:27 +1569495327 2019-09-26 11:55:27 2019-09-26 11:55:27 +drop table t1; +set time_zone = "+00:00"; +create table t1 (a int, b timestamp as (from_unixtime(a)) virtual); +insert into t1 (a) value (1569495327); +select a, b, from_unixtime(a) from t1; +a b from_unixtime(a) +1569495327 2019-09-26 10:55:27 2019-09-26 10:55:27 +set time_zone = "+01:00"; +select a, b, from_unixtime(a) from t1; +a b from_unixtime(a) +1569495327 2019-09-26 11:55:27 2019-09-26 11:55:27 +flush tables; +select a, b, from_unixtime(a) from t1; +a b from_unixtime(a) +1569495327 2019-09-26 11:55:27 2019-09-26 11:55:27 +drop table t1; diff --git a/mysql-test/t/default_session.test b/mysql-test/t/default_session.test index 7796354ffd4..5e582bd5ca1 100644 --- a/mysql-test/t/default_session.test +++ b/mysql-test/t/default_session.test @@ -80,3 +80,27 @@ insert t1 () values (); set sql_mode=default; select * from t1; drop table t1; + +# +# MDEV-21249 MariaDB 10.3.10 When referring to bigint to generate timestamp data in the virtual generated column, the value of the generated column does not change when the time zone changes +# +set time_zone='+00:00'; +create table t1 (a int, b datetime default from_unixtime(a), c datetime); +insert t1 (a, c) values (1569495327, from_unixtime(1569495327)); +set time_zone='+01:00'; +insert t1 (a, c) values (1569495327, from_unixtime(1569495327)); +flush tables; +insert t1 (a, c) values (1569495327, from_unixtime(1569495327)); +select * from t1; +drop table t1; + +# same with vcols +set time_zone = "+00:00"; +create table t1 (a int, b timestamp as (from_unixtime(a)) virtual); +insert into t1 (a) value (1569495327); +select a, b, from_unixtime(a) from t1; +set time_zone = "+01:00"; +select a, b, from_unixtime(a) from t1; +flush tables; +select a, b, from_unixtime(a) from t1; +drop table t1; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index c89b6921796..f25fe3a551f 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -867,6 +867,10 @@ class Item_func_from_unixtime :public Item_datetimefunc const char *func_name() const { return "from_unixtime"; } bool fix_length_and_dec(); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); + bool check_vcol_func_processor(void *arg) + { + return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC); + } Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy<Item_func_from_unixtime>(thd, mem_root, this); } }; |