diff options
author | tmokmss <tomookam@live.jp> | 2022-06-05 08:04:18 +0000 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-08-26 12:40:58 +0300 |
commit | 827b049e1e7df204feb744a270b4dca619a61de1 (patch) | |
tree | 607c8f72697c91d696c7a931af1698d545e57f00 /mysql-test/suite/period | |
parent | 851058a3e6f40cd2714762916235ebe93fc594b5 (diff) | |
download | mariadb-git-827b049e1e7df204feb744a270b4dca619a61de1.tar.gz |
MDEV-18873 Server crashes in Compare_identifiers::operator or in my_strcasecmp_utf8 upon ADD PERIOD IF NOT EXISTS with empty name
empty identifier specified as `` ends up with a NULL LEX_CSTRING::str in lexer.
This is not considered correct in upper layers, for example in Compare_identifiers::operator().
Empty column name is usually avoided by a check_column_name() call while parsing,
and period name matches the column name completely.
Hence, this fix uses the mentioned call for verification, too.
Diffstat (limited to 'mysql-test/suite/period')
-rw-r--r-- | mysql-test/suite/period/r/alter.result | 14 | ||||
-rw-r--r-- | mysql-test/suite/period/t/alter.test | 23 |
2 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/suite/period/r/alter.result b/mysql-test/suite/period/r/alter.result index a6466c8944b..875dab93b68 100644 --- a/mysql-test/suite/period/r/alter.result +++ b/mysql-test/suite/period/r/alter.result @@ -190,3 +190,17 @@ alter table t1 add primary key(x, s, e); ERROR 23000: Duplicate entry '1-2020-03-01-2020-03-02' for key 'PRIMARY' alter table t1 add system versioning; drop table t1; +# +# MDEV-18873 Server crashes in Compare_identifiers::operator or in +# my_strcasecmp_utf8 upon ADD PERIOD IF NOT EXISTS with empty name +# +alter table t add period if not exists for `` (s,e); +ERROR 42000: Incorrect column name '' +create table t(s DATE, e DATE); +alter table t add period if not exists for `` (s,e); +ERROR 42000: Incorrect column name '' +alter table t add period if not exists for ` ` (s,e); +ERROR 42000: Incorrect column name ' ' +create table t2 (period for `` (s,e)) select * from t; +ERROR 42000: Incorrect column name '' +drop table t; diff --git a/mysql-test/suite/period/t/alter.test b/mysql-test/suite/period/t/alter.test index 3fa3c5c87d5..2a82f74b670 100644 --- a/mysql-test/suite/period/t/alter.test +++ b/mysql-test/suite/period/t/alter.test @@ -151,3 +151,26 @@ alter table t1 add system versioning; # cleanup drop table t1; + +--echo # +--echo # MDEV-18873 Server crashes in Compare_identifiers::operator or in +--echo # my_strcasecmp_utf8 upon ADD PERIOD IF NOT EXISTS with empty name +--echo # + +# When there is no table defined. +--error ER_WRONG_COLUMN_NAME +alter table t add period if not exists for `` (s,e); + +# When there is an actual table. +create table t(s DATE, e DATE); +--error ER_WRONG_COLUMN_NAME +alter table t add period if not exists for `` (s,e); + +# When the last character is space +--error ER_WRONG_COLUMN_NAME +alter table t add period if not exists for ` ` (s,e); + +# Create table with an empty period name +--error ER_WRONG_COLUMN_NAME +create table t2 (period for `` (s,e)) select * from t; +drop table t; |