Skip to content

add scheme/Index NoneUnique #610

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 2 commits into from
Aug 16, 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
8 changes: 6 additions & 2 deletions schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Index struct {
Name string
Columns []string
Cardinality []uint64
NoneUnique uint64
}

type Table struct {
Expand Down Expand Up @@ -190,7 +191,7 @@ func (ta *Table) AddIndex(name string) (index *Index) {
}

func NewIndex(name string) *Index {
return &Index{name, make([]string, 0, 8), make([]uint64, 0, 8)}
return &Index{name, make([]string, 0, 8), make([]uint64, 0, 8), 0}
}

func (idx *Index) AddColumn(name string, cardinality uint64) {
Expand Down Expand Up @@ -317,6 +318,7 @@ func (ta *Table) fetchIndexes(conn mysql.Executer) error {
cardinality, _ := r.GetUint(i, 6)
colName, _ := r.GetString(i, 4)
currentIndex.AddColumn(colName, cardinality)
currentIndex.NoneUnique, _ = r.GetUint(i, 1)
}

return ta.fetchPrimaryKeyColumns()
Expand All @@ -338,11 +340,12 @@ func (ta *Table) fetchIndexesViaSqlDB(conn *sql.DB) error {

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

err := r.Scan(
&unused,
&unused,
&noneUnique,
&indexName,
&unused,
&colName,
Expand All @@ -366,6 +369,7 @@ func (ta *Table) fetchIndexesViaSqlDB(conn *sql.DB) error {

c := toUint64(cardinality)
currentIndex.AddColumn(colName, c)
currentIndex.NoneUnique = noneUnique
}

return ta.fetchPrimaryKeyColumns()
Expand Down