Files
tidb/pkg/planner/core/plan_clone_generated.go

331 lines
11 KiB
Go

// Copyright 2024 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by plan_clone_generator; DO NOT EDIT IT DIRECTLY.
package core
import (
"github.com/pingcap/tidb/pkg/expression"
"github.com/pingcap/tidb/pkg/planner/core/base"
"github.com/pingcap/tidb/pkg/planner/core/operator/physicalop"
"github.com/pingcap/tidb/pkg/planner/util"
)
// CloneForPlanCache implements the base.Plan interface.
func (op *PhysicalIndexScan) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PhysicalIndexScan)
*cloned = *op
basePlan, baseOK := op.PhysicalSchemaProducer.CloneForPlanCacheWithSelf(newCtx, cloned)
if !baseOK {
return nil, false
}
cloned.PhysicalSchemaProducer = *basePlan
cloned.AccessCondition = cloneExpressionsForPlanCache(op.AccessCondition, nil)
cloned.IdxCols = cloneColumnsForPlanCache(op.IdxCols, nil)
cloned.IdxColLens = make([]int, len(op.IdxColLens))
copy(cloned.IdxColLens, op.IdxColLens)
if op.GenExprs != nil {
return nil, false
}
cloned.ByItems = util.CloneByItemss(op.ByItems)
if op.pkIsHandleCol != nil {
if op.pkIsHandleCol.SafeToShareAcrossSession() {
cloned.pkIsHandleCol = op.pkIsHandleCol
} else {
cloned.pkIsHandleCol = op.pkIsHandleCol.Clone().(*expression.Column)
}
}
cloned.constColsByCond = make([]bool, len(op.constColsByCond))
copy(cloned.constColsByCond, op.constColsByCond)
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *PhysicalStreamAgg) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PhysicalStreamAgg)
*cloned = *op
basePlan, baseOK := op.BasePhysicalAgg.CloneForPlanCacheWithSelf(newCtx, cloned)
if !baseOK {
return nil, false
}
cloned.BasePhysicalAgg = *basePlan
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *PhysicalHashAgg) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PhysicalHashAgg)
*cloned = *op
basePlan, baseOK := op.BasePhysicalAgg.CloneForPlanCacheWithSelf(newCtx, cloned)
if !baseOK {
return nil, false
}
cloned.BasePhysicalAgg = *basePlan
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *PhysicalTableReader) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PhysicalTableReader)
*cloned = *op
basePlan, baseOK := op.PhysicalSchemaProducer.CloneForPlanCacheWithSelf(newCtx, cloned)
if !baseOK {
return nil, false
}
cloned.PhysicalSchemaProducer = *basePlan
if op.tablePlan != nil {
tablePlan, ok := op.tablePlan.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.tablePlan = tablePlan.(base.PhysicalPlan)
}
cloned.TablePlans = flattenPushDownPlan(cloned.tablePlan)
cloned.PlanPartInfo = op.PlanPartInfo.CloneForPlanCache()
if op.TableScanAndPartitionInfos != nil {
return nil, false
}
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *PhysicalIndexReader) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PhysicalIndexReader)
*cloned = *op
basePlan, baseOK := op.PhysicalSchemaProducer.CloneForPlanCacheWithSelf(newCtx, cloned)
if !baseOK {
return nil, false
}
cloned.PhysicalSchemaProducer = *basePlan
if op.indexPlan != nil {
indexPlan, ok := op.indexPlan.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.indexPlan = indexPlan.(base.PhysicalPlan)
}
cloned.IndexPlans = flattenPushDownPlan(cloned.indexPlan)
cloned.OutputColumns = cloneColumnsForPlanCache(op.OutputColumns, nil)
cloned.PlanPartInfo = op.PlanPartInfo.CloneForPlanCache()
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *PointGetPlan) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PointGetPlan)
*cloned = *op
cloned.Plan = *op.Plan.CloneWithNewCtx(newCtx)
if op.PartitionIdx != nil {
cloned.PartitionIdx = new(int)
*cloned.PartitionIdx = *op.PartitionIdx
}
if op.Handle != nil {
cloned.Handle = op.Handle.Copy()
}
if op.HandleConstant != nil {
if op.HandleConstant.SafeToShareAcrossSession() {
cloned.HandleConstant = op.HandleConstant
} else {
cloned.HandleConstant = op.HandleConstant.Clone().(*expression.Constant)
}
}
cloned.IndexValues = util.CloneDatums(op.IndexValues)
cloned.IndexConstants = cloneConstantsForPlanCache(op.IndexConstants, nil)
cloned.IdxCols = cloneColumnsForPlanCache(op.IdxCols, nil)
cloned.IdxColLens = make([]int, len(op.IdxColLens))
copy(cloned.IdxColLens, op.IdxColLens)
cloned.AccessConditions = cloneExpressionsForPlanCache(op.AccessConditions, nil)
cloned.accessCols = cloneColumnsForPlanCache(op.accessCols, nil)
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *BatchPointGetPlan) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(BatchPointGetPlan)
*cloned = *op
cloned.baseSchemaProducer = *op.baseSchemaProducer.cloneForPlanCache(newCtx)
probeParents, ok := clonePhysicalPlansForPlanCache(newCtx, op.probeParents)
if !ok {
return nil, false
}
cloned.probeParents = probeParents
cloned.ctx = newCtx
cloned.Handles = util.CloneHandles(op.Handles)
cloned.HandleParams = cloneConstantsForPlanCache(op.HandleParams, nil)
cloned.IndexValues = util.CloneDatum2D(op.IndexValues)
cloned.IndexValueParams = cloneConstant2DForPlanCache(op.IndexValueParams)
cloned.AccessConditions = cloneExpressionsForPlanCache(op.AccessConditions, nil)
cloned.IdxCols = cloneColumnsForPlanCache(op.IdxCols, nil)
cloned.IdxColLens = make([]int, len(op.IdxColLens))
copy(cloned.IdxColLens, op.IdxColLens)
cloned.PartitionIdxs = make([]int, len(op.PartitionIdxs))
copy(cloned.PartitionIdxs, op.PartitionIdxs)
cloned.accessCols = cloneColumnsForPlanCache(op.accessCols, nil)
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *PhysicalIndexHashJoin) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PhysicalIndexHashJoin)
*cloned = *op
inlj, ok := op.PhysicalIndexJoin.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.PhysicalIndexJoin = *inlj.(*physicalop.PhysicalIndexJoin)
cloned.Self = cloned
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *PhysicalIndexLookUpReader) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PhysicalIndexLookUpReader)
*cloned = *op
basePlan, baseOK := op.PhysicalSchemaProducer.CloneForPlanCacheWithSelf(newCtx, cloned)
if !baseOK {
return nil, false
}
cloned.PhysicalSchemaProducer = *basePlan
if op.indexPlan != nil {
indexPlan, ok := op.indexPlan.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.indexPlan = indexPlan.(base.PhysicalPlan)
}
if op.tablePlan != nil {
tablePlan, ok := op.tablePlan.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.tablePlan = tablePlan.(base.PhysicalPlan)
}
cloned.IndexPlans = flattenPushDownPlan(cloned.indexPlan)
cloned.TablePlans = flattenPushDownPlan(cloned.tablePlan)
if op.ExtraHandleCol != nil {
if op.ExtraHandleCol.SafeToShareAcrossSession() {
cloned.ExtraHandleCol = op.ExtraHandleCol
} else {
cloned.ExtraHandleCol = op.ExtraHandleCol.Clone().(*expression.Column)
}
}
cloned.PushedLimit = op.PushedLimit.Clone()
cloned.CommonHandleCols = cloneColumnsForPlanCache(op.CommonHandleCols, nil)
cloned.PlanPartInfo = op.PlanPartInfo.CloneForPlanCache()
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *PhysicalIndexMergeReader) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(PhysicalIndexMergeReader)
*cloned = *op
basePlan, baseOK := op.PhysicalSchemaProducer.CloneForPlanCacheWithSelf(newCtx, cloned)
if !baseOK {
return nil, false
}
cloned.PhysicalSchemaProducer = *basePlan
cloned.PushedLimit = op.PushedLimit.Clone()
cloned.ByItems = util.CloneByItemss(op.ByItems)
partialPlans, ok := clonePhysicalPlansForPlanCache(newCtx, op.partialPlans)
if !ok {
return nil, false
}
cloned.partialPlans = partialPlans
if op.tablePlan != nil {
tablePlan, ok := op.tablePlan.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.tablePlan = tablePlan.(base.PhysicalPlan)
}
cloned.PartialPlans = make([][]base.PhysicalPlan, len(op.PartialPlans))
for i, plan := range cloned.partialPlans {
cloned.PartialPlans[i] = flattenPushDownPlan(plan)
}
cloned.TablePlans = flattenPushDownPlan(cloned.tablePlan)
cloned.PlanPartInfo = op.PlanPartInfo.CloneForPlanCache()
if op.HandleCols != nil {
cloned.HandleCols = op.HandleCols.Clone()
}
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *Update) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(Update)
*cloned = *op
cloned.baseSchemaProducer = *op.baseSchemaProducer.cloneForPlanCache(newCtx)
cloned.OrderedList = util.CloneAssignments(op.OrderedList)
if op.SelectPlan != nil {
SelectPlan, ok := op.SelectPlan.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.SelectPlan = SelectPlan.(base.PhysicalPlan)
}
if op.FKChecks != nil {
return nil, false
}
if op.FKCascades != nil {
return nil, false
}
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *Delete) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(Delete)
*cloned = *op
cloned.baseSchemaProducer = *op.baseSchemaProducer.cloneForPlanCache(newCtx)
if op.SelectPlan != nil {
SelectPlan, ok := op.SelectPlan.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.SelectPlan = SelectPlan.(base.PhysicalPlan)
}
if op.FKChecks != nil {
return nil, false
}
if op.FKCascades != nil {
return nil, false
}
return cloned, true
}
// CloneForPlanCache implements the base.Plan interface.
func (op *Insert) CloneForPlanCache(newCtx base.PlanContext) (base.Plan, bool) {
cloned := new(Insert)
*cloned = *op
cloned.baseSchemaProducer = *op.baseSchemaProducer.cloneForPlanCache(newCtx)
cloned.Lists = cloneExpression2DForPlanCache(op.Lists)
cloned.OnDuplicate = util.CloneAssignments(op.OnDuplicate)
cloned.GenCols = op.GenCols.cloneForPlanCache()
if op.SelectPlan != nil {
SelectPlan, ok := op.SelectPlan.CloneForPlanCache(newCtx)
if !ok {
return nil, false
}
cloned.SelectPlan = SelectPlan.(base.PhysicalPlan)
}
if op.FKChecks != nil {
return nil, false
}
if op.FKCascades != nil {
return nil, false
}
return cloned, true
}