Skip to content

builtin func char() has different result between MySQL when value is illegal UTF8 character #29685

@Defined2014

Description

@Defined2014

Bug Report

builtin func char() has different result between MySQL when value is illegal UTF8 character

1. Minimal reproduce step (Required)

select char(123456 using utf8);
show warnings;

2. What did you expect to see? (Required)

mysql> select char(123456 using utf8);
+-------------------------+
| char(123456 using utf8) |
+-------------------------+
| NULL                    |
+-------------------------+
1 row in set, 2 warnings (0.00 sec)
mysql> show warnings;
+---------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                                                                     |
+---------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 3719 | 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |
| Warning | 1300 | Invalid utf8mb3 character string: 'E240'                                                                                                                                    |
+---------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

3. What did you see instead (Required)

mysql> select char(123456 using utf8);
+-------------------------+
| char(123456 using utf8) |
+-------------------------+
| �@                      |
+-------------------------+
1 row in set (0.01 sec)
mysql> show warnings;
Empty set (0.00 sec)

4. What is your TiDB version? (Required)

mysql> SELECT tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                             |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.2.0-alpha-2186-g2bdebedfc
Edition: Community
Git Commit Hash: 2bdebedfc042e340c7826d0ac96f635f3949a8b3
Git Branch: master
UTC Build Time: 2021-11-11 05:47:41
GoVersion: go1.16.6
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions