Skip to content

Commit 331504c

Browse files
Merge pull request #41 from adamotonete/tidb_support
Added support for additional field Clustered on TiDB
2 parents d745f3a + 2ba9de3 commit 331504c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tableparser/tableparser.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type IndexField struct {
7070
NonUnique bool
7171
Visible string // MySQL 8.0+
7272
Expression sql.NullString // MySQL 8.0.16+
73+
Clustered string // TiDB Support
7374
}
7475

7576
// Constraint holds Foreign Keys information
@@ -136,7 +137,9 @@ func New(db *sql.DB, schema, tableName string) (*Table, error) {
136137
if err != nil {
137138
return nil, err
138139
}
140+
139141
table.Constraints, err = getConstraints(db, table.Schema, table.Name)
142+
140143
if err != nil {
141144
return nil, err
142145
}
@@ -295,6 +298,10 @@ func getIndexes(db *sql.DB, schema, tableName string) (map[string]Index, error)
295298
if err == nil && len(cols) >= 15 && cols[14] == "Expression" {
296299
fields = append(fields, &i.Expression)
297300
}
301+
// support for TiDB (Clustered Index)
302+
if err == nil && len(cols) >= 16 && cols[15] == "Clustered" {
303+
fields = append(fields, &i.Clustered)
304+
}
298305

299306
err = rows.Scan(fields...)
300307
if err != nil {

0 commit comments

Comments
 (0)