summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2019-02-21 18:59:28 +0300
committerAlexander Barkov <bar@mariadb.com>2019-05-20 15:19:01 +0400
commit6473641b9a04d65b7480831e926aa4150571a617 (patch)
treeb05c101dce425456b91ce5e2a4216d3d4652208a
parentb77460508eb9b82054ac92a42bbb7c54f34273ce (diff)
downloadmariadb-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.result7
-rw-r--r--mysql-test/suite/versioning/t/create.test9
-rw-r--r--sql/handler.cc3
-rw-r--r--sql/table.cc1
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)