Skip to content

The function upper produces error for some special characters #32488

@lcwangchao

Description

@lcwangchao

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

With new_collation_enabled is True

create table t(a varchar(32)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
insert into t values('ʞ');
select binary upper('ʞ');
select binary upper(a) from t;
select distinct upper(a) from t; 

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

mysql> select binary upper('ʞ');
+----------------------------------------+
| binary upper('ʞ')                      |
+----------------------------------------+
| 0xEA9EB0                               |
+----------------------------------------+
1 row in set (0.03 sec)

mysql>  select binary upper(a) from t;
+----------------------------------+
| binary upper(a)                  |
+----------------------------------+
| 0xEA9EB0                         |
+----------------------------------+
1 row in set (0.03 sec)

mysql> select distinct upper(a) from t;
+----------+
| upper(a) |
+----------+
| Ʞ        |
+----------+
1 row in set (1.76 sec)

3. What did you see instead (Required)

mysql> select binary upper('ʞ');
+----------------------------------------+
| binary upper('ʞ')                      |
+----------------------------------------+
| 0xEA9EB0                               |
+----------------------------------------+
1 row in set (0.03 sec)

mysql>  select binary upper(a) from t;
+----------------------------------+
| binary upper(a)                  |
+----------------------------------+
| 0xEA9E                           |
+----------------------------------+
1 row in set (0.03 sec)

mysql> select distinct upper(a) from t;
ERROR 1105 (HY000): runtime error: index out of range [2] with length 2

4. What is your TiDB version? (Required)

master. But I think it effects all tidb versions

mysql> SELECT tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: None
Edition: Community
Git Commit Hash: None
Git Branch: None
UTC Build Time: None
GoVersion: go1.16.3
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.03 sec)

Metadata

Metadata

Assignees

Labels

affects-5.0This bug affects 5.0.x versions.affects-5.1This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.affects-5.4This bug affects the 5.4.x(LTS) versions.may-affects-4.0This bug maybe affects 4.0.x versions.severity/majorsig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions