Skip to content

Commit 30a86a0

Browse files
author
bar@mysql.com
committed
Bug#4417 binary character set breaks multi-byte table/field name.
1 parent 434e2e0 commit 30a86a0

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

mysql-test/r/ctype_recoding.result

+25
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,28 @@ SET character_set_connection=cp1251;
111111
SELECT hex('����');
112112
hex('����')
113113
F2E5F1F2
114+
USE test;
115+
SET NAMES binary;
116+
CREATE TABLE `тест` (`тест` int);
117+
SHOW CREATE TABLE `тест`;
118+
Table Create Table
119+
тест CREATE TABLE `тест` (
120+
`тест` int(11) default NULL
121+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
122+
SET NAMES utf8;
123+
SHOW CREATE TABLE `тест`;
124+
Table Create Table
125+
тест CREATE TABLE `тест` (
126+
`тест` int(11) default NULL
127+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
128+
DROP TABLE `тест`;
129+
SET NAMES binary;
130+
SET character_set_connection=utf8;
131+
SELECT 'тест' as s;
132+
s
133+
тест
134+
SET NAMES utf8;
135+
SET character_set_connection=binary;
136+
SELECT 'тест' as s;
137+
s
138+
тест

mysql-test/t/ctype_recoding.test

+19
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,22 @@ SET NAMES koi8r;
7878
SELECT hex('����');
7979
SET character_set_connection=cp1251;
8080
SELECT hex('����');
81+
82+
USE test;
83+
84+
# Bug#4417
85+
# Check that identifiers and strings are not converted
86+
# when the client character set is binary.
87+
88+
SET NAMES binary;
89+
CREATE TABLE `тест` (`тест` int);
90+
SHOW CREATE TABLE `тест`;
91+
SET NAMES utf8;
92+
SHOW CREATE TABLE `тест`;
93+
DROP TABLE `тест`;
94+
SET NAMES binary;
95+
SET character_set_connection=utf8;
96+
SELECT 'тест' as s;
97+
SET NAMES utf8;
98+
SET character_set_connection=binary;
99+
SELECT 'тест' as s;

sql/sql_class.cc

+8-6
Original file line numberDiff line numberDiff line change
@@ -533,21 +533,23 @@ bool THD::convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
533533
return FALSE;
534534
}
535535

536+
536537
/*
537538
Update some cache variables when character set changes
538539
*/
539540

540541
void THD::update_charset()
541542
{
542-
charset_is_system_charset= my_charset_same(charset(),system_charset_info);
543-
charset_is_collation_connection= my_charset_same(charset(),
544-
variables.
545-
collation_connection);
543+
uint32 not_used;
544+
charset_is_system_charset= !String::needs_conversion(0,charset(),
545+
system_charset_info,
546+
&not_used);
547+
charset_is_collation_connection=
548+
!String::needs_conversion(0,charset(),variables.collation_connection,
549+
&not_used);
546550
}
547551

548552

549-
550-
551553
/* routings to adding tables to list of changed in transaction tables */
552554

553555
inline static void list_include(CHANGED_TABLE_LIST** prev,

0 commit comments

Comments
 (0)