Skip to content

Commit

Permalink
Updated more struct variable names according to reviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjonss committed Jan 5, 2024
1 parent 93c3a6f commit d34e4da
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions pkg/executor/point_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ type PointGetExecutor struct {
tblInfo *model.TableInfo
handle kv.Handle
idxInfo *model.IndexInfo
partition *model.PartitionDefinition
partitionDef *model.PartitionDefinition
idxKey kv.Key
handleVal []byte
idxVals []types.Datum
Expand Down Expand Up @@ -162,7 +162,7 @@ func (e *PointGetExecutor) Init(p *plannercore.PointGetPlan) {
e.lockWaitTime = 0
}
e.rowDecoder = decoder
e.partition = p.Partition
e.partitionDef = p.PartitionDef
e.columns = p.Columns
e.buildVirtualColumnInfo()
}
Expand Down Expand Up @@ -221,8 +221,8 @@ func (e *PointGetExecutor) Next(ctx context.Context, req *chunk.Chunk) error {

var tblID int64
var err error
if e.partition != nil {
tblID = e.partition.ID
if e.partitionDef != nil {
tblID = e.partitionDef.ID
} else {
tblID = e.tblInfo.ID
}
Expand Down Expand Up @@ -510,8 +510,8 @@ func (e *PointGetExecutor) verifyTxnScope() error {
var tblName string
var partName string
is := e.Ctx().GetInfoSchema().(infoschema.InfoSchema)
if e.partition != nil {
tblID = e.partition.ID
if e.partitionDef != nil {
tblID = e.partitionDef.ID
tblInfo, _, partInfo := is.FindTableByPartitionID(tblID)
tblName = tblInfo.Meta().Name.String()
partName = partInfo.Name.String()
Expand Down
4 changes: 2 additions & 2 deletions pkg/planner/core/access_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ func (p *PointGetPlan) AccessObject() AccessObject {
Database: p.dbName,
Table: p.TblInfo.Name.O,
}
if p.Partition != nil {
res.Partitions = []string{p.Partition.Name.O}
if p.PartitionDef != nil {
res.Partitions = []string{p.PartitionDef.Name.O}
}
if p.IndexInfo != nil {
index := IndexAccess{
Expand Down
4 changes: 2 additions & 2 deletions pkg/planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,7 @@ func (ds *DataSource) convertToPointGet(prop *property.PhysicalProperty, candida
if candidate.path.IsIntHandlePath {
pointGetPlan.Handle = kv.IntHandle(candidate.path.Ranges[0].LowVal[0].GetInt64())
pointGetPlan.UnsignedHandle = mysql.HasUnsignedFlag(ds.handleCols.GetCol(0).RetType.GetFlag())
pointGetPlan.Partition = partitionDef
pointGetPlan.PartitionDef = partitionDef
pointGetPlan.accessCols = ds.TblCols
// Add filter condition to table plan now.
if len(candidate.path.TableFilters) > 0 {
Expand All @@ -2350,7 +2350,7 @@ func (ds *DataSource) convertToPointGet(prop *property.PhysicalProperty, candida
pointGetPlan.IdxCols = candidate.path.IdxCols
pointGetPlan.IdxColLens = candidate.path.IdxColLens
pointGetPlan.IndexValues = candidate.path.Ranges[0].LowVal
pointGetPlan.Partition = partitionDef
pointGetPlan.PartitionDef = partitionDef
if candidate.path.IsSingleScan {
pointGetPlan.accessCols = candidate.path.IdxCols
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/plan_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func rebuildRange(p Plan) error {
}
// The code should never run here as long as we're not using point get for partition table.
// And if we change the logic one day, here work as defensive programming to cache the error.
if x.Partition != nil {
if x.PartitionDef != nil {
// TODO: relocate the partition after rebuilding range to make PlanCache support PointGet
return errors.New("point get for partition table can not use plan cache")
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/planner/core/point_get_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type PointGetPlan struct {
schema *expression.Schema
TblInfo *model.TableInfo
IndexInfo *model.IndexInfo
Partition *model.PartitionDefinition
PartitionDef *model.PartitionDefinition
Handle kv.Handle
HandleConstant *expression.Constant
handleFieldType *types.FieldType
Expand Down Expand Up @@ -272,8 +272,8 @@ func (p *PointGetPlan) MemoryUsage() (sum int64) {
if p.schema != nil {
sum += p.schema.MemoryUsage()
}
if p.Partition != nil {
sum += p.Partition.MemoryUsage()
if p.PartitionDef != nil {
sum += p.PartitionDef.MemoryUsage()
}
if p.HandleConstant != nil {
sum += p.HandleConstant.MemoryUsage()
Expand Down Expand Up @@ -658,7 +658,7 @@ func newBatchPointGetPlan(
var handles = make([]kv.Handle, len(patternInExpr.List))
var handleParams = make([]*expression.Constant, len(patternInExpr.List))
var pos2PartitionDefinition = make(map[int]*model.PartitionDefinition)
partitionInfos := make([]*model.PartitionDefinition, 0, len(patternInExpr.List))
partitionDefs := make([]*model.PartitionDefinition, 0, len(patternInExpr.List))
for i, item := range patternInExpr.List {
// SELECT * FROM t WHERE (key) in ((1), (2))
if p, ok := item.(*ast.ParenthesesExpr); ok {
Expand Down Expand Up @@ -711,18 +711,18 @@ func newBatchPointGetPlan(
}
sort.Ints(posArr)
for _, pos := range posArr {
partitionInfos = append(partitionInfos, pos2PartitionDefinition[pos])
partitionDefs = append(partitionDefs, pos2PartitionDefinition[pos])
}
if len(partitionInfos) == 0 {
partitionInfos = nil
if len(partitionDefs) == 0 {
partitionDefs = nil
}
p := &BatchPointGetPlan{
TblInfo: tbl,
Handles: handles,
HandleParams: handleParams,
HandleType: &handleCol.FieldType,
PartitionExpr: partitionExpr,
PartitionDefs: partitionInfos,
PartitionDefs: partitionDefs,
}

return p.Init(ctx, statsInfo, schema, names, 0)
Expand Down Expand Up @@ -1097,7 +1097,7 @@ func tryPointGetPlan(ctx sessionctx.Context, selStmt *ast.SelectStmt, check bool
p.UnsignedHandle = mysql.HasUnsignedFlag(fieldType.GetFlag())
p.handleFieldType = fieldType
p.HandleConstant = handlePair.con
p.Partition = partitionDef
p.PartitionDef = partitionDef
return p
} else if handlePair.value.Kind() != types.KindNull {
return nil
Expand Down Expand Up @@ -1180,8 +1180,8 @@ func checkTblIndexForPointPlan(ctx sessionctx.Context, tblName *ast.TableName, s
p.IndexValues = idxValues
p.IndexConstants = idxConstant
p.ColsFieldType = colsFieldType
p.Partition = partitionDef
if p.Partition != nil {
p.PartitionDef = partitionDef
if p.PartitionDef != nil {
p.partitionColumnPos = findPartitionIdx(idxInfo, pos, pairs)
}
return p
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1820,8 +1820,8 @@ func (cc *clientConn) prefetchPointPlanKeys(ctx context.Context, stmts []ast.Stm
var tableID int64
switch v := p.(type) {
case *plannercore.PointGetPlan:
if v.Partition != nil {
tableID = v.Partition.ID
if v.PartitionDef != nil {
tableID = v.PartitionDef.ID
} else {
tableID = v.TblInfo.ID
}
Expand Down

0 comments on commit d34e4da

Please sign in to comment.