summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-02-16 18:43:20 +0100
committerSergei Golubchik <serg@mariadb.org>2019-02-21 14:57:10 +0100
commit8ad23ff49834775b07397ebd8d2840c203aab59a (patch)
tree1d68206bd120ab43c4818f15f30bd4149bb0f8b3
parent7b48724dcca4064a272aac1ebe0e3ba061cc78c2 (diff)
downloadmariadb-git-8ad23ff49834775b07397ebd8d2840c203aab59a.tar.gz
don't allow TIME columns in PERIOD specification
-rw-r--r--mysql-test/suite/period/r/create.result3
-rw-r--r--mysql-test/suite/period/t/create.test3
-rw-r--r--sql/handler.cc3
3 files changed, 8 insertions, 1 deletions
diff --git a/mysql-test/suite/period/r/create.result b/mysql-test/suite/period/r/create.result
index df77669f727..427d9605afe 100644
--- a/mysql-test/suite/period/r/create.result
+++ b/mysql-test/suite/period/r/create.result
@@ -40,6 +40,9 @@ ERROR HY000: Fields of PERIOD FOR `mytime` have different types
create or replace table t (id int primary key, s int, e date,
period for mytime(s,e));
ERROR 42000: Incorrect column specifier for column 's'
+create or replace table t (id int primary key, s time, e time,
+period for mytime(s,e));
+ERROR 42000: Incorrect column specifier for column 's'
create or replace table t (id int primary key, s date, e date,
period for mytime(s,x));
ERROR 42S22: Unknown column 'x' in 'mytime'
diff --git a/mysql-test/suite/period/t/create.test b/mysql-test/suite/period/t/create.test
index 9648fa02fbc..45f934bf133 100644
--- a/mysql-test/suite/period/t/create.test
+++ b/mysql-test/suite/period/t/create.test
@@ -26,6 +26,9 @@ create or replace table t (s timestamp(2), e timestamp(6),
--error ER_WRONG_FIELD_SPEC
create or replace table t (id int primary key, s int, e date,
period for mytime(s,e));
+--error ER_WRONG_FIELD_SPEC
+create or replace table t (id int primary key, s time, e time,
+ period for mytime(s,e));
--error ER_BAD_FIELD_ERROR
create or replace table t (id int primary key, s date, e date,
period for mytime(s,x));
diff --git a/sql/handler.cc b/sql/handler.cc
index f11361f7779..0269e85b123 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -7593,7 +7593,8 @@ bool Table_period_info::check_field(const Create_field* f,
my_error(ER_BAD_FIELD_ERROR, MYF(0), f_name.str, name.str);
res= true;
}
- else if (f->type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_ERROR)
+ else if (f->type_handler()->mysql_timestamp_type() != MYSQL_TIMESTAMP_DATE &&
+ f->type_handler()->mysql_timestamp_type() != MYSQL_TIMESTAMP_DATETIME)
{
my_error(ER_WRONG_FIELD_SPEC, MYF(0), f->field_name.str);
res= true;