Skip to content

Added support for additional field Clustered on TiDB #41

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

Merged
merged 1 commit into from
Oct 1, 2021
Merged
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
7 changes: 7 additions & 0 deletions tableparser/tableparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type IndexField struct {
NonUnique bool
Visible string // MySQL 8.0+
Expression sql.NullString // MySQL 8.0.16+
Clustered string // TiDB Support
}

// Constraint holds Foreign Keys information
Expand Down Expand Up @@ -136,7 +137,9 @@ func New(db *sql.DB, schema, tableName string) (*Table, error) {
if err != nil {
return nil, err
}

table.Constraints, err = getConstraints(db, table.Schema, table.Name)

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -295,6 +298,10 @@ func getIndexes(db *sql.DB, schema, tableName string) (map[string]Index, error)
if err == nil && len(cols) >= 15 && cols[14] == "Expression" {
fields = append(fields, &i.Expression)
}
// support for TiDB (Clustered Index)
if err == nil && len(cols) >= 16 && cols[15] == "Clustered" {
fields = append(fields, &i.Clustered)
}

err = rows.Scan(fields...)
if err != nil {
Expand Down