diff options
author | Eugene Kosov <claprix@yandex.ru> | 2019-02-21 18:59:28 +0300 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-05-20 15:19:01 +0400 |
commit | 6473641b9a04d65b7480831e926aa4150571a617 (patch) | |
tree | b05c101dce425456b91ce5e2a4216d3d4652208a | |
parent | b77460508eb9b82054ac92a42bbb7c54f34273ce (diff) | |
download | mariadb-git-6473641b9a04d65b7480831e926aa4150571a617.tar.gz |
MDEV-18512 using DATETIME(6) as row_start/row_end crashes server
Disallow DATETIME for SYSTEM VERSIONING tables.
-rw-r--r-- | mysql-test/suite/versioning/r/create.result | 7 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/create.test | 9 | ||||
-rw-r--r-- | sql/handler.cc | 3 | ||||
-rw-r--r-- | sql/table.cc | 1 |
4 files changed, 17 insertions, 3 deletions
diff --git a/mysql-test/suite/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result index 6cacdd1fd54..0c68624355b 100644 --- a/mysql-test/suite/versioning/r/create.result +++ b/mysql-test/suite/versioning/r/create.result @@ -508,5 +508,12 @@ row_end bigint as row end, period for system_time (row_start, row_end) ) engine=myisam with system versioning; ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `t1` +create table t ( +a int, +row_start datetime(6) generated always as row start, +row_end datetime(6) generated always as row end, +period for system_time(row_start, row_end) +) with system versioning; +ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `t` drop database test; create database test; diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test index 7c7be3e02e3..e7bf3fda803 100644 --- a/mysql-test/suite/versioning/t/create.test +++ b/mysql-test/suite/versioning/t/create.test @@ -387,5 +387,14 @@ create or replace table t1 ( period for system_time (row_start, row_end) ) engine=myisam with system versioning; +--error ER_VERS_FIELD_WRONG_TYPE +create table t ( + a int, + row_start datetime(6) generated always as row start, + row_end datetime(6) generated always as row end, + period for system_time(row_start, row_end) +) with system versioning; + + drop database test; create database test; diff --git a/sql/handler.cc b/sql/handler.cc index 826b6f34746..993ba5947dc 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7433,8 +7433,7 @@ bool Vers_parse_info::check_conditions(const Lex_table_name &table_name, static bool is_versioning_timestamp(const Create_field *f) { - return (f->type_handler() == &type_handler_datetime2 || - f->type_handler() == &type_handler_timestamp2) && + return f->type_handler() == &type_handler_timestamp2 && f->length == MAX_DATETIME_FULL_WIDTH; } diff --git a/sql/table.cc b/sql/table.cc index 1253710c677..bd651673388 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2025,7 +2025,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, switch (field_type) { case MYSQL_TYPE_TIMESTAMP2: - case MYSQL_TYPE_DATETIME2: break; case MYSQL_TYPE_LONGLONG: if (vers_can_native) |