diff --git a/mysql-test/suite/period/r/alter.result b/mysql-test/suite/period/r/alter.result index 9eb4555c0bdad..0d82acb994449 100644 --- a/mysql-test/suite/period/r/alter.result +++ b/mysql-test/suite/period/r/alter.result @@ -222,3 +222,12 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; # End of 10.5 tests +# +# MDEV-30297 Server crash / assertion failure in Compare_identifiers::operator upon dropping period with empty name +# +create table t (a int); +alter table t drop period if exists for ``; +Warnings: +Note 1091 Can't DROP PERIOD ``; check that it exists +drop table t; +# End of 10.11 tests diff --git a/mysql-test/suite/period/t/alter.test b/mysql-test/suite/period/t/alter.test index fab933eca879c..24f61ab223695 100644 --- a/mysql-test/suite/period/t/alter.test +++ b/mysql-test/suite/period/t/alter.test @@ -190,3 +190,13 @@ show create table t1; drop table t1; --echo # End of 10.5 tests + +--echo # +--echo # MDEV-30297 Server crash / assertion failure in Compare_identifiers::operator upon dropping period with empty name +--echo # +create table t (a int); +alter table t drop period if exists for ``; + +drop table t; + +--echo # End of 10.11 tests diff --git a/sql/vers_string.h b/sql/vers_string.h index 9c1730fad81a5..d91b2538d10b5 100644 --- a/sql/vers_string.h +++ b/sql/vers_string.h @@ -66,7 +66,11 @@ struct Lex_cstring_with_compare : public Lex_cstring { } bool streq(const Lex_cstring_with_compare& b) const { - return Lex_cstring::length == b.length && 0 == Compare()(*this, b); + if (length != b.length) + return false; + if (str == NULL || b.str == NULL) + return str == b.str; + return length == 0 || 0 == Compare()(*this, b); } operator const char* () const {