MDEV-27195 SIGSEGV in Table_scope_and_contents_source_st::vers_check_system_fields

The old code erroneously used default_charset_info to compare field names.
default_charset_info can point to any arbitrary collation,
including ucs2*, utf16*, utf32*, including those that do not
support strcasecmp().

my_charset_utf8mb4_unicode_ci, which is used in this scenario:

CREATE TABLE t1 ENGINE=InnoDB WITH SYSTEM VERSIONING AS SELECT 0;

does not support strcasecmp().

Fixing the code to use Lex_ident::streq(), which uses
system_charset_info instead of default_charset_info.
This commit is contained in:
Alexander Barkov 2021-12-22 13:12:40 +04:00
parent 3b33593f80
commit a5ef74e7eb
4 changed files with 28 additions and 2 deletions

View file

@ -0,0 +1 @@
--character-set-server=utf8mb4,latin1 --collation-server=utf8mb4_unicode_ci

View file

@ -0,0 +1,11 @@
#
# Start of 10.3 tests
#
#
# MDEV-27195 SIGSEGV in Table_scope_and_contents_source_st::vers_check_system_fields
#
CREATE TABLE t1 ENGINE=MyISAM WITH SYSTEM VERSIONING AS SELECT 0;
DROP TABLE t1;
#
# End of 10.3 tests
#

View file

@ -0,0 +1,15 @@
--echo #
--echo # Start of 10.3 tests
--echo #
--echo #
--echo # MDEV-27195 SIGSEGV in Table_scope_and_contents_source_st::vers_check_system_fields
--echo #
CREATE TABLE t1 ENGINE=MyISAM WITH SYSTEM VERSIONING AS SELECT 0;
DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #

View file

@ -7264,8 +7264,7 @@ bool Table_scope_and_contents_source_st::vers_check_system_fields(
{
List_iterator<Create_field> dup_it(alter_info->create_list);
for (Create_field *dup= dup_it++; !is_dup && dup != f; dup= dup_it++)
is_dup= my_strcasecmp(default_charset_info,
dup->field_name.str, f->field_name.str) == 0;
is_dup= Lex_ident(dup->field_name).streq(f->field_name);
}
if (!(f->flags & VERS_UPDATE_UNVERSIONED_FLAG) && !is_dup)