Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.3.20, 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
-
ubuntu 16.04 mariadb 10.3
Description
When creating a virtual column, if the virtual column is timestamp, the value of the virtual column does not change when the time zone changes, and the mysql version changes.
mariadb10.3:
|
create table test_timestamp (`create_timestamp` timestamp(3) NOT NULL COMMENT '记录创建时间',`create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` )) VIRTUAL COMMENT '记录创建时间');
|
|
insert into test_timestamp (`create_timestamp`) value (1569495326.861);
|
|
|
mysql> select * from test_timestamp;
|
+------------------+-------------------------+
|
| create_timestamp | create_time |
|
+------------------+-------------------------+
|
| 1569495326861 | 2019-09-26 10:55:26.861 |
|
+------------------+-------------------------+
|
1 row in set (0.01 sec)
|
|
mysql> set time_zone = "+01:00";
|
Query OK, 0 rows affected (0.00 sec)
|
|
mysql> select * from test_timestamp;
|
+------------------+-------------------------+
|
| create_timestamp | create_time |
|
+------------------+-------------------------+
|
| 1569495326861 | 2019-09-26 10:55:26.861 |
|
+------------------+-------------------------+
|
1 row in set (0.00 sec)
|
|
mysql5.7:
mysql> create table test_timestamp (`create_timestamp` bigint(20) NOT NULL COMMENT '记录创建时间',
|
-> `create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` / 1000)) VIRTUAL COMMENT '记录创建时间');
|
Query OK, 0 rows affected (0.31 sec)
|
|
mysql> insert into test_timestamp (`create_timestamp`) value (1569495326861);
|
Query OK, 1 row affected (0.03 sec)
|
|
mysql> select * from test_timestamp;
|
+------------------+-------------------------+
|
| create_timestamp | create_time |
|
+------------------+-------------------------+
|
| 1569495326861 | 2019-09-26 10:55:26.861 |
|
+------------------+-------------------------+
|
1 row in set (0.01 sec)
|
|
mysql> set time_zone = "+01:00";
|
Query OK, 0 rows affected (0.00 sec)
|
|
mysql> select * from test_timestamp;
|
+------------------+-------------------------+
|
| create_timestamp | create_time |
|
+------------------+-------------------------+
|
| 1569495326861 | 2019-09-26 11:55:26.861 |
|
+------------------+-------------------------+
|
1 row in set (0.00 sec)
|
Attachments
Issue Links
- causes
-
MDEV-21593 from_unixtime can not be longer used in Virtual Column
-
- Stalled
-
Activity
Field | Original Value | New Value |
---|---|---|
Description |
mariadb 创建一个虚拟列时,如果虚拟列为timestamp时,当时区发生变化时,虚拟列的值不发生变化,而mysql版本会发生变化
mariadb10.3环境: create table test_timestamp (`create_timestamp` timestamp(3) NOT NULL COMMENT '记录创建时间',`create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` )) VIRTUAL COMMENT '记录创建时间'); insert into test_timestamp (`create_timestamp`) value (1569495326.861); mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.01 sec) mysql> set time_zone = "+01:00"; Query OK, 0 rows affected (0.00 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.00 sec) mysql5.7环境: mysql> create table test_timestamp (`create_timestamp` bigint(20) NOT NULL COMMENT '记录创建时间', -> `create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` / 1000)) VIRTUAL COMMENT '记录创建时间'); Query OK, 0 rows affected (0.31 sec) mysql> insert into test_timestamp (`create_timestamp`) value (1569495326861); Query OK, 1 row affected (0.03 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.01 sec) mysql> set time_zone = "+01:00"; Query OK, 0 rows affected (0.00 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 11:55:26.861 | +------------------+-------------------------+ 1 row in set (0.00 sec) |
When creating a virtual column, if the virtual column is timestamp, the value of the virtual column does not change when the time zone changes, and the mysql version changes.
mariadb10.3: create table test_timestamp (`create_timestamp` timestamp(3) NOT NULL COMMENT '记录创建时间',`create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` )) VIRTUAL COMMENT '记录创建时间'); insert into test_timestamp (`create_timestamp`) value (1569495326.861); mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.01 sec) mysql> set time_zone = "+01:00"; Query OK, 0 rows affected (0.00 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.00 sec) mysql5.7: mysql> create table test_timestamp (`create_timestamp` bigint(20) NOT NULL COMMENT '记录创建时间', -> `create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` / 1000)) VIRTUAL COMMENT '记录创建时间'); Query OK, 0 rows affected (0.31 sec) mysql> insert into test_timestamp (`create_timestamp`) value (1569495326861); Query OK, 1 row affected (0.03 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.01 sec) mysql> set time_zone = "+01:00"; Query OK, 0 rows affected (0.00 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 11:55:26.861 | +------------------+-------------------------+ 1 row in set (0.00 sec) |
Environment | 生产环境 ubuntu 16.04 | ubuntu 16.04 mariadb 10.3 |
Summary | mariadb 10.3.10 虚拟生成列中引用bigint 生成timestamp类型的数据时,当时区变化时,生成列的值不变化 | 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 |
Description |
When creating a virtual column, if the virtual column is timestamp, the value of the virtual column does not change when the time zone changes, and the mysql version changes.
mariadb10.3: create table test_timestamp (`create_timestamp` timestamp(3) NOT NULL COMMENT '记录创建时间',`create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` )) VIRTUAL COMMENT '记录创建时间'); insert into test_timestamp (`create_timestamp`) value (1569495326.861); mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.01 sec) mysql> set time_zone = "+01:00"; Query OK, 0 rows affected (0.00 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.00 sec) mysql5.7: mysql> create table test_timestamp (`create_timestamp` bigint(20) NOT NULL COMMENT '记录创建时间', -> `create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` / 1000)) VIRTUAL COMMENT '记录创建时间'); Query OK, 0 rows affected (0.31 sec) mysql> insert into test_timestamp (`create_timestamp`) value (1569495326861); Query OK, 1 row affected (0.03 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.01 sec) mysql> set time_zone = "+01:00"; Query OK, 0 rows affected (0.00 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 11:55:26.861 | +------------------+-------------------------+ 1 row in set (0.00 sec) |
When creating a virtual column, if the virtual column is timestamp, the value of the virtual column does not change when the time zone changes, and the mysql version changes.
mariadb10.3: {noformat} create table test_timestamp (`create_timestamp` timestamp(3) NOT NULL COMMENT '记录创建时间',`create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` )) VIRTUAL COMMENT '记录创建时间'); insert into test_timestamp (`create_timestamp`) value (1569495326.861); mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.01 sec) mysql> set time_zone = "+01:00"; Query OK, 0 rows affected (0.00 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.00 sec) {noformat} mysql5.7: {noformat} mysql> create table test_timestamp (`create_timestamp` bigint(20) NOT NULL COMMENT '记录创建时间', -> `create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` / 1000)) VIRTUAL COMMENT '记录创建时间'); Query OK, 0 rows affected (0.31 sec) mysql> insert into test_timestamp (`create_timestamp`) value (1569495326861); Query OK, 1 row affected (0.03 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 10:55:26.861 | +------------------+-------------------------+ 1 row in set (0.01 sec) mysql> set time_zone = "+01:00"; Query OK, 0 rows affected (0.00 sec) mysql> select * from test_timestamp; +------------------+-------------------------+ | create_timestamp | create_time | +------------------+-------------------------+ | 1569495326861 | 2019-09-26 11:55:26.861 | +------------------+-------------------------+ 1 row in set (0.00 sec) {noformat} |
Affects Version/s | 5.5 [ 15800 ] | |
Affects Version/s | 10.0 [ 16000 ] | |
Affects Version/s | 10.1 [ 16100 ] | |
Affects Version/s | 10.2 [ 14601 ] | |
Affects Version/s | 10.3 [ 22126 ] | |
Affects Version/s | 10.4 [ 22408 ] |
Labels | datatype | datatype virtual_columns |
Fix Version/s | 5.5 [ 15800 ] | |
Fix Version/s | 10.0 [ 16000 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Fix Version/s | 10.4 [ 22408 ] |
Status | Open [ 1 ] | Confirmed [ 10101 ] |
Assignee | Sergei Golubchik [ serg ] |
Status | Confirmed [ 10101 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | Stalled [ 10000 ] |
Component/s | Virtual Columns [ 10803 ] | |
Component/s | Data Manipulation - Insert [ 10101 ] | |
Fix Version/s | 10.2.31 [ 24017 ] | |
Fix Version/s | 10.3.22 [ 24018 ] | |
Fix Version/s | 10.4.12 [ 24019 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Fix Version/s | 5.5 [ 15800 ] | |
Fix Version/s | 10.0 [ 16000 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Link | This issue causes MDEV-21593 [ MDEV-21593 ] |
Workflow | MariaDB v3 [ 101724 ] | MariaDB v4 [ 157066 ] |
Thanks a lot! I repeated on MariaDb 5.5-10.4:
MariaDB [test]> select a, b, from_unixtime(a) from t1;
+------------+---------------------+---------------------+
| a | b | from_unixtime(a) |
+------------+---------------------+---------------------+
| 1569495327 | 2019-09-26 12:55:27 | 2019-09-26 12:55:27 |
+------------+---------------------+---------------------+
1 row in set (0.000 sec)
MariaDB [test]> set time_zone = "+01:00";
Query OK, 0 rows affected (0.000 sec)
MariaDB [test]> select a, b, from_unixtime(a) from t1;
+------------+---------------------+---------------------+
| a | b | from_unixtime(a) |
+------------+---------------------+---------------------+
| 1569495327 | 2019-09-26 12:55:27 | 2019-09-26 11:55:27 |
+------------+---------------------+---------------------+
1 row in set (0.000 sec)