summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2021-12-22 13:12:40 +0400
committerAlexander Barkov <bar@mariadb.com>2021-12-22 13:12:40 +0400
commita5ef74e7eb4bab09c9bda4fcd7fab12302526ea4 (patch)
tree7195b963353558aa74df1e3a52f826444a7a30e0
parent3b33593f80442214640eefb2ce75c34698c8043b (diff)
downloadmariadb-git-a5ef74e7eb4bab09c9bda4fcd7fab12302526ea4.tar.gz
MDEV-27195 SIGSEGV in Table_scope_and_contents_source_st::vers_check_system_fieldsbb-10.3-bar-MDEV-27195
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.
-rw-r--r--mysql-test/main/ctype_utf8mb4_unicode_ci_def.opt1
-rw-r--r--mysql-test/main/ctype_utf8mb4_unicode_ci_def.result11
-rw-r--r--mysql-test/main/ctype_utf8mb4_unicode_ci_def.test15
-rw-r--r--sql/handler.cc3
4 files changed, 28 insertions, 2 deletions
diff --git a/mysql-test/main/ctype_utf8mb4_unicode_ci_def.opt b/mysql-test/main/ctype_utf8mb4_unicode_ci_def.opt
new file mode 100644
index 00000000000..e430a45c10e
--- /dev/null
+++ b/mysql-test/main/ctype_utf8mb4_unicode_ci_def.opt
@@ -0,0 +1 @@
+--character-set-server=utf8mb4,latin1 --collation-server=utf8mb4_unicode_ci
diff --git a/mysql-test/main/ctype_utf8mb4_unicode_ci_def.result b/mysql-test/main/ctype_utf8mb4_unicode_ci_def.result
new file mode 100644
index 00000000000..2e15931248b
--- /dev/null
+++ b/mysql-test/main/ctype_utf8mb4_unicode_ci_def.result
@@ -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
+#
diff --git a/mysql-test/main/ctype_utf8mb4_unicode_ci_def.test b/mysql-test/main/ctype_utf8mb4_unicode_ci_def.test
new file mode 100644
index 00000000000..fb7fbe04e3b
--- /dev/null
+++ b/mysql-test/main/ctype_utf8mb4_unicode_ci_def.test
@@ -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 #
diff --git a/sql/handler.cc b/sql/handler.cc
index 11a387fb4e3..f8702c27a39 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -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)