From 5655a2f8ae315c79c138b11d065eb1c8867d0962 Mon Sep 17 00:00:00 2001 From: PranavKTiwari Date: Mon, 15 Jun 2026 15:27:50 +0530 Subject: [PATCH] MDEV-30297 Server crash / assertion failure in Compare_identifiers::operator upon dropping period with empty name Lex_cstring_with_compare::streq() could invoke Compare_identifiers on default-constructed Lex_cstring objects (str == NULL, length == 0). Compare_identifiers assumes non-null strings and asserts in debug builds or crashes in non-debug builds. Guard against null string pointers in streq() before invoking the comparator. --- mysql-test/suite/period/r/alter.result | 9 +++++++++ mysql-test/suite/period/t/alter.test | 10 ++++++++++ sql/vers_string.h | 6 +++++- 3 files changed, 24 insertions(+), 1 deletion(-) 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 {