[MDEV-19059] Misleading ER_INVALID_CHARACTER_STRING message for DDL statements Created: 2019-03-27  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: Character Sets, Data Definition - Alter Table, Data Definition - Create Table
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: character-set, error


 Description   

The system_charset_info that MariaDB uses for schema object names (such as tables, indexes and columns) only supports the Basic Multilingual Plane (Unicode code points below U+10000), that is, at most 3 bytes per character.

In MariaDB 10.0 and 10.1, the test innodb.innodb-alter returns the following error message to 4-byte UTF-8 data:

ERROR HY000: Invalid utf8 character string: '\xF0\x9F\x98\xB2'

This is somewhat misleading, because the quoted byte sequence is valid UTF-8. We could still claim that utf8 is an alias to utf8mb3 and say that this is not an error.

However, starting with MariaDB 10.2, the error message is unambiguously misleading:

ERROR HY000: Invalid utf8mb4 character string: '\xF0\x9F\x98\xB2'

The 4-byte sequence is pretty much valid in utf8mb4. The error message should convey the correct meaning that while this sequence is valid utf8mb4, only utf8mb3 is valid for a schema object name.

At the very least we should change the utf8mb4 to utf8mb3. It would be better to say something like ‘invalid schema object name’.

Unfortunately, I cannot quote the exact statement that produces the above error, because Jira does not allow 4-byte UTF-8 data. Here is a stand-alone test case that works around the Jira limitation:

SET NAMES utf8mb4;
CREATE TEMPORARY TABLE t1 (c3 INT);
--error ER_INVALID_CHARACTER_STRING
EXECUTE IMMEDIATE CONCAT('ALTER TABLE t1 CHANGE c3 ',_utf8mb4 0xF09F98B2,' INT');

This will return the same misleading error message that is returned for the statement in innodb.innodb-alter:

10.2 c676f58c270d75b6c1889b24b9833afc65b0d98b

ERROR HY000: Invalid utf8mb4 character string: '\xF0\x9F\x98\xB2'


Generated at Thu Feb 08 08:48:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.