summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNayuta Yanagisawa <nayuta.yanagisawa@gmail.com>2020-10-16 14:33:22 +0000
committerNikita Malyavin <nikitamalyavin@gmail.com>2020-11-04 12:33:13 +0300
commitb13fe8e51bd356299f58a07fecc589b3b3c4937b (patch)
treef01e0f35e4d38d6e7af675036950d0d3ab66f7e3
parent0f04f61395b642d429aaa6a0372061b0d996a6b9 (diff)
downloadmariadb-git-b13fe8e51bd356299f58a07fecc589b3b3c4937b.tar.gz
MDEV-18842: Unfortunate error message when the same column is used for application period start and end
An application-time period must be composed of two different columns. We added a check that ensures that the above condition is met.
-rw-r--r--mysql-test/suite/period/r/create.result4
-rw-r--r--mysql-test/suite/period/t/create.test6
-rw-r--r--sql/sql_lex.h6
3 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/suite/period/r/create.result b/mysql-test/suite/period/r/create.result
index 8cedb23465d..da4cf998918 100644
--- a/mysql-test/suite/period/r/create.result
+++ b/mysql-test/suite/period/r/create.result
@@ -45,6 +45,10 @@ 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'
+# MDEV-18842: Unfortunate error message when the same column is used
+# for application period start and end
+create or replace table t (s date, t date, period for apt(s,s));
+ERROR 42000: Column 's' specified twice
create or replace table t (id int primary key, s date, e date,
period for mytime(s,e),
period for mytime2(s,e));
diff --git a/mysql-test/suite/period/t/create.test b/mysql-test/suite/period/t/create.test
index 2e3de795698..49dcc6ad3c7 100644
--- a/mysql-test/suite/period/t/create.test
+++ b/mysql-test/suite/period/t/create.test
@@ -31,6 +31,12 @@ create or replace table t (id int primary key, s time, e time,
--error ER_BAD_FIELD_ERROR
create or replace table t (id int primary key, s date, e date,
period for mytime(s,x));
+
+--echo # MDEV-18842: Unfortunate error message when the same column is used
+--echo # for application period start and end
+--error ER_FIELD_SPECIFIED_TWICE
+create or replace table t (s date, t date, period for apt(s,s));
+
--error ER_MORE_THAN_ONE_PERIOD
create or replace table t (id int primary key, s date, e date,
period for mytime(s,e),
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index c8fca748b77..66c44f2d901 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -4361,6 +4361,12 @@ public:
int add_period(Lex_ident name, Lex_ident_sys_st start, Lex_ident_sys_st end)
{
+ if (lex_string_cmp(system_charset_info, &start, &end) == 0)
+ {
+ my_error(ER_FIELD_SPECIFIED_TWICE, MYF(0), start.str);
+ return 1;
+ }
+
Table_period_info &info= create_info.period_info;
if (check_exists && info.name.streq(name))