[MDEV-6558] Malformed strings are accepted as column names when SET NAMES binary Created: 2014-08-11  Updated: 2022-09-08

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.39, 10.0.13
Fix Version/s: 5.5

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: 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.


Generated at Thu Feb 08 07:12:50 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.