don't allow TIME columns in PERIOD specification

This commit is contained in:
Sergei Golubchik 2019-02-16 18:43:20 +01:00
parent 7b48724dcc
commit 8ad23ff498
3 changed files with 8 additions and 1 deletions

View File

@ -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'

View File

@ -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));

View File

@ -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;