Skip to content

Commit

Permalink
support global index (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
Defined2014 authored Jun 21, 2024
1 parent 202087d commit e7e2efd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
13 changes: 7 additions & 6 deletions framework/mainloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import (
"database/sql"
"encoding/json"
"fmt"
"github.com/PingCAP-QE/schrddl/dump"
"github.com/PingCAP-QE/schrddl/norec"
"github.com/PingCAP-QE/schrddl/reduce"
"github.com/pingcap/tidb/pkg/parser"
"github.com/pingcap/tidb/pkg/util/logutil"
"go.uber.org/zap"
crc322 "hash/crc32"
"math/rand"
"os"
Expand All @@ -22,6 +16,13 @@ import (
"time"
"unsafe"

"github.com/PingCAP-QE/schrddl/dump"
"github.com/PingCAP-QE/schrddl/norec"
"github.com/PingCAP-QE/schrddl/reduce"
"github.com/pingcap/tidb/pkg/parser"
"github.com/pingcap/tidb/pkg/util/logutil"
"go.uber.org/zap"

"github.com/PingCAP-QE/schrddl/sqlgenerator"
"github.com/juju/errors"
"github.com/ngaut/log"
Expand Down
10 changes: 5 additions & 5 deletions sqlgenerator/rule_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ var IndexDefinitionColumn = NewFn(func(state *State) Fn {
tbl := state.env.Table
idx := state.env.Index
partCol := state.env.PartColumn
if partCol != nil && idx.IsUnique() && !idx.Columns.Contain(partCol) {
// Global index supports primary key with non-clustered,
// but we don't decide the index is clustered or not at this time,
// so only check is primary or not here.
if partCol != nil && idx.Tp == IndexTypePrimary && !idx.Columns.Contain(partCol) {
state.env.IdxColumn = partCol
return Or(
IndexDefinitionColumnNoPrefix,
IndexDefinitionColumnPrefix.P(IndexColumnPrefixable),
)
return IndexDefinitionColumnNoPrefix
}
totalCols := tbl.Columns.Filter(func(c *Column) bool {
return !idx.HasColumn(c) && !state.env.MultiObjs.SameObject(c.Name)
Expand Down
3 changes: 1 addition & 2 deletions sqlgenerator/rule_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ var PartitionDefinitionHash = NewFn(func(state *State) Fn {
})

var PartitionDefinitionKey = NewFn(func(state *State) Fn {
partitionedCol := state.env.Table.Columns.Filter(func(c *Column) bool { return c.Tp.IsKeyPartitionType() }).Rand()
state.env.PartColumn = partitionedCol
partitionedCol := state.env.PartColumn
partitionNum := RandomNum(1, 6)
return And(
Str("partition by key ("),
Expand Down

0 comments on commit e7e2efd

Please sign in to comment.