pingcap / pingcap/tidb

I_S query with explicit collation fails

Open
#46,288 1 comment 0 reactions 0 assignees View on GitHub
severity/minor sig/sql-infra type/bug type/compatibility
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

When running information_schema queries with explicit collations TiDB returns errors that MySQL does not.

### 1. Minimal reproduce step (Required)

```
SELECT schema_name FROM information_schema.schemata WHERE schema_name COLLATE utf8_general_ci = 'mysql';
SHOW SESSION VARIABLES LIKE 'character\_set\_%';
```

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

```
sql> SELECT schema_name FROM information_schema.schemata WHERE schema_name COLLATE utf8_general_ci = 'mysql';
+-------------+
| SCHEMA_NAME |
+-------------+
| mysql |
+-------------+
1 row in set (0.0021 sec)

sql> SHOW SESSION VARIABLES LIKE 'character\_set\_%';
+--------------------------+---------+
| Variable_name | Value |
+--------------------------+---------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8mb3 |
+--------------------------+---------+
7 rows in set (0.0044 sec)
```

### 3. What did you see instead (Required)

```
sql> SELECT schema_name FROM information_schema.schemata WHERE schema_name COLLATE utf8_general_ci = 'mysql';
ERROR: 1253 (42000): COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'utf8mb4'

sql> SHOW SESSION VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------------------------------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.6.25-osx10.8-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.0014 sec)
```

### 4. What is your TiDB version? (Required)

```
sql> SELECT TIDB_VERSION()\G
*************************** 1. row ***************************
TIDB_VERSION(): Release Version: v7.3.0
Edition: Community
Git Commit Hash: 40b72e7a9a4fc9670d4c5d974dd503a3c6097471
Git Branch: heads/refs/tags/v7.3.0
UTC Build Time: 2023-08-08 10:08:14
GoVersion: go1.20.7
Race Enabled: false
Check Table Before Drop: false
Store: tikv
1 row in set (0.0012 sec)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.