Bug #104642 gbk field converts to gb18030 failed
Submitted: 17 Aug 2021 8:52 Modified: 17 Aug 2021 12:10
Reporter: GONGTUI FU Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.25 OS:Any
Assigned to: CPU Architecture:Any
Tags: gbk gb18030

[17 Aug 2021 8:52] GONGTUI FU
  A table named t has default character set gbk and a column id varchar(100).
  An error occurred when Inserting a hex-value and converting to gb18030.

How to repeat:
mysql> create table t(id varchar(100)) charset=gbk;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t select 0xACBE;
Query OK, 1 row affected (0.01 sec)

mysql> alter table t  convert to character set gb18030;
ERROR 1366 (HY000): Incorrect string value: '\xAC\xBE' for column 'id' at row 1

Suggested fix:
0xACBE is not a valid gbk character, so converting would fail.
Should it fail to insert 0XACBE?
[17 Aug 2021 12:10] MySQL Verification Team
Hi Mr. FU,

Thank you for your bug report.

MySQL does check whether hex representation of the string is valid and permitted for all character sets.

That 2-byte combo does not conform to the rules of the GBK character set.

Hence, try to insert it with actual string values.

Not a bug.