Bug #102672 The executing sample does not match the explanation in Charset Chapter.
Submitted: 21 Feb 2021 0:42 Modified: 23 Feb 2021 12:12
Reporter: Kei SAKAI Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:8.0,5.7,5.6 OS:Any
Assigned to: CPU Architecture:Any

[21 Feb 2021 0:42] Kei SAKAI
Description:
In the chapter 10.5 "Configuring Application Character Set and Collation", executing example is different from the description.

https://dev.mysql.com/doc/refman/8.0/en/charset-errors.html
---
-Binary string values are copied as is for bytes in the range 0x20 to 0x7E, and using \x hexadecimal encoding for bytes outside that range. For example, if a duplicate-key error occurs for an attempt to insert 0x41CF9F into a VARBINARY unique column, the resulting error message uses UTF-8 with some bytes hexadecimal encoded: 
---
    1 Duplicate entry 'A\xC3\x9F' for key 1
---

Description: insert 0x41CF9F 
but Result: 'A\xC3\x9F'

How to repeat:
mysql> CREATE TABLE tv1 (id integer, s varbinary(10) unique not null);
mysql> INSERT INTO tv1 VALUES (1, 0x414243);
mysql> INSERT INTO tv1 VALUES (1, 0x41CF9F);

mysql> SELECT * FROM tv1;
+------+----------+
| id   | s        |
+------+----------+
|    1 | 0x414243 |
|    1 | 0x41CF9F |
+------+----------+
2 rows in set (0.00 sec)

mysql> INSERT INTO tv1 VALUES (1, 0x414243);
ERROR 1062 (23000): Duplicate entry 'ABC' for key 'tv1.s'

mysql> INSERT INTO tv1 VALUES (1, 0x41CF9F);
ERROR 1062 (23000): Duplicate entry 'A\xCF\x9F' for key 'tv1.s'

Suggested fix:
---
    1 Duplicate entry 'A\xCF\x9F' for key 1
---
[21 Feb 2021 9:00] MySQL Verification Team
Hello Sakai-san,

Thank you for the report and feedback.

regards,
Umesh
[23 Feb 2021 12:12] Paul DuBois
Posted by developer:
 
Fixed. Thanks for spotting this!