List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:March 1 2011 10:24am
Subject:bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341
Bug#11764503
View as plain text  
#At file:///home/bar/mysql-bzr/mysql-5.5.b57341/ based on revid:tor.didriksen@strippeddgiyyy

 3357 Alexander Barkov	2011-03-01
      Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters
      
        @ mysql-test/r/ctype_latin1.result
        @ mysql-test/r/ctype_utf8.result
        @ mysql-test/t/ctype_latin1.test
        @ mysql-test/t/ctype_utf8.test
        Adding tests
      
        @ sql/mysqld.h
        Adding a new Item::print() mode - QT_EXPLAIN, which
        - displays introducers
        - prints ASCII characters as is
        - prints non-ASCII characters using hex-escape
        Note: as "EXPLAIN" output is only for human readability purposes
        and does not need to be a pasrable SQL, using hex-escape is Ok.
      
        @ sql/item.cc
        Implementing QT_EXPLAIN mode for Item_string::print().
        Note: ErrConvString class perfectly suites for EXPLAIN purposes.
      
        @ sql/sql_parse.cc
        Using new QT_EXPLAIN mode for "EXPLAIN EXTENDED SELECT".

    modified:
      mysql-test/r/ctype_latin1.result
      mysql-test/r/ctype_utf8.result
      mysql-test/t/ctype_latin1.test
      mysql-test/t/ctype_utf8.test
      sql/item.cc
      sql/mysqld.h
      sql/sql_parse.cc
=== modified file 'mysql-test/r/ctype_latin1.result'
--- a/mysql-test/r/ctype_latin1.result	2011-02-10 08:18:08 +0000
+++ b/mysql-test/r/ctype_latin1.result	2011-03-01 10:17:10 +0000
@@ -3246,5 +3246,20 @@ maketime(`a`,`a`,`a`)
 DROP TABLE t1;
 SET sql_mode=default;
 #
+# Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters
+#
+SET NAMES utf8;
+EXPLAIN EXTENDED SELECT 'abcdó', _latin1'abcdó', _utf8'abcdó';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select 'abcdó' AS `abcdó`,_latin1'abcd\xC3\xB3' AS `abcdó`,_utf8'abcd\xC3\xB3' AS `abcdó`
+SET NAMES latin1;
+EXPLAIN EXTENDED SELECT 'abcdó', _latin1'abcdó', _utf8'abcdref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select 'abcdó' AS `abcdó`,_latin1'abcd\xC3\xB3' AS `abcdó`,_utf8'abcd\xC3\xB3' AS `abcd�`
+#
 # End of 5.5 tests
 #

=== modified file 'mysql-test/r/ctype_utf8.result'
--- a/mysql-test/r/ctype_utf8.result	2011-02-10 08:18:08 +0000
+++ b/mysql-test/r/ctype_utf8.result	2011-03-01 10:17:10 +0000
@@ -4969,5 +4969,20 @@ GROUP BY INSERT('', t2.a, t1.a, (@@globa
 ERROR 23000: Duplicate entry '107374182410737418241' for key 'group_key'
 DROP TABLE t1;
 #
+# Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters
+#
+SET NAMES latin1;
+EXPLAIN EXTENDED SELECT 'abcdÁÂÃÄÅ', _latin1'abcdÁÂÃÄÅ', _utf8'abcdÁÂÃÄÅ' AS u;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select 'abcdÁÂÃÄÅ' AS `abcdÁÂÃÄÅ`,_latin1'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `abcdÁÂÃÄÅ`,_utf8'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `u`
+SET NAMES utf8;
+EXPLAIN EXTENDED SELECT 'abcdÁÂÃÄÅ', _latin1'abcdÁÂÃÄÅ', _utf8'abcdÁÂÃÄÅ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select 'abcdÁÂÃÄÅ' AS `abcdÁÂÃÄÅ`,_latin1'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `abcd3\xC3\x84\xC3\x85' AS `abcdÁÂÃÄÅ`
+#
 # End of 5.5 tests
 #

=== modified file 'mysql-test/t/ctype_latin1.test'
--- a/mysql-test/t/ctype_latin1.test	2010-11-18 09:14:27 +0000
+++ b/mysql-test/t/ctype_latin1.test	2011-03-01 10:17:10 +0000
@@ -144,5 +144,20 @@ SELECT '' LIKE '' ESCAPE EXPORT_SET(1, 1
 --source include/ctype_numconv.inc
 
 --echo #
+--echo # Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters
+--echo #
+# Test latin1 client erroneously started with --default-character-set=utf8
+# EXPLAIN output should still be pretty readable.
+# We're using 'ó' (\xC3\xB3) as a magic sequence:
+# - it's "LATIN CAPITAL LETTER A WITH TILDE ABOVE + SUPERSCRIPT 3" in latin1
+# - it's "LATIN SMALL LETTER O WITH ACUTE ABOVE" in utf8.
+SET NAMES utf8;
+EXPLAIN EXTENDED SELECT 'abcdó', _latin1'abcdó', _utf8'abcdó';
+# Test normal latin1
+SET NAMES latin1;
+EXPLAIN EXTENDED SELECT 'abcdó', _latin1'abcdó', _utf8'abcdó';
+
+
+--echo #
 --echo # End of 5.5 tests
 --echo #

=== modified file 'mysql-test/t/ctype_utf8.test'
--- a/mysql-test/t/ctype_utf8.test	2010-12-17 11:11:34 +0000
+++ b/mysql-test/t/ctype_utf8.test	2011-03-01 10:17:10 +0000
@@ -1550,6 +1550,16 @@ SELECT COUNT(*) FROM t1, t1 t2 
 GROUP BY INSERT('', t2.a, t1.a, (@@global.max_binlog_size));
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters
+--echo #
+# Emulate utf8 client erroneously started with --default-character-set=latin1,
+# as in the bug report. EXPLAIN output should still be pretty readable
+SET NAMES latin1;
+EXPLAIN EXTENDED SELECT 'abcdÁÂÃÄÅ', _latin1'abcdÁÂÃÄÅ', _utf8'abcdÁÂÃÄÅ' AS u;
+# Test normal utf8
+SET NAMES utf8;
+EXPLAIN EXTENDED SELECT 'abcdÁÂÃÄÅ', _latin1'abcdÁÂÃÄÅ', _utf8'abcdÁÂÃÄÅ';
 
 --echo #
 --echo # End of 5.5 tests

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-01-12 12:58:47 +0000
+++ b/sql/item.cc	2011-03-01 10:17:10 +0000
@@ -2514,7 +2514,8 @@ my_decimal *Item_float::val_decimal(my_d
 
 void Item_string::print(String *str, enum_query_type query_type)
 {
-  if (query_type == QT_ORDINARY && is_cs_specified())
+  if ((query_type == QT_ORDINARY || query_type == QT_EXPLAIN) &&
+      is_cs_specified())
   {
     str->append('_');
     str->append(collation.collation->csname);
@@ -2522,8 +2523,14 @@ void Item_string::print(String *str, enu
 
   str->append('\'');
 
-  if (query_type == QT_ORDINARY ||
-      my_charset_same(str_value.charset(), system_charset_info))
+  if (query_type == QT_EXPLAIN && is_cs_specified())
+  {
+    /* Print ASCII as is, print extended characters using \xFF sequences */
+    ErrConvString tmp(str_value.ptr(), str_value.length(), &my_charset_bin);
+    str->append(tmp.ptr());
+  }
+  else if (query_type == QT_ORDINARY ||
+           my_charset_same(str_value.charset(), system_charset_info))
   {
     str_value.print(str);
   }

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2011-01-14 13:21:46 +0000
+++ b/sql/mysqld.h	2011-03-01 10:17:10 +0000
@@ -404,11 +404,14 @@ enum options_mysqld
   QT_ORDINARY -- ordinary SQL query.
   QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
   character set introducers).
+  QT_EXPLAIN -- SQL query to be shown in EXPLAIN SELECT EXTENDED (with
+  introducers and \xFF escape sequences for extended characters)
 */
 enum enum_query_type
 {
   QT_ORDINARY,
-  QT_IS
+  QT_IS,
+  QT_EXPLAIN
 };
 
 /* query_id */

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-02-18 13:24:03 +0000
+++ b/sql/sql_parse.cc	2011-03-01 10:17:10 +0000
@@ -4439,7 +4439,7 @@ static bool execute_sqlcom_select(THD *t
         char buff[1024];
         String str(buff,(uint32) sizeof(buff), system_charset_info);
         str.length(0);
-        thd->lex->unit.print(&str, QT_ORDINARY);
+        thd->lex->unit.print(&str, QT_EXPLAIN);
         str.append('\0');
         push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
                      ER_YES, str.ptr());

Attachment: [text/bzr-bundle] bzr/alexander.barkov@oracle.com-20110301101710-mj73b9f3sj96kvhu.bundle
Thread
bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Alexander Barkov1 Mar
  • Re: bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Guilhem Bichot1 Mar
    • Re: bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Alexander Barkov1 Mar
      • Re: bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Guilhem Bichot2 Mar
        • Re: bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Alexander Barkov3 Mar
  • Re: bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Guilhem Bichot3 Mar
    • Re: bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Alexander Barkov4 Mar
      • Re: bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Guilhem Bichot4 Mar
        • Re: bzr commit into mysql-5.5 branch (alexander.barkov:3357) Bug#57341Bug#11764503Alexander Barkov4 Mar