@@ -56,6 +56,7 @@ type Index struct {
56
56
Name string
57
57
Columns []string
58
58
Cardinality []uint64
59
+ NoneUnique uint64
59
60
}
60
61
61
62
type Table struct {
@@ -190,7 +191,7 @@ func (ta *Table) AddIndex(name string) (index *Index) {
190
191
}
191
192
192
193
func NewIndex (name string ) * Index {
193
- return & Index {name , make ([]string , 0 , 8 ), make ([]uint64 , 0 , 8 )}
194
+ return & Index {name , make ([]string , 0 , 8 ), make ([]uint64 , 0 , 8 ), 0 }
194
195
}
195
196
196
197
func (idx * Index ) AddColumn (name string , cardinality uint64 ) {
@@ -317,6 +318,7 @@ func (ta *Table) fetchIndexes(conn mysql.Executer) error {
317
318
cardinality , _ := r .GetUint (i , 6 )
318
319
colName , _ := r .GetString (i , 4 )
319
320
currentIndex .AddColumn (colName , cardinality )
321
+ currentIndex .NoneUnique , _ = r .GetUint (i , 1 )
320
322
}
321
323
322
324
return ta .fetchPrimaryKeyColumns ()
@@ -338,11 +340,12 @@ func (ta *Table) fetchIndexesViaSqlDB(conn *sql.DB) error {
338
340
339
341
for r .Next () {
340
342
var indexName , colName string
343
+ var noneUnique uint64
341
344
var cardinality interface {}
342
345
343
346
err := r .Scan (
344
347
& unused ,
345
- & unused ,
348
+ & noneUnique ,
346
349
& indexName ,
347
350
& unused ,
348
351
& colName ,
@@ -366,6 +369,7 @@ func (ta *Table) fetchIndexesViaSqlDB(conn *sql.DB) error {
366
369
367
370
c := toUint64 (cardinality )
368
371
currentIndex .AddColumn (colName , c )
372
+ currentIndex .NoneUnique = noneUnique
369
373
}
370
374
371
375
return ta .fetchPrimaryKeyColumns ()
0 commit comments