diff --git a/mysql-test/r/ctype_swe7.result b/mysql-test/r/ctype_swe7.result index 9c1c06fbb32..ccab77c21d1 100644 --- a/mysql-test/r/ctype_swe7.result +++ b/mysql-test/r/ctype_swe7.result @@ -1,12 +1,13 @@ # # Start of 10.0 tests # +SET NAMES swe7; # Start of ctype_unescape.inc SET @query=_binary'SELECT CHARSET(\'test\'),@@character_set_client,@@character_set_connection'; PREPARE stmt FROM @query; EXECUTE stmt; CHARSET('test') @@character_set_client @@character_set_connection -latin1 latin1 latin1 +swe7 swe7 swe7 DEALLOCATE PREPARE stmt; CREATE TABLE allbytes (a VARBINARY(10)); # Using selected bytes combinations @@ -73,7 +74,7 @@ CALL p1(val); END LOOP; CLOSE stmt; END// -CREATE FUNCTION iswellformed(a VARBINARY(256)) RETURNS INT RETURN a=BINARY CONVERT(a USING latin1);// +CREATE FUNCTION iswellformed(a VARBINARY(256)) RETURNS INT RETURN a=BINARY CONVERT(a USING swe7);// CREATE FUNCTION unescape(a VARBINARY(256)) RETURNS VARBINARY(256) BEGIN # We need to do it in a way to avoid producing new escape sequences diff --git a/mysql-test/t/ctype_swe7.test b/mysql-test/t/ctype_swe7.test index d3f3d861d0f..7d1ef89b374 100644 --- a/mysql-test/t/ctype_swe7.test +++ b/mysql-test/t/ctype_swe7.test @@ -2,6 +2,15 @@ --echo # Start of 10.0 tests --echo # +SET NAMES swe7; + +# +# Test escape sequences. +# This also covers: +# MDEV-6737 Stored routines do now work with swe7: "The table mysql.proc is missing, corrupt, or contains bad data" +# as uses stored functions actively. +# + let $ctype_unescape_combinations=selected; --source include/ctype_unescape.inc diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b2cfab1b768..87cec1ce2ae 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1321,9 +1321,22 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) it's a keyword */ + /* + Special code for swe7. It encodes the letter "E WITH ACUTE" on + the position 0x60, where backtick normally resides. + In swe7 we cannot append 0x60 using system_charset_info, + because it cannot be converted to swe7 and will be replaced to + question mark '?'. Use &my_charset_bin to avoid this. + It will prevent conversion and will append the backtick as is. + */ + CHARSET_INFO *quote_charset= q == 0x60 && + (packet->charset()->state & MY_CS_NONASCII) && + packet->charset()->mbmaxlen == 1 ? + &my_charset_bin : system_charset_info; + (void) packet->reserve(length*2 + 2); quote_char= (char) q; - if (packet->append("e_char, 1, system_charset_info)) + if (packet->append("e_char, 1, quote_charset)) return true; for (name_end= name+length ; name < name_end ; name+= length) @@ -1340,12 +1353,12 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) if (!length) length= 1; if (length == 1 && chr == (uchar) quote_char && - packet->append("e_char, 1, system_charset_info)) + packet->append("e_char, 1, quote_charset)) return true; if (packet->append(name, length, system_charset_info)) return true; } - return packet->append("e_char, 1, system_charset_info); + return packet->append("e_char, 1, quote_charset); }