Commit 8eec2d61 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-21249 MariaDB 10.3.10 When referring to bigint to generate timestamp data...

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
parent 4e7f3fb8
......@@ -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;
......@@ -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;
......@@ -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); }
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment