Charset of parameters is incompatible with MySQL in `PREPARE` stage
Open
severity/moderate
sig/sql-infra
type/bug
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
The following go code may fail on TiDB, but success in MySQL (by default):
```
db.Query("SELECT WEIGHT_STRING(? collate utf8mb4_general_ci)", fmt.Sprintf("%c", rune(i)))
```
It'll report the following error:
```
panic: Error 1253 (42000): COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'binary'
```
A workaround is to convert the `?` to `utf8mb4` explicitly:
```
db.Query("SELECT WEIGHT_STRING(CONVERT(? USING utf8mb4) collate utf8mb4_general_ci)", fmt.Sprintf("%c", rune(i)))
```
Contributor guide
Assessment
This issue has not been assessed yet.