diff --git a/pkg/executor/point_get.go b/pkg/executor/point_get.go index cc2a51afb71d4..4250f15a8c47a 100644 --- a/pkg/executor/point_get.go +++ b/pkg/executor/point_get.go @@ -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 @@ -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() } @@ -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 } @@ -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() diff --git a/pkg/planner/core/access_object.go b/pkg/planner/core/access_object.go index bfb953b929147..162e321643771 100644 --- a/pkg/planner/core/access_object.go +++ b/pkg/planner/core/access_object.go @@ -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{ diff --git a/pkg/planner/core/find_best_task.go b/pkg/planner/core/find_best_task.go index bbabf95484c4f..7516c037610b5 100644 --- a/pkg/planner/core/find_best_task.go +++ b/pkg/planner/core/find_best_task.go @@ -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 { @@ -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 { diff --git a/pkg/planner/core/plan_cache.go b/pkg/planner/core/plan_cache.go index d7e779c7e3af0..a0c9c251dd3ba 100644 --- a/pkg/planner/core/plan_cache.go +++ b/pkg/planner/core/plan_cache.go @@ -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") } diff --git a/pkg/planner/core/point_get_plan.go b/pkg/planner/core/point_get_plan.go index f78cd8c310e50..658a9aa8b2e2a 100644 --- a/pkg/planner/core/point_get_plan.go +++ b/pkg/planner/core/point_get_plan.go @@ -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 @@ -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() @@ -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 { @@ -711,10 +711,10 @@ 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, @@ -722,7 +722,7 @@ func newBatchPointGetPlan( HandleParams: handleParams, HandleType: &handleCol.FieldType, PartitionExpr: partitionExpr, - PartitionDefs: partitionInfos, + PartitionDefs: partitionDefs, } return p.Init(ctx, statsInfo, schema, names, 0) @@ -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 @@ -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 diff --git a/pkg/server/conn.go b/pkg/server/conn.go index 38c61b31083a0..2d29c6fd800fb 100644 --- a/pkg/server/conn.go +++ b/pkg/server/conn.go @@ -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 }