Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fetchIndexesViaSqlDB/NewTableFromSqlDB for MySQL 8.0 #527

Merged
merged 2 commits into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,28 +339,31 @@ func (ta *Table) fetchIndexesViaSqlDB(conn *sql.DB) error {
currentName := ""

var unusedVal interface{}
unused := &unusedVal

for r.Next() {
var indexName, colName string
var noneUnique uint64
var cardinality interface{}

err := r.Scan(
&unused,
&noneUnique,
&indexName,
&unused,
&colName,
&unused,
&cardinality,
&unused,
&unused,
&unused,
&unused,
&unused,
&unused,
)
cols, err := r.Columns()
if err != nil {
return errors.Trace(err)
}
values := make([]interface{}, len(cols))
for i := 0; i < len(cols); i++ {
switch i {
case 1:
values[i] = &noneUnique
case 2:
values[i] = &indexName
case 4:
values[i] = &colName
case 6:
values[i] = &cardinality
default:
values[i] = &unusedVal
}
}
err = r.Scan(values...)
if err != nil {
return errors.Trace(err)
}
Expand Down
3 changes: 2 additions & 1 deletion schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"fmt"
"testing"

. "github.com/pingcap/check"

"github.com/go-mysql-org/go-mysql/client"
_ "github.com/go-mysql-org/go-mysql/driver"
. "github.com/pingcap/check"
)

// use docker mysql for test
Expand Down