From b012bdb9d40814a4949cf89d826b1b8b78a959bf Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 2 Jan 2024 23:59:54 +0000 Subject: [PATCH] Removed renaming of variables due to #49989 --- pkg/ddl/ddl_api.go | 6 ++-- pkg/ddl/partition.go | 2 +- pkg/executor/builder.go | 8 +++--- pkg/planner/core/access_object.go | 8 +++--- pkg/planner/core/exhaust_physical_plans.go | 6 ++-- pkg/planner/core/find_best_task.go | 10 +++---- pkg/planner/core/fragment.go | 2 +- pkg/planner/core/physical_plans.go | 32 +++++++++++----------- pkg/planner/core/plan_cache.go | 2 +- pkg/planner/core/task.go | 14 +++++----- 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/pkg/ddl/ddl_api.go b/pkg/ddl/ddl_api.go index 015ad40f86df3..ff46a61a82d36 100644 --- a/pkg/ddl/ddl_api.go +++ b/pkg/ddl/ddl_api.go @@ -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. @@ -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 diff --git a/pkg/ddl/partition.go b/pkg/ddl/partition.go index bed5dfcada94a..3abca1c2b1df7 100644 --- a/pkg/ddl/partition.go +++ b/pkg/ddl/partition.go @@ -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 diff --git a/pkg/executor/builder.go b/pkg/executor/builder.go index 799c9b2d418b0..9ff3568fcd75a 100644 --- a/pkg/executor/builder.go +++ b/pkg/executor/builder.go @@ -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 @@ -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) @@ -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 @@ -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") } diff --git a/pkg/planner/core/access_object.go b/pkg/planner/core/access_object.go index 9a428ad83e66f..21e3a0cf6df01 100644 --- a/pkg/planner/core/access_object.go +++ b/pkg/planner/core/access_object.go @@ -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 @@ -407,7 +407,7 @@ 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) } @@ -415,7 +415,7 @@ func (p *PhysicalTableReader) accessObject(sctx sessionctx.Context) AccessObject } 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 @@ -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 diff --git a/pkg/planner/core/exhaust_physical_plans.go b/pkg/planner/core/exhaust_physical_plans.go index 194202fa938a0..82bc8e20d4e1c 100644 --- a/pkg/planner/core/exhaust_physical_plans.go +++ b/pkg/planner/core/exhaust_physical_plans.go @@ -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()) @@ -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, diff --git a/pkg/planner/core/find_best_task.go b/pkg/planner/core/find_best_task.go index b2cd4e90850f5..6f2338b9a058c 100644 --- a/pkg/planner/core/find_best_task.go +++ b/pkg/planner/core/find_best_task.go @@ -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, @@ -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, @@ -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, @@ -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 diff --git a/pkg/planner/core/fragment.go b/pkg/planner/core/fragment.go index a68d62a88d58e..06745c5e26fcb 100644 --- a/pkg/planner/core/fragment.go +++ b/pkg/planner/core/fragment.go @@ -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) } diff --git a/pkg/planner/core/physical_plans.go b/pkg/planner/core/physical_plans.go index 3d0e35eec3eba..4c250cc91cf35 100644 --- a/pkg/planner/core/physical_plans.go +++ b/pkg/planner/core/physical_plans.go @@ -76,8 +76,8 @@ var ( ) type tableScanAndPartitionInfo struct { - tableScan *PhysicalTableScan - physPlanPartitionInfo PhysPlanPartitionInfo + tableScan *PhysicalTableScan + partitionInfo PartitionInfo } // MemoryUsage return the memory usage of tableScanAndPartitionInfo @@ -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() } @@ -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 } @@ -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() } @@ -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, @@ -315,7 +315,7 @@ type PhysicalIndexReader struct { OutputColumns []*expression.Column // Used by partition table. - PartitionInfo PhysPlanPartitionInfo + PartitionInfo PartitionInfo } // Clone implements PhysicalPlan interface. @@ -444,7 +444,7 @@ type PhysicalIndexLookUpReader struct { CommonHandleCols []*expression.Column // Used by partition table. - PartitionInfo PhysPlanPartitionInfo + PartitionInfo PartitionInfo // required by cost calculation expectedCnt uint64 @@ -576,7 +576,7 @@ type PhysicalIndexMergeReader struct { tablePlan PhysicalPlan // Used by partition table. - PartitionInfo PhysPlanPartitionInfo + PartitionInfo PartitionInfo KeepOrder bool @@ -865,7 +865,7 @@ type PhysicalTableScan struct { isChildOfIndexLookUp bool - PhysPlanPartitionInfo PhysPlanPartitionInfo + PartitionInfo PartitionInfo SampleInfo *TableSampleInfo @@ -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() } diff --git a/pkg/planner/core/plan_cache.go b/pkg/planner/core/plan_cache.go index e61adfa0503c2..0d75f8f8e96a6 100644 --- a/pkg/planner/core/plan_cache.go +++ b/pkg/planner/core/plan_cache.go @@ -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") } diff --git a/pkg/planner/core/task.go b/pkg/planner/core/task.go index 9b171b108aa8d..ce81dc1e91180 100644 --- a/pkg/planner/core/task.go +++ b/pkg/planner/core/task.go @@ -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. @@ -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() } @@ -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 @@ -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) @@ -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 { @@ -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 @@ -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)