From f4733ad3dd2311cd62a85c1d77f49492aac44d0f Mon Sep 17 00:00:00 2001 From: wangyinliang Date: Thu, 12 Aug 2021 18:04:47 +0800 Subject: [PATCH 1/2] add scheme/Index NoneUnique --- schema/schema.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/schema/schema.go b/schema/schema.go index 68448f6e3..8f7407233 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -56,6 +56,7 @@ type Index struct { Name string Columns []string Cardinality []uint64 + NoneUnique uint64 } type Table struct { @@ -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) { @@ -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() From 39cf8feae3e1289971296eac64a73bc4a209802f Mon Sep 17 00:00:00 2001 From: wangyinliang Date: Thu, 12 Aug 2021 18:13:43 +0800 Subject: [PATCH 2/2] add scheme/Index NoneUnique --- schema/schema.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/schema/schema.go b/schema/schema.go index 8f7407233..20039a209 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -340,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, @@ -368,6 +369,7 @@ func (ta *Table) fetchIndexesViaSqlDB(conn *sql.DB) error { c := toUint64(cardinality) currentIndex.AddColumn(colName, c) + currentIndex.NoneUnique = noneUnique } return ta.fetchPrimaryKeyColumns()