From b9adaeb491a36170a140799bce0de911d654c2d6 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 12 May 2022 10:55:18 +0400 Subject: MDEV-28481 SIGSEGV in Lex_charset_collation_st::find_bin_collation --- mysql-test/main/ctype_filename.result | 19 +++++++++++++++++++ mysql-test/main/ctype_filename.test | 24 ++++++++++++++++++++++++ sql/lex_charset.cc | 3 ++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/ctype_filename.result b/mysql-test/main/ctype_filename.result index 739fa979f28..a223bf084e9 100644 --- a/mysql-test/main/ctype_filename.result +++ b/mysql-test/main/ctype_filename.result @@ -133,3 +133,22 @@ a c DROP TABLE t1; SET NAMES utf8; # End of 10.5 tests +# +# Start of 10.9 tests +# +# +# MDEV-28481 SIGSEGV in Lex_charset_collation_st::find_bin_collation +# +SET SESSION collation_server=filename; +CREATE DATABASE db1; +USE db1; +CREATE TABLE t (c CHAR BINARY); +ERROR HY000: Unknown collation: 'filename_bin' +DROP DATABASE db1; +USE test; +SET NAMES latin1; +CREATE TABLE t1 (c CHAR BINARY) CHARACTER SET filename; +ERROR HY000: Unknown collation: 'filename_bin' +# +# End of 10.9 tests +# diff --git a/mysql-test/main/ctype_filename.test b/mysql-test/main/ctype_filename.test index ba42d1a2807..100e2b3ae43 100644 --- a/mysql-test/main/ctype_filename.test +++ b/mysql-test/main/ctype_filename.test @@ -139,3 +139,27 @@ SET NAMES utf8; --enable_ps_protocol --echo # End of 10.5 tests + +--echo # +--echo # Start of 10.9 tests +--echo # + +--echo # +--echo # MDEV-28481 SIGSEGV in Lex_charset_collation_st::find_bin_collation +--echo # + +SET SESSION collation_server=filename; +CREATE DATABASE db1; +USE db1; +--error ER_UNKNOWN_COLLATION +CREATE TABLE t (c CHAR BINARY); +DROP DATABASE db1; +USE test; +SET NAMES latin1; + +--error ER_UNKNOWN_COLLATION +CREATE TABLE t1 (c CHAR BINARY) CHARACTER SET filename; + +--echo # +--echo # End of 10.9 tests +--echo # diff --git a/sql/lex_charset.cc b/sql/lex_charset.cc index c6c9e402731..7570abbdfb9 100644 --- a/sql/lex_charset.cc +++ b/sql/lex_charset.cc @@ -41,10 +41,11 @@ CHARSET_INFO *Lex_charset_collation_st::find_bin_collation(CHARSET_INFO *cs) return cs; // CREATE TABLE t1 (a CHAR(10) BINARY) CHARACTER SET utf8mb4; + const LEX_CSTRING &cs_name= cs->cs_name; if (!(cs= get_charset_by_csname(cs->cs_name.str, MY_CS_BINSORT, MYF(0)))) { char tmp[65]; - strxnmov(tmp, sizeof(tmp)-1, cs->cs_name.str, "_bin", NULL); + strxnmov(tmp, sizeof(tmp)-1, cs_name.str, "_bin", NULL); my_error(ER_UNKNOWN_COLLATION, MYF(0), tmp); } return cs; -- cgit v1.2.1