Not able to insert arbitrary binary data / invalid UTF8 characters into a VARCHAR column
We have a VARCHAR(255) column using collation utf8_unicode_ci in a table.
We can write arbitrary byte sequences (data that contains invalid UTF8 character sequences) using INSERT or UPDATE statements in MySQL 5.7.43. However, we get errors while performing the same actions with the same configurations (character set utf8mb3 collate utf8mb3_unicode_ci) in MySQL 8.0.33.
For example, I’ve tried the following
INSERT INTO data_tests (data) VALUES (0xED\xA0\xBC\xED\xB7\xA9\xED\xA0\xBC\xED\xB7\xAA);
In MySQL 5.7.43, the arbitrary byte sequences is written into the table successfully:
Query OK, 1 row affected (0.01 sec)
In MySQL 8.0.33, I get the following error:
ERROR 1366 (HY000): Incorrect string value: '\xED\xA0\xBC\xED\xB7\xA9...' for column 'data' at row 1
I also tried CONVERT( … USING UTF8) or BINARY( … ), but neither of them are working in MySQL 8.0.33.
How can I write an INSERT or UPDATE statement that bypasses the check/validation, allowing me to write arbitrary byte sequences in MySQL 8.0.33?
Subject
Views
Written By
Posted
Not able to insert arbitrary binary data / invalid UTF8 characters into a VARCHAR column
787
August 15, 2023 07:46PM
243
January 15, 2024 03:40AM
Sorry, only registered users may post in this forum.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.