Hello,
Alexander Barkov a écrit, Le 01.03.2011 11:24:
> #At file:///home/bar/mysql-bzr/mysql-5.5.b57341/ based on
> revid:tor.didriksen@stripped
>
> 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 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;
I had looked a bit into this bug, and my impression was that the cause
is rather one piece of code (the one printing literals of the SELECT
list, or the one printing AS clauses?), which forgets to convert to the
proper charset.
In other words, if I type
EXPLAIN EXTENDED SELECT 'abcdó', _latin1'abcdó', _utf8'abcdó';
wouldn't the proper solution be to display
Note 1003 select 'abcdó' AS `abcdó`, _latin1'abcdó' AS
`abcdó`, etc?
Isn't the solution chosen in the patch hiding the real bug?