Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
5.3.12, 5.5.39, 10.0.14
-
None
Description
I create a database with some question marks in the name:
DROP DATABASE IF EXISTS `test????`; |
CREATE DATABASE `test????`; |
Now I run a "USE" query with a bad byte sequence:
SET NAMES utf8; |
USE `test��`; |
SELECT DATABASE(), HEX(DATABASE()); |
(notice. '��' is a four-byte UTF-8 character, which is considered as a wrong
byte sequence by MariaDB's 3-byte "utf8").
It erroneously connects to the database 'test????':
ariaDB [(none)]> SET NAMES utf8;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [(none)]> USE `test��`;
|
Database changed
|
MariaDB [test��]> SELECT DATABASE(), HEX(DATABASE());
|
+------------+------------------+
|
| DATABASE() | HEX(DATABASE()) |
|
+------------+------------------+
|
| test???? | 746573743F3F3F3F |
|
+------------+------------------+
|
1 row in set (0.00 sec)
|
The correct behaviour would be report either "unknown database",
or "bad database name" or "Invalid utf8 character string: 'test\xF0\x9F\x98\x81'".
The latter would be consistent with what's reported on attempt to
create a database with such a broken name:
MariaDB [test]> CREATE DATABASE `test��`;
|
ERROR 1300 (HY000): Invalid utf8 character string: 'test\xF0\x9F\x98\x81'
|
A similar problem also happens with table names.
I create a table with question marks in its name:
SET NAMES utf8; |
DROP TABLE IF EXISTS `test????`; |
CREATE TABLE `test????` (a INT); |
INSERT INTO `test????` values (10); |
Now I change the connection character set to utf8mb4 and run a SELECT query:
SET NAMES utf8mb4; |
SELECT * FROM `test��������`; |
It returns rows from the table `test????`:
+------+
|
| a |
|
+------+
|
| 10 |
|
+------+
|
1 row in set (0.01 sec)
|
The expected behaviour would be to return some error.
Attachments
Issue Links
- is blocked by
-
MDEV-6566 Different INSERT behaviour on bad bytes with and without character set conversion
- Closed