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

Malformed strings are accepted as column names when SET NAMES binary

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 5.5.39, 10.0.13, 11.8
    • 10.11, 11.4
    • None
    • None

    Description

      Run an new iso-8859-1 terminal window.
      For example, in gnome-terminal, do:
      Terminal -> Set character encoding -> Western (ISO-8859-1)

      Execute this command:

      LANG=de_DE.iso88591 ; mysql test <<END
      SET NAMES binary;
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 AS SELECT 'aaaßßß';
      END
      

      Now run a new UTF8 terminal window.
      For example, in gnome-terminal, do:
      Terminal -> Set character encoding -> Unicode (UTF-8)

      Execute this command:

      mysql --table test << END
      SET NAMES utf8;
      SHOW CREATE TABLE t1;
      END
      

      The output is incorrect:

      +-------+---------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                            |
      +-------+---------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `aaa��� ` varbinary(6) NOT NULL DEFAULT ''
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1    |
      +-------+---------------------------------------------------------------------------------------------------------+
      

      Notice, the column name after 'aaa' has replacement characters,
      which are printed for invalid sequences.

      The desired behavior would be to report an error at CREATE TABLE,
      as the supplied name is not a valid UTF-8 string.

      More examples

      This script inserts a wrong value:

      CREATE OR REPLACE TABLE t1 (a TEXT CHARACTER SET utf8mb3);
      INSERT INTO t1 VALUES (0xEDA080);
      SELECT HEX(a) FROM t1;
      

      +--------+
      | HEX(a) |
      +--------+
      | EDA080 |
      +--------+
      

      so does this:

      CREATE OR REPLACE TABLE t1 (a TEXT CHARACTER SET utf8mb3);
      EXECUTE IMMEDIATE CONCAT('INSERT INTO t1 VALUES (''', 0xEDA080,''')');
      SELECT HEX(a) FROM t1;
      

      +--------+
      | HEX(a) |
      +--------+
      | EDA080 |
      +--------+
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.