Skip to content

Commit

Permalink
Removed renaming of variables due to pingcap#49989
Browse files Browse the repository at this point in the history
  • Loading branch information
mjonss committed Jan 2, 2024
1 parent 342bb1b commit b012bdb
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 45 deletions.
6 changes: 3 additions & 3 deletions pkg/ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5645,7 +5645,7 @@ func GetModifiableColumnJob(
newCol.FieldType.GetCharset() != col.FieldType.GetCharset() {
return nil, dbterror.ErrUnsupportedModifyColumn.GenWithStackByArgs("can't change the partitioning column, since it would require reorganize all partitions")
}
// Generate a new PhysPlanPartitionInfo and validate it together with the new column definition
// Generate a new PartitionInfo and validate it together with the new column definition
// Checks if all partition definition values are compatible.
// Similar to what buildRangePartitionDefinitions would do in terms of checks.

Expand All @@ -5671,11 +5671,11 @@ func GetModifiableColumnJob(
stmt, _, err := parser.New().ParseSQL("ALTER TABLE t " + buf.String())
if err != nil {
// Should never happen!
return nil, dbterror.ErrUnsupportedModifyColumn.GenWithStack("cannot parse generated PhysPlanPartitionInfo")
return nil, dbterror.ErrUnsupportedModifyColumn.GenWithStack("cannot parse generated PartitionInfo")
}
at, ok := stmt[0].(*ast.AlterTableStmt)
if !ok || len(at.Specs) != 1 || at.Specs[0].Partition == nil {
return nil, dbterror.ErrUnsupportedModifyColumn.GenWithStack("cannot parse generated PhysPlanPartitionInfo")
return nil, dbterror.ErrUnsupportedModifyColumn.GenWithStack("cannot parse generated PartitionInfo")
}
pAst := at.Specs[0].Partition
sv := sctx.GetSessionVars().StmtCtx
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -4232,7 +4232,7 @@ func writeColumnListToBuffer(partitionInfo *model.PartitionInfo, sqlMode mysql.S
}

// AppendPartitionInfo is used in SHOW CREATE TABLE as well as generation the SQL syntax
// for the PhysPlanPartitionInfo during validation of various DDL commands
// for the PartitionInfo during validation of various DDL commands
func AppendPartitionInfo(partitionInfo *model.PartitionInfo, buf *bytes.Buffer, sqlMode mysql.SQLMode) {
if partitionInfo == nil {
return
Expand Down
8 changes: 4 additions & 4 deletions pkg/executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3453,7 +3453,7 @@ func (b *executorBuilder) buildTableReader(v *plannercore.PhysicalTableReader) e

tmp, _ := b.is.TableByID(ts.Table.ID)
tbl := tmp.(table.PartitionedTable)
partitions, err := partitionPruning(b.ctx, tbl, v.PhysPlanPartitionInfo.PruningConds, v.PhysPlanPartitionInfo.PartitionNames, v.PhysPlanPartitionInfo.Columns, v.PhysPlanPartitionInfo.ColumnNames)
partitions, err := partitionPruning(b.ctx, tbl, v.PartitionInfo.PruningConds, v.PartitionInfo.PartitionNames, v.PartitionInfo.Columns, v.PartitionInfo.ColumnNames)
if err != nil {
b.err = err
return nil
Expand Down Expand Up @@ -3539,7 +3539,7 @@ func getPartitionKeyColOffsets(keyColIDs []int64, pt table.PartitionedTable) []i
return keyColOffsets
}

func (builder *dataReaderBuilder) prunePartitionForInnerExecutor(tbl table.Table, partitionInfo *plannercore.PhysPlanPartitionInfo,
func (builder *dataReaderBuilder) prunePartitionForInnerExecutor(tbl table.Table, partitionInfo *plannercore.PartitionInfo,
lookUpContent []*indexJoinLookUpContent) (usedPartition []table.PhysicalTable, canPrune bool, contentPos []int64, err error) {
partitionTbl := tbl.(table.PartitionedTable)

Expand Down Expand Up @@ -4163,7 +4163,7 @@ func (builder *dataReaderBuilder) buildTableReaderForIndexJoin(ctx context.Conte
}
tbl, _ := builder.is.TableByID(tbInfo.ID)
pt := tbl.(table.PartitionedTable)
partitionInfo := &v.PhysPlanPartitionInfo
partitionInfo := &v.PartitionInfo
usedPartitionList, err := builder.partitionPruning(pt, partitionInfo.PruningConds, partitionInfo.PartitionNames, partitionInfo.Columns, partitionInfo.ColumnNames)
if err != nil {
return nil, err
Expand Down Expand Up @@ -5190,7 +5190,7 @@ func partitionPruning(ctx sessionctx.Context, tbl table.PartitionedTable, conds
return ret, nil
}

func getPartitionIdsAfterPruning(ctx sessionctx.Context, tbl table.PartitionedTable, partInfo *plannercore.PhysPlanPartitionInfo) (map[int64]struct{}, error) {
func getPartitionIdsAfterPruning(ctx sessionctx.Context, tbl table.PartitionedTable, partInfo *plannercore.PartitionInfo) (map[int64]struct{}, error) {
if partInfo == nil {
return nil, errors.New("partInfo in getPartitionIdsAfterPruning must not be nil")
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/planner/core/access_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (p *BatchPointGetPlan) AccessObject() AccessObject {
return res
}

func getDynamicAccessPartition(sctx sessionctx.Context, tblInfo *model.TableInfo, partitionInfo *PhysPlanPartitionInfo, asName string) (res *DynamicPartitionAccessObject) {
func getDynamicAccessPartition(sctx sessionctx.Context, tblInfo *model.TableInfo, partitionInfo *PartitionInfo, asName string) (res *DynamicPartitionAccessObject) {
pi := tblInfo.GetPartitionInfo()
if pi == nil || !sctx.GetSessionVars().StmtCtx.UseDynamicPartitionPrune() {
return nil
Expand Down Expand Up @@ -407,15 +407,15 @@ func (p *PhysicalTableReader) accessObject(sctx sessionctx.Context) AccessObject
if ts.TableAsName != nil && len(ts.TableAsName.O) > 0 {
asName = ts.TableAsName.O
}
res := getDynamicAccessPartition(sctx, ts.Table, &p.PhysPlanPartitionInfo, asName)
res := getDynamicAccessPartition(sctx, ts.Table, &p.PartitionInfo, asName)
if res == nil {
return DynamicPartitionAccessObjects(nil)
}
return DynamicPartitionAccessObjects{res}
}
if len(p.PartitionInfos) == 1 {
ts := p.PartitionInfos[0].tableScan
partInfo := p.PartitionInfos[0].physPlanPartitionInfo
partInfo := p.PartitionInfos[0].partitionInfo
asName := ""
if ts.TableAsName != nil && len(ts.TableAsName.O) > 0 {
asName = ts.TableAsName.O
Expand All @@ -433,7 +433,7 @@ func (p *PhysicalTableReader) accessObject(sctx sessionctx.Context) AccessObject
continue
}
ts := info.tableScan
partInfo := info.physPlanPartitionInfo
partInfo := info.partitionInfo
asName := ""
if ts.TableAsName != nil && len(ts.TableAsName.O) > 0 {
asName = ts.TableAsName.O
Expand Down
6 changes: 3 additions & 3 deletions pkg/planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,13 +1108,13 @@ func (p *LogicalJoin) constructInnerTableScanTask(
tblColHists: ds.TblColHists,
keepOrder: ts.KeepOrder,
}
copTask.physPlanPartitionInfo = PhysPlanPartitionInfo{
copTask.partitionInfo = PartitionInfo{
PruningConds: ds.allConds,
PartitionNames: ds.partitionNames,
Columns: ds.TblCols,
ColumnNames: ds.names,
}
ts.PhysPlanPartitionInfo = copTask.physPlanPartitionInfo
ts.PartitionInfo = copTask.partitionInfo
selStats := ts.StatsInfo().Scale(selectivity)
ts.addPushedDownSelection(copTask, selStats)
t := copTask.convertToRootTask(ds.SCtx())
Expand Down Expand Up @@ -1272,7 +1272,7 @@ func (p *LogicalJoin) constructInnerIndexScanTask(
tblCols: ds.TblCols,
keepOrder: is.KeepOrder,
}
cop.physPlanPartitionInfo = PhysPlanPartitionInfo{
cop.partitionInfo = PartitionInfo{
PruningConds: ds.allConds,
PartitionNames: ds.partitionNames,
Columns: ds.TblCols,
Expand Down
10 changes: 5 additions & 5 deletions pkg/planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ func (ds *DataSource) convertToIndexMergeScan(prop *property.PhysicalProperty, c
indexPlanFinished: false,
tblColHists: ds.TblColHists,
}
cop.physPlanPartitionInfo = PhysPlanPartitionInfo{
cop.partitionInfo = PartitionInfo{
PruningConds: pushDownNot(ds.SCtx(), ds.allConds),
PartitionNames: ds.partitionNames,
Columns: ds.TblCols,
Expand Down Expand Up @@ -1757,7 +1757,7 @@ func (ds *DataSource) convertToIndexScan(prop *property.PhysicalProperty,
tblCols: ds.TblCols,
expectCnt: uint64(prop.ExpectedCnt),
}
cop.physPlanPartitionInfo = PhysPlanPartitionInfo{
cop.partitionInfo = PartitionInfo{
PruningConds: pushDownNot(ds.SCtx(), ds.allConds),
PartitionNames: ds.partitionNames,
Columns: ds.TblCols,
Expand Down Expand Up @@ -2179,7 +2179,7 @@ func (ds *DataSource) convertToTableScan(prop *property.PhysicalProperty, candid
partTp: property.AnyType,
tblColHists: ds.TblColHists,
}
ts.PhysPlanPartitionInfo = PhysPlanPartitionInfo{
ts.PartitionInfo = PartitionInfo{
PruningConds: pushDownNot(ds.SCtx(), ds.allConds),
PartitionNames: ds.partitionNames,
Columns: ds.TblCols,
Expand Down Expand Up @@ -2213,13 +2213,13 @@ func (ds *DataSource) convertToTableScan(prop *property.PhysicalProperty, candid
indexPlanFinished: true,
tblColHists: ds.TblColHists,
}
copTask.physPlanPartitionInfo = PhysPlanPartitionInfo{
copTask.partitionInfo = PartitionInfo{
PruningConds: pushDownNot(ds.SCtx(), ds.allConds),
PartitionNames: ds.partitionNames,
Columns: ds.TblCols,
ColumnNames: ds.names,
}
ts.PhysPlanPartitionInfo = copTask.physPlanPartitionInfo
ts.PartitionInfo = copTask.partitionInfo
task = copTask
if candidate.isMatchProp {
copTask.keepOrder = true
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/fragment.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func (e *mppTaskGenerator) constructMPPTasksImpl(ctx context.Context, ts *Physic
tbl := tmp.(table.PartitionedTable)
if !tiFlashStaticPrune {
var partitions []table.PhysicalTable
partitions, err = partitionPruning(e.ctx, tbl, ts.PhysPlanPartitionInfo.PruningConds, ts.PhysPlanPartitionInfo.PartitionNames, ts.PhysPlanPartitionInfo.Columns, ts.PhysPlanPartitionInfo.ColumnNames)
partitions, err = partitionPruning(e.ctx, tbl, ts.PartitionInfo.PruningConds, ts.PartitionInfo.PartitionNames, ts.PartitionInfo.Columns, ts.PartitionInfo.ColumnNames)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down
32 changes: 16 additions & 16 deletions pkg/planner/core/physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ var (
)

type tableScanAndPartitionInfo struct {
tableScan *PhysicalTableScan
physPlanPartitionInfo PhysPlanPartitionInfo
tableScan *PhysicalTableScan
partitionInfo PartitionInfo
}

// MemoryUsage return the memory usage of tableScanAndPartitionInfo
Expand All @@ -86,7 +86,7 @@ func (t *tableScanAndPartitionInfo) MemoryUsage() (sum int64) {
return
}

sum += t.physPlanPartitionInfo.MemoryUsage()
sum += t.partitionInfo.MemoryUsage()
if t.tableScan != nil {
sum += t.tableScan.MemoryUsage()
}
Expand Down Expand Up @@ -136,23 +136,23 @@ type PhysicalTableReader struct {
IsCommonHandle bool

// Used by partition table.
PhysPlanPartitionInfo PhysPlanPartitionInfo
PartitionInfo PartitionInfo
// Used by MPP, because MPP plan may contain join/union/union all, it is possible that a physical table reader contains more than 1 table scan
PartitionInfos []tableScanAndPartitionInfo
}

// PhysPlanPartitionInfo indicates partition helper info in physical plan.
type PhysPlanPartitionInfo struct {
// PartitionInfo indicates partition helper info in physical plan.
type PartitionInfo struct {
PruningConds []expression.Expression
PartitionNames []model.CIStr
Columns []*expression.Column
ColumnNames types.NameSlice
}

const emptyPartitionInfoSize = int64(unsafe.Sizeof(PhysPlanPartitionInfo{}))
const emptyPartitionInfoSize = int64(unsafe.Sizeof(PartitionInfo{}))

// MemoryUsage return the memory usage of PhysPlanPartitionInfo
func (pi *PhysPlanPartitionInfo) MemoryUsage() (sum int64) {
// MemoryUsage return the memory usage of PartitionInfo
func (pi *PartitionInfo) MemoryUsage() (sum int64) {
if pi == nil {
return
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func (p *PhysicalTableReader) MemoryUsage() (sum int64) {
return
}

sum = p.physicalSchemaProducer.MemoryUsage() + size.SizeOfUint8*2 + size.SizeOfBool + p.PhysPlanPartitionInfo.MemoryUsage()
sum = p.physicalSchemaProducer.MemoryUsage() + size.SizeOfUint8*2 + size.SizeOfBool + p.PartitionInfo.MemoryUsage()
if p.tablePlan != nil {
sum += p.tablePlan.MemoryUsage()
}
Expand All @@ -235,7 +235,7 @@ func setMppOrBatchCopForTableScan(curPlan PhysicalPlan) {
// GetPhysicalTableReader returns PhysicalTableReader for logical TiKVSingleGather.
func (sg *TiKVSingleGather) GetPhysicalTableReader(schema *expression.Schema, stats *property.StatsInfo, props ...*property.PhysicalProperty) *PhysicalTableReader {
reader := PhysicalTableReader{}.Init(sg.SCtx(), sg.QueryBlockOffset())
reader.PhysPlanPartitionInfo = PhysPlanPartitionInfo{
reader.PartitionInfo = PartitionInfo{
PruningConds: sg.Source.allConds,
PartitionNames: sg.Source.partitionNames,
Columns: sg.Source.TblCols,
Expand Down Expand Up @@ -315,7 +315,7 @@ type PhysicalIndexReader struct {
OutputColumns []*expression.Column

// Used by partition table.
PartitionInfo PhysPlanPartitionInfo
PartitionInfo PartitionInfo
}

// Clone implements PhysicalPlan interface.
Expand Down Expand Up @@ -444,7 +444,7 @@ type PhysicalIndexLookUpReader struct {
CommonHandleCols []*expression.Column

// Used by partition table.
PartitionInfo PhysPlanPartitionInfo
PartitionInfo PartitionInfo

// required by cost calculation
expectedCnt uint64
Expand Down Expand Up @@ -576,7 +576,7 @@ type PhysicalIndexMergeReader struct {
tablePlan PhysicalPlan

// Used by partition table.
PartitionInfo PhysPlanPartitionInfo
PartitionInfo PartitionInfo

KeepOrder bool

Expand Down Expand Up @@ -865,7 +865,7 @@ type PhysicalTableScan struct {

isChildOfIndexLookUp bool

PhysPlanPartitionInfo PhysPlanPartitionInfo
PartitionInfo PartitionInfo

SampleInfo *TableSampleInfo

Expand Down Expand Up @@ -1014,7 +1014,7 @@ func (ts *PhysicalTableScan) MemoryUsage() (sum int64) {
}

sum = emptyPhysicalTableScanSize + ts.physicalSchemaProducer.MemoryUsage() + ts.DBName.MemoryUsage() +
int64(cap(ts.HandleIdx))*size.SizeOfInt + ts.PhysPlanPartitionInfo.MemoryUsage() + int64(len(ts.rangeInfo))
int64(cap(ts.HandleIdx))*size.SizeOfInt + ts.PartitionInfo.MemoryUsage() + int64(len(ts.rangeInfo))
if ts.TableAsName != nil {
sum += ts.TableAsName.MemoryUsage()
}
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 @@ -493,7 +493,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.PhysPlanPartitionInfo != nil {
if x.PartitionInfo != 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
14 changes: 7 additions & 7 deletions pkg/planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type copTask struct {
rootTaskConds []expression.Expression

// For table partition.
physPlanPartitionInfo PhysPlanPartitionInfo
partitionInfo PartitionInfo

// expectCnt is the expected row count of upper task, 0 for unlimited.
// It's used for deciding whether using paging distsql.
Expand Down Expand Up @@ -191,7 +191,7 @@ func (t *copTask) MemoryUsage() (sum int64) {
}

sum = size.SizeOfInterface*(2+int64(cap(t.idxMergePartPlans)+cap(t.rootTaskConds))) + size.SizeOfBool*3 + size.SizeOfUint64 +
size.SizeOfPointer*(3+int64(cap(t.commonHandleCols)+cap(t.tblCols))) + size.SizeOfSlice*4 + t.physPlanPartitionInfo.MemoryUsage()
size.SizeOfPointer*(3+int64(cap(t.commonHandleCols)+cap(t.tblCols))) + size.SizeOfSlice*4 + t.partitionInfo.MemoryUsage()
if t.indexPlan != nil {
sum += t.indexPlan.MemoryUsage()
}
Expand Down Expand Up @@ -591,7 +591,7 @@ func buildIndexLookUpTask(ctx sessionctx.Context, t *copTask) *rootTask {
expectedCnt: t.expectCnt,
keepOrder: t.keepOrder,
}.Init(ctx, t.tablePlan.QueryBlockOffset())
p.PartitionInfo = t.physPlanPartitionInfo
p.PartitionInfo = t.partitionInfo
setTableScanToTableRowIDScan(p.tablePlan)
p.SetStats(t.tablePlan.StatsInfo())
// Do not inject the extra Projection even if t.needExtraProj is set, or the schema between the phase-1 agg and
Expand Down Expand Up @@ -695,7 +695,7 @@ func (t *copTask) convertToRootTaskImpl(ctx sessionctx.Context) *rootTask {
AccessMVIndex: t.idxMergeAccessMVIndex,
KeepOrder: t.keepOrder,
}.Init(ctx, t.idxMergePartPlans[0].QueryBlockOffset())
p.PartitionInfo = t.physPlanPartitionInfo
p.PartitionInfo = t.partitionInfo
setTableScanToTableRowIDScan(p.tablePlan)
newTask.p = p
t.handleRootTaskConds(ctx, newTask)
Expand All @@ -712,7 +712,7 @@ func (t *copTask) convertToRootTaskImpl(ctx sessionctx.Context) *rootTask {
newTask = buildIndexLookUpTask(ctx, t)
} else if t.indexPlan != nil {
p := PhysicalIndexReader{indexPlan: t.indexPlan}.Init(ctx, t.indexPlan.QueryBlockOffset())
p.PartitionInfo = t.physPlanPartitionInfo
p.PartitionInfo = t.partitionInfo
p.SetStats(t.indexPlan.StatsInfo())
newTask.p = p
} else {
Expand All @@ -731,7 +731,7 @@ func (t *copTask) convertToRootTaskImpl(ctx sessionctx.Context) *rootTask {
StoreType: ts.StoreType,
IsCommonHandle: ts.Table.IsCommonHandle,
}.Init(ctx, t.tablePlan.QueryBlockOffset())
p.PhysPlanPartitionInfo = t.physPlanPartitionInfo
p.PartitionInfo = t.partitionInfo
p.SetStats(t.tablePlan.StatsInfo())

// If agg was pushed down in attach2Task(), the partial agg was placed on the top of tablePlan, the final agg was
Expand Down Expand Up @@ -2602,7 +2602,7 @@ func (t *mppTask) MemoryUsage() (sum int64) {
func collectPartitionInfosFromMPPPlan(p *PhysicalTableReader, mppPlan PhysicalPlan) {
switch x := mppPlan.(type) {
case *PhysicalTableScan:
p.PartitionInfos = append(p.PartitionInfos, tableScanAndPartitionInfo{x, x.PhysPlanPartitionInfo})
p.PartitionInfos = append(p.PartitionInfos, tableScanAndPartitionInfo{x, x.PartitionInfo})
default:
for _, ch := range mppPlan.Children() {
collectPartitionInfosFromMPPPlan(p, ch)
Expand Down

0 comments on commit b012bdb

Please sign in to comment.