pingcap / pingcap/tidb

column type of query result is not same with MySQL

Open
#34,508 0 comments 0 reactions 0 assignees View on GitHub
compatibility-mysql80
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Reproduce

```go

import (
"database/sql"
"fmt"

_ "github.com/go-sql-driver/mysql"
)

func main() {
dbDSN := fmt.Sprintf("root:%s@tcp(%s)/test", "", "127.0.0.1:4000")
db, err := sql.Open("mysql", dbDSN)
if err != nil {
panic(err)
}
db.Exec("create table if not exists t (a MEDIUMTEXT)")
rows, err := db.Query("select a from t")
if err != nil {
panic(err)
}
defer rows.Close()
tps, err := rows.ColumnTypes()
if err != nil {
panic(err)
}
for _, tp := range tps {
fmt.Printf("column: %v, type: %v \n", tp.Name(), tp.DatabaseTypeName())
}
}
```

**TiDB Output**

```shell
column: a, type: MEDIUMTEXT
```

**MySQL Output**

```shell
column: a, type: TEXT
```

TiDB version:

```sql
>select tidb_version()\G
***************************[ 1. row ]***************************
tidb_version() | Release Version: v6.1.0-alpha-360-gab26a287dc
Edition: Community
Git Commit Hash: ab26a287dcbe4186d327cfcaa74bf945db83a338
Git Branch: master
UTC Build Time: 2022-05-10 01:36:13
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```

MySQL version:

```sql
>select version();
+-----------+
| version() |
+-----------+
| 8.0.29 |
+-----------+
```

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.