diff --git a/mysql-test/r/ctype_ldml.result b/mysql-test/r/ctype_ldml.result index 222351cd5e2..3373e31539f 100644 --- a/mysql-test/r/ctype_ldml.result +++ b/mysql-test/r/ctype_ldml.result @@ -402,3 +402,8 @@ s1 a b DROP TABLE t1; +SET NAMES utf8 COLLATE utf8_phone_ci; +SHOW COLLATION LIKE 'utf8_phone_ci'; +Collation Charset Id Default Compiled Sortlen +utf8_phone_ci utf8 352 8 +SET NAMES utf8; diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test index 7e469321d5b..99d9cd5a866 100644 --- a/mysql-test/t/ctype_ldml.test +++ b/mysql-test/t/ctype_ldml.test @@ -144,3 +144,11 @@ CREATE TABLE t1 (s1 char(10) character set utf8 collate utf8_maxuserid_ci); INSERT INTO t1 VALUES ('a'),('b'); SELECT * FROM t1 WHERE s1='a' ORDER BY BINARY s1; DROP TABLE t1; + + +# +# Bug#47756 Setting 2byte collation ID with 'set names' crashes the server +# +SET NAMES utf8 COLLATE utf8_phone_ci; +SHOW COLLATION LIKE 'utf8_phone_ci'; +SET NAMES utf8; diff --git a/mysys/charset.c b/mysys/charset.c index 280b2ad6091..e216f665092 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -255,6 +255,9 @@ static int add_collation(CHARSET_INFO *cs) { #if defined (HAVE_CHARSET_utf8) && defined(HAVE_UCA_COLLATIONS) copy_uca_collation(newcs, &my_charset_utf8_unicode_ci); + newcs->ctype= my_charset_utf8_unicode_ci.ctype; + if (init_state_maps(newcs)) + return MY_XML_ERROR; #endif } else