We're updating the issue view to help you get more done. 

INFORMATION_SCHEMA.ROUTINES.ROUTINE_DEFINITION does not handle binary literals well

Description

  • I run a terminal using koi8-r character set.
    In case of gnome-terminal, do "Terminal >Set Character Encoding>Cyrillic(KOI8-R)

  • Start mysql like this:

    1 LANG=ru_RU.koi8r mysql -uroot test
  • And create a stored function returning a binary string

    1 2 3 DROP FUNCTION IF EXISTS f1; CREATE FUNCTION f1() RETURNS BINARY RETURN (SELECT _binary'яп╠' AS я); SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME='f1';

This SQL script returns:

1 2 3 4 5 +----------------------------+ | ROUTINE_DEFINITION | +----------------------------+ | RETURN (SELECT '???' AS я) | +----------------------------+

Note, if I now run a new terminal using utf8 as a character set and run this query:

1 SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME='f1';

it returns

1 2 3 4 5 +--------------------------------+ | ROUTINE_DEFINITION | +--------------------------------+ | RETURN (SELECT 'Ñб' AS я) | +--------------------------------+

The expected result would be to replace the literal to X'HHHH' notation.

Environment

None

Status

Assignee

Alexander Barkov

Reporter

Alexander Barkov

Labels

None

External issue ID

None

External issue ID

None

Affects versions

10.0
10.1
10.2
5.5

Priority

Major