Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12681

Wrong VIEW results for CHAR(0xDF USING latin1)

    Details

      Description

      In Linux console, I run

      SET NAMES utf8;
      SELECT CHAR(0xDF USING latin1);
      

      +-------------------------+
      | CHAR(0xDF USING latin1) |
      +-------------------------+
      | ß                       |
      +-------------------------+
      

      Notice, it correctly returned LATIN SMALL LETTER SHARP S.

      Now I put the same expression into a view and query the view:

      CREATE OR REPLACE VIEW v1 AS SELECT CHAR(0xDF USING latin1) AS c;
      SELECT * FROM v1;
      

      +---+
      | c |
      +---+
      | �  |
      +---+
      

      Notice, it returned some garbage (Linux console changed garbage to U+FFFD REPLACEMENT CHARACTER).
      Looks wrong. The expected result is to return the same SHARP S character.

      The problem is that Item_func_char::print() does not display the USING clause:

      SHOW CREATE VIEW v1;
      

      +------+------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
      | View | Create View                                                                                                      | character_set_client | collation_connection |
      +------+------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
      | v1   | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select char(0xdf) AS `c` | utf8                 | utf8_general_ci      |
      +------+------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
      

      Notice, it prints:

      char(0xdf)
      

      It should print:

      char(0xdf using latin1)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: