pingcap / pingcap/tidb

Charset of parameters is incompatible with MySQL in `PREPARE` stage

Open
#46,059 0 comments 0 reactions 1 assignee Claimed by @YangKeao View on GitHub
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

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.