core

package
v7.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 100 Imported by: 0

Documentation

Overview

Package core Copyright 2022 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.

Index

Constants

View Source
const (
	// TiDBMergeJoin is hint enforce merge join.
	TiDBMergeJoin = "tidb_smj"
	// HintSMJ is hint enforce merge join.
	HintSMJ = "merge_join"

	// TiDBBroadCastJoin indicates applying broadcast join by force.
	TiDBBroadCastJoin = "tidb_bcj"
	// HintBCJ indicates applying broadcast join by force.
	HintBCJ = "broadcast_join"
	// HintShuffleJoin indicates applying shuffle join by force.
	HintShuffleJoin = "shuffle_join"

	// HintStraightJoin causes TiDB to join tables in the order in which they appear in the FROM clause.
	HintStraightJoin = "straight_join"
	// HintLeading specifies the set of tables to be used as the prefix in the execution plan.
	HintLeading = "leading"

	// TiDBIndexNestedLoopJoin is hint enforce index nested loop join.
	TiDBIndexNestedLoopJoin = "tidb_inlj"
	// HintINLJ is hint enforce index nested loop join.
	HintINLJ = "inl_join"
	// HintINLHJ is hint enforce index nested loop hash join.
	HintINLHJ = "inl_hash_join"
	// HintINLMJ is hint enforce index nested loop merge join.
	HintINLMJ = "inl_merge_join"
	// TiDBHashJoin is hint enforce hash join.
	TiDBHashJoin = "tidb_hj"
	// HintHJ is hint enforce hash join.
	HintHJ = "hash_join"
	// HintHashJoinBuild is hint enforce hash join's build side
	HintHashJoinBuild = "hash_join_build"
	// HintHashJoinProbe is hint enforce hash join's probe side
	HintHashJoinProbe = "hash_join_probe"
	// HintHashAgg is hint enforce hash aggregation.
	HintHashAgg = "hash_agg"
	// HintStreamAgg is hint enforce stream aggregation.
	HintStreamAgg = "stream_agg"
	// HintMPP1PhaseAgg enforces the optimizer to use the mpp-1phase aggregation.
	HintMPP1PhaseAgg = "mpp_1phase_agg"
	// HintMPP2PhaseAgg enforces the optimizer to use the mpp-2phase aggregation.
	HintMPP2PhaseAgg = "mpp_2phase_agg"
	// HintUseIndex is hint enforce using some indexes.
	HintUseIndex = "use_index"
	// HintIgnoreIndex is hint enforce ignoring some indexes.
	HintIgnoreIndex = "ignore_index"
	// HintForceIndex make optimizer to use this index even if it thinks a table scan is more efficient.
	HintForceIndex = "force_index"
	// HintKeepOrder is hint enforce using some indexes and keep the index's order.
	HintKeepOrder = "keep_order"
	// HintNoKeepOrder is hint enforce using some indexes and not keep the index's order.
	HintNoKeepOrder = "no_keep_order"
	// HintAggToCop is hint enforce pushing aggregation to coprocessor.
	HintAggToCop = "agg_to_cop"
	// HintReadFromStorage is hint enforce some tables read from specific type of storage.
	HintReadFromStorage = "read_from_storage"
	// HintTiFlash is a label represents the tiflash storage type.
	HintTiFlash = "tiflash"
	// HintTiKV is a label represents the tikv storage type.
	HintTiKV = "tikv"
	// HintIndexMerge is a hint to enforce using some indexes at the same time.
	HintIndexMerge = "use_index_merge"
	// HintTimeRange is a hint to specify the time range for metrics summary tables
	HintTimeRange = "time_range"
	// HintIgnorePlanCache is a hint to enforce ignoring plan cache
	HintIgnorePlanCache = "ignore_plan_cache"
	// HintLimitToCop is a hint enforce pushing limit or topn to coprocessor.
	HintLimitToCop = "limit_to_cop"
	// HintMerge is a hint which can switch turning inline for the CTE.
	HintMerge = "merge"
	// HintSemiJoinRewrite is a hint to force we rewrite the semi join operator as much as possible.
	HintSemiJoinRewrite = "semi_join_rewrite"
	// HintNoDecorrelate indicates a LogicalApply not to be decorrelated.
	HintNoDecorrelate = "no_decorrelate"
)
View Source
const (
	// ErrExprInSelect  is in select fields for the error of ErrFieldNotInGroupBy
	ErrExprInSelect = "SELECT list"
	// ErrExprInOrderBy  is in order by items for the error of ErrFieldNotInGroupBy
	ErrExprInOrderBy = "ORDER BY"
)
View Source
const (
	// HotRegionTypeRead hot read region.
	HotRegionTypeRead = "read"
	// HotRegionTypeWrite hot write region.
	HotRegionTypeWrite = "write"
)
View Source
const (
	// PartitionHashSplitterType is the splitter splits by hash.
	PartitionHashSplitterType = iota
	// PartitionRangeSplitterType is the splitter that split sorted data into the same range
	PartitionRangeSplitterType
)
View Source
const (
	// RowCountLbl indicates for rowCount
	RowCountLbl = "rowCount"
	// RowSizeLbl indicates rowSize
	RowSizeLbl = "rowSize"
	// BuildRowCountLbl indicates rowCount on build side
	BuildRowCountLbl = "buildRowCount"
	// ProbeRowCountLbl indicates rowCount on probe side
	ProbeRowCountLbl = "probeRowCount"
	// NumPairsLbl indicates numPairs
	NumPairsLbl = "numPairs"

	// NetworkFactorLbl indicates networkFactor
	NetworkFactorLbl = "networkFactor"
	// SeekFactorLbl indicates seekFactor
	SeekFactorLbl = "seekFactor"
	// ScanFactorLbl indicates for scanFactor
	ScanFactorLbl = "scanFactor"
	// SelectionFactorLbl indicates selection factor
	SelectionFactorLbl = "selectionFactor"
	// CPUFactorLbl indicates cpu factor
	CPUFactorLbl = "cpuFactor"
	// MemoryFactorLbl indicates mem factor
	MemoryFactorLbl = "memoryFactor"
	// DiskFactorLbl indicates disk factor
	DiskFactorLbl = "diskFactor"
	// ConcurrencyFactorLbl indicates for concurrency factor
	ConcurrencyFactorLbl = "concurrencyFactor"

	// ScanConcurrencyLbl indicates sql scan concurrency
	ScanConcurrencyLbl = "scanConcurrency"
	// HashJoinConcurrencyLbl indicates concurrency for hash join
	HashJoinConcurrencyLbl = "hashJoinConcurrency"

	// NetSeekCostLbl indicates netSeek cost
	NetSeekCostLbl = "netSeekCost"
	// TablePlanCostLbl indicates tablePlan cost
	TablePlanCostLbl = "tablePlanCost"
	// IndexPlanCostLbl indicates indexPlan cost
	IndexPlanCostLbl = "indexPlanCost"

	// ProbeCostDetailLbl indicates probeCost
	ProbeCostDetailLbl = "probeCostDetail"
	// ProbeCostDescLbl indicates description for probe cost
	ProbeCostDescLbl = "probeCostDesc"
	// CPUCostDetailLbl indicates cpuCost detail
	CPUCostDetailLbl = "cpuCostDetail"
	// CPUCostDescLbl indicates description for cpu cost
	CPUCostDescLbl = "cpuCostDesc"
	// MemCostDetailLbl indicates mem cost detail
	MemCostDetailLbl = "memCostDetail"
	// MemCostDescLbl indicates description for mem cost
	MemCostDescLbl = "memCostDesc"
	// DiskCostDetailLbl indicates disk cost detail
	DiskCostDetailLbl = "diskCostDetail"
	// DiskCostDescLbl indicates description for disk cost
	DiskCostDescLbl = "diskCostDesc"
	// ProbeDiskCostLbl indicates probe disk cost detail
	ProbeDiskCostLbl = "probeDiskCostDetail"
	// ProbeDiskCostDescLbl indicates description for probe disk cost
	ProbeDiskCostDescLbl = "probeDiskCostDesc"

	// MemQuotaLbl indicates memory quota
	MemQuotaLbl = "memQuota"
)
View Source
const (
	// CostFlagRecalculate indicates the optimizer to ignore cached cost and recalculate it again.
	CostFlagRecalculate uint64 = 1 << iota

	// CostFlagUseTrueCardinality indicates the optimizer to use true cardinality to calculate the cost.
	CostFlagUseTrueCardinality

	// CostFlagTrace indicates whether to trace the cost calculation.
	CostFlagTrace
)
View Source
const (
	// HintFlagSemiJoinRewrite corresponds to HintSemiJoinRewrite.
	HintFlagSemiJoinRewrite uint64 = 1 << iota
	// HintFlagNoDecorrelate corresponds to HintNoDecorrelate.
	HintFlagNoDecorrelate
)

Hint flags listed here are used by PlanBuilder.subQueryHintFlags.

View Source
const (
	// TraceFormatRow indicates row tracing format.
	TraceFormatRow = "row"
	// TraceFormatJSON indicates json tracing format.
	TraceFormatJSON = "json"
	// TraceFormatLog indicates log tracing format.
	TraceFormatLog = "log"

	// TracePlanTargetEstimation indicates CE trace target for optimizer trace.
	TracePlanTargetEstimation = "estimation"
)
View Source
const (
	// TypeInvalid for unexpected types.
	TypeInvalid byte = iota
	// TypeSelect for SelectStmt.
	TypeSelect
	// TypeSetOpr for SetOprStmt.
	TypeSetOpr
	// TypeDelete for DeleteStmt.
	TypeDelete
	// TypeUpdate for UpdateStmt.
	TypeUpdate
	// TypeInsert for InsertStmt.
	TypeInsert
	// TypeDrop for DropStmt
	TypeDrop
	// TypeCreate for CreateStmt
	TypeCreate
	// TypeAlter for AlterStmt
	TypeAlter
	// TypeRename for RenameStmt
	TypeRename
	// TypeRepair for RepairStmt
	TypeRepair
	// TypeShow for ShowStmt
	TypeShow
	// TypeExecute for ExecuteStmt
	TypeExecute
)
View Source
const FullRange = -1

FullRange represent used all partitions.

View Source
const MetricTableTimeFormat = "2006-01-02 15:04:05.999"

MetricTableTimeFormat is the time format for metric table explain and format.

View Source
const PointPlanKey = stringutil.StringerStr("pointPlanKey")

PointPlanKey is used to get point plan that is pre-built for multi-statement query.

View Source
const (
	// SelectionFactor is the default factor of the selectivity.
	// For example, If we have no idea how to estimate the selectivity
	// of a Selection or a JoinCondition, we can use this default value.
	SelectionFactor = 0.8
)

Variables

View Source
var (
	ErrUnsupportedType                 = dbterror.ClassOptimizer.NewStd(mysql.ErrUnsupportedType)
	ErrAnalyzeMissIndex                = dbterror.ClassOptimizer.NewStd(mysql.ErrAnalyzeMissIndex)
	ErrAnalyzeMissColumn               = dbterror.ClassOptimizer.NewStd(mysql.ErrAnalyzeMissColumn)
	ErrWrongParamCount                 = dbterror.ClassOptimizer.NewStd(mysql.ErrWrongParamCount)
	ErrSchemaChanged                   = dbterror.ClassOptimizer.NewStd(mysql.ErrSchemaChanged)
	ErrTablenameNotAllowedHere         = dbterror.ClassOptimizer.NewStd(mysql.ErrTablenameNotAllowedHere)
	ErrNotSupportedYet                 = dbterror.ClassOptimizer.NewStd(mysql.ErrNotSupportedYet)
	ErrWrongUsage                      = dbterror.ClassOptimizer.NewStd(mysql.ErrWrongUsage)
	ErrUnknown                         = dbterror.ClassOptimizer.NewStd(mysql.ErrUnknown)
	ErrUnknownTable                    = dbterror.ClassOptimizer.NewStd(mysql.ErrUnknownTable)
	ErrNoSuchTable                     = dbterror.ClassOptimizer.NewStd(mysql.ErrNoSuchTable)
	ErrViewRecursive                   = dbterror.ClassOptimizer.NewStd(mysql.ErrViewRecursive)
	ErrWrongArguments                  = dbterror.ClassOptimizer.NewStd(mysql.ErrWrongArguments)
	ErrWrongNumberOfColumnsInSelect    = dbterror.ClassOptimizer.NewStd(mysql.ErrWrongNumberOfColumnsInSelect)
	ErrBadGeneratedColumn              = dbterror.ClassOptimizer.NewStd(mysql.ErrBadGeneratedColumn)
	ErrFieldNotInGroupBy               = dbterror.ClassOptimizer.NewStd(mysql.ErrFieldNotInGroupBy)
	ErrAggregateOrderNonAggQuery       = dbterror.ClassOptimizer.NewStd(mysql.ErrAggregateOrderNonAggQuery)
	ErrFieldInOrderNotSelect           = dbterror.ClassOptimizer.NewStd(mysql.ErrFieldInOrderNotSelect)
	ErrAggregateInOrderNotSelect       = dbterror.ClassOptimizer.NewStd(mysql.ErrAggregateInOrderNotSelect)
	ErrBadTable                        = dbterror.ClassOptimizer.NewStd(mysql.ErrBadTable)
	ErrKeyDoesNotExist                 = dbterror.ClassOptimizer.NewStd(mysql.ErrKeyDoesNotExist)
	ErrOperandColumns                  = dbterror.ClassOptimizer.NewStd(mysql.ErrOperandColumns)
	ErrInvalidGroupFuncUse             = dbterror.ClassOptimizer.NewStd(mysql.ErrInvalidGroupFuncUse)
	ErrIllegalReference                = dbterror.ClassOptimizer.NewStd(mysql.ErrIllegalReference)
	ErrNoDB                            = dbterror.ClassOptimizer.NewStd(mysql.ErrNoDB)
	ErrUnknownExplainFormat            = dbterror.ClassOptimizer.NewStd(mysql.ErrUnknownExplainFormat)
	ErrWrongGroupField                 = dbterror.ClassOptimizer.NewStd(mysql.ErrWrongGroupField)
	ErrDupFieldName                    = dbterror.ClassOptimizer.NewStd(mysql.ErrDupFieldName)
	ErrNonUpdatableTable               = dbterror.ClassOptimizer.NewStd(mysql.ErrNonUpdatableTable)
	ErrMultiUpdateKeyConflict          = dbterror.ClassOptimizer.NewStd(mysql.ErrMultiUpdateKeyConflict)
	ErrInternal                        = dbterror.ClassOptimizer.NewStd(mysql.ErrInternal)
	ErrNonUniqTable                    = dbterror.ClassOptimizer.NewStd(mysql.ErrNonuniqTable)
	ErrWindowInvalidWindowFuncUse      = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowInvalidWindowFuncUse)
	ErrWindowInvalidWindowFuncAliasUse = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowInvalidWindowFuncAliasUse)
	ErrWindowNoSuchWindow              = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowNoSuchWindow)
	ErrWindowCircularityInWindowGraph  = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowCircularityInWindowGraph)
	ErrWindowNoChildPartitioning       = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowNoChildPartitioning)
	ErrWindowNoInherentFrame           = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowNoInherentFrame)
	ErrWindowNoRedefineOrderBy         = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowNoRedefineOrderBy)
	ErrWindowDuplicateName             = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowDuplicateName)
	ErrPartitionClauseOnNonpartitioned = dbterror.ClassOptimizer.NewStd(mysql.ErrPartitionClauseOnNonpartitioned)
	ErrWindowFrameStartIllegal         = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowFrameStartIllegal)
	ErrWindowFrameEndIllegal           = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowFrameEndIllegal)
	ErrWindowFrameIllegal              = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowFrameIllegal)
	ErrWindowRangeFrameOrderType       = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowRangeFrameOrderType)
	ErrWindowRangeFrameTemporalType    = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowRangeFrameTemporalType)
	ErrWindowRangeFrameNumericType     = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowRangeFrameNumericType)
	ErrWindowRangeBoundNotConstant     = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowRangeBoundNotConstant)
	ErrWindowRowsIntervalUse           = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowRowsIntervalUse)
	ErrWindowFunctionIgnoresFrame      = dbterror.ClassOptimizer.NewStd(mysql.ErrWindowFunctionIgnoresFrame)
	ErrUnsupportedOnGeneratedColumn    = dbterror.ClassOptimizer.NewStd(mysql.ErrUnsupportedOnGeneratedColumn)
	ErrPrivilegeCheckFail              = dbterror.ClassOptimizer.NewStd(mysql.ErrPrivilegeCheckFail)
	ErrInvalidWildCard                 = dbterror.ClassOptimizer.NewStd(mysql.ErrInvalidWildCard)
	ErrMixOfGroupFuncAndFields         = dbterror.ClassOptimizer.NewStd(mysql.ErrMixOfGroupFuncAndFieldsIncompatible)

	ErrDBaccessDenied                        = dbterror.ClassOptimizer.NewStd(mysql.ErrDBaccessDenied)
	ErrTableaccessDenied                     = dbterror.ClassOptimizer.NewStd(mysql.ErrTableaccessDenied)
	ErrSpecificAccessDenied                  = dbterror.ClassOptimizer.NewStd(mysql.ErrSpecificAccessDenied)
	ErrViewNoExplain                         = dbterror.ClassOptimizer.NewStd(mysql.ErrViewNoExplain)
	ErrWrongValueCountOnRow                  = dbterror.ClassOptimizer.NewStd(mysql.ErrWrongValueCountOnRow)
	ErrViewInvalid                           = dbterror.ClassOptimizer.NewStd(mysql.ErrViewInvalid)
	ErrNoSuchThread                          = dbterror.ClassOptimizer.NewStd(mysql.ErrNoSuchThread)
	ErrUnknownColumn                         = dbterror.ClassOptimizer.NewStd(mysql.ErrBadField)
	ErrCartesianProductUnsupported           = dbterror.ClassOptimizer.NewStd(mysql.ErrCartesianProductUnsupported)
	ErrStmtNotFound                          = dbterror.ClassOptimizer.NewStd(mysql.ErrPreparedStmtNotFound)
	ErrAmbiguous                             = dbterror.ClassOptimizer.NewStd(mysql.ErrNonUniq)
	ErrUnresolvedHintName                    = dbterror.ClassOptimizer.NewStd(mysql.ErrUnresolvedHintName)
	ErrNotHintUpdatable                      = dbterror.ClassOptimizer.NewStd(mysql.ErrNotHintUpdatable)
	ErrWarnConflictingHint                   = dbterror.ClassOptimizer.NewStd(mysql.ErrWarnConflictingHint)
	ErrCTERecursiveRequiresUnion             = dbterror.ClassOptimizer.NewStd(mysql.ErrCTERecursiveRequiresUnion)
	ErrCTERecursiveRequiresNonRecursiveFirst = dbterror.ClassOptimizer.NewStd(mysql.ErrCTERecursiveRequiresNonRecursiveFirst)
	ErrCTERecursiveForbidsAggregation        = dbterror.ClassOptimizer.NewStd(mysql.ErrCTERecursiveForbidsAggregation)
	ErrCTERecursiveForbiddenJoinOrder        = dbterror.ClassOptimizer.NewStd(mysql.ErrCTERecursiveForbiddenJoinOrder)
	ErrInvalidRequiresSingleReference        = dbterror.ClassOptimizer.NewStd(mysql.ErrInvalidRequiresSingleReference)
	ErrSQLInReadOnlyMode                     = dbterror.ClassOptimizer.NewStd(mysql.ErrReadOnlyMode)
	// Since we cannot know if user logged in with a password, use message of ErrAccessDeniedNoPassword instead
	ErrAccessDenied              = dbterror.ClassOptimizer.NewStdErr(mysql.ErrAccessDenied, mysql.MySQLErrName[mysql.ErrAccessDeniedNoPassword])
	ErrBadNull                   = dbterror.ClassOptimizer.NewStd(mysql.ErrBadNull)
	ErrNotSupportedWithSem       = dbterror.ClassOptimizer.NewStd(mysql.ErrNotSupportedWithSem)
	ErrAsOf                      = dbterror.ClassOptimizer.NewStd(mysql.ErrAsOf)
	ErrOptOnTemporaryTable       = dbterror.ClassOptimizer.NewStd(mysql.ErrOptOnTemporaryTable)
	ErrOptOnCacheTable           = dbterror.ClassOptimizer.NewStd(mysql.ErrOptOnCacheTable)
	ErrDropTableOnTemporaryTable = dbterror.ClassOptimizer.NewStd(mysql.ErrDropTableOnTemporaryTable)
	// ErrPartitionNoTemporary returns when partition at temporary mode
	ErrPartitionNoTemporary     = dbterror.ClassOptimizer.NewStd(mysql.ErrPartitionNoTemporary)
	ErrViewSelectTemporaryTable = dbterror.ClassOptimizer.NewStd(mysql.ErrViewSelectTmptable)
	ErrSubqueryMoreThan1Row     = dbterror.ClassOptimizer.NewStd(mysql.ErrSubqueryNo1Row)
	ErrKeyPart0                 = dbterror.ClassOptimizer.NewStd(mysql.ErrKeyPart0)
	ErrGettingNoopVariable      = dbterror.ClassOptimizer.NewStd(mysql.ErrGettingNoopVariable)

	ErrPrepareMulti     = dbterror.ClassExecutor.NewStd(mysql.ErrPrepareMulti)
	ErrUnsupportedPs    = dbterror.ClassExecutor.NewStd(mysql.ErrUnsupportedPs)
	ErrPsManyParam      = dbterror.ClassExecutor.NewStd(mysql.ErrPsManyParam)
	ErrPrepareDDL       = dbterror.ClassExecutor.NewStd(mysql.ErrPrepareDDL)
	ErrRowIsReferenced2 = dbterror.ClassOptimizer.NewStd(mysql.ErrRowIsReferenced2)
	ErrNoReferencedRow2 = dbterror.ClassOptimizer.NewStd(mysql.ErrNoReferencedRow2)
)

error definitions.

View Source
var (
	// PreparedPlanCacheMaxMemory stores the max memory size defined in the global config "performance-server-memory-quota".
	PreparedPlanCacheMaxMemory = *atomic2.NewUint64(math.MaxUint64)

	// ExtractSelectAndNormalizeDigest extract the select statement and normalize it.
	ExtractSelectAndNormalizeDigest func(stmtNode ast.StmtNode, specifiledDB string) (ast.StmtNode, string, string, error)
)
View Source
var AllowCartesianProduct = atomic.NewBool(true)

AllowCartesianProduct means whether tidb allows cartesian join without equal conditions.

CMSketchSizeLimit indicates the size limit of CMSketch.

View Source
var DefaultDisabledLogicalRulesList *atomic.Value

DefaultDisabledLogicalRulesList indicates the logical rules which should be banned.

View Source
var EvalSubqueryFirstRow func(ctx context.Context, p PhysicalPlan, is infoschema.InfoSchema, sctx sessionctx.Context) (row []types.Datum, err error)

EvalSubqueryFirstRow evaluates incorrelated subqueries once, and get first row.

View Source
var ForceUseOuterBuild4Test = atomic.NewBool(false)

ForceUseOuterBuild4Test is a test option to control forcing use outer input as build. TODO: use hint and remove this variable

View Source
var ForcedHashLeftJoin4Test = atomic.NewBool(false)

ForcedHashLeftJoin4Test is a test option to force using HashLeftJoin TODO: use hint and remove this variable

View Source
var IsReadOnly func(node ast.Node, vars *variable.SessionVars) bool

IsReadOnly check whether the ast.Node is a read only statement.

View Source
var OptimizeAstNode func(ctx context.Context, sctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema) (Plan, types.NameSlice, error)

OptimizeAstNode optimizes the query to a physical plan directly.

Functions

func AllocMPPQueryID

func AllocMPPQueryID() uint64

AllocMPPQueryID allocates local query id for mpp queries.

func AllocMPPTaskID

func AllocMPPTaskID(ctx sessionctx.Context) int64

AllocMPPTaskID allocates task id for mpp tasks. It will reset the task id when the query finished.

func BinaryPlanStrFromFlatPlan

func BinaryPlanStrFromFlatPlan(explainCtx sessionctx.Context, flat *FlatPhysicalPlan) string

BinaryPlanStrFromFlatPlan generates the compressed and encoded binary plan from a FlatPhysicalPlan.

func BuildPhysicalJoinSchema

func BuildPhysicalJoinSchema(joinType JoinType, join PhysicalPlan) *expression.Schema

BuildPhysicalJoinSchema builds the schema of PhysicalJoin from it's children's schema.

func Cacheable

func Cacheable(node ast.Node, is infoschema.InfoSchema) bool

Cacheable checks whether the input ast is cacheable with empty session context, which is mainly for testing.

func CacheableWithCtx

func CacheableWithCtx(sctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema) (bool, string)

CacheableWithCtx checks whether the input ast is cacheable. Handle "ignore_plan_cache()" hint If there are multiple hints, only one will take effect

func CheckAggCanPushCop

func CheckAggCanPushCop(sctx sessionctx.Context, aggFuncs []*aggregation.AggFuncDesc, groupByItems []expression.Expression, storeType kv.StoreType) bool

CheckAggCanPushCop checks whether the aggFuncs and groupByItems can be pushed down to coprocessor.

func CheckParamTypeInt64orUint64

func CheckParamTypeInt64orUint64(param *driver.ParamMarkerExpr) (bool, uint64)

CheckParamTypeInt64orUint64 check param type for plan cache limit, only allow int64 and uint64 now eg: set @a = 1;

func CheckPreparedPriv

func CheckPreparedPriv(sctx sessionctx.Context, stmt *PlanCacheStmt, is infoschema.InfoSchema) error

CheckPreparedPriv checks the privilege of the prepared statement

func CheckPrivilege

func CheckPrivilege(activeRoles []*auth.RoleIdentity, pm privilege.Manager, vs []visitInfo) error

CheckPrivilege checks the privilege for a user.

func CheckTableLock

func CheckTableLock(ctx sessionctx.Context, is infoschema.InfoSchema, vs []visitInfo) error

CheckTableLock checks the table lock.

func CheckUpdateList

func CheckUpdateList(assignFlags []int, updt *Update, newTblID2Table map[int64]table.Table) error

CheckUpdateList checks all related columns in updatable state.

func CollectColumnStatsUsage

func CollectColumnStatsUsage(lp LogicalPlan, predicate, histNeeded bool) ([]model.TableItemID, []model.TableItemID)

CollectColumnStatsUsage collects column stats usage from logical plan. predicate indicates whether to collect predicate columns and histNeeded indicates whether to collect histogram-needed columns. The first return value is predicate columns(nil if predicate is false) and the second return value is histogram-needed columns(nil if histNeeded is false).

func CollectPlanStatsVersion

func CollectPlanStatsVersion(plan PhysicalPlan, statsInfos map[string]uint64) map[string]uint64

CollectPlanStatsVersion uses to collect the statistics version of the plan.

func DeleteTrueExprs

func DeleteTrueExprs(p LogicalPlan, conds []expression.Expression) []expression.Expression

DeleteTrueExprs deletes the surely true expressions

func DeriveOtherConditions

func DeriveOtherConditions(
	p *LogicalJoin, leftSchema *expression.Schema, rightSchema *expression.Schema,
	deriveLeft bool, deriveRight bool) (
	leftCond []expression.Expression, rightCond []expression.Expression)

DeriveOtherConditions given a LogicalJoin, check the OtherConditions to see if we can derive more conditions for left/right child pushdown.

func EncodeFlatPlan

func EncodeFlatPlan(flat *FlatPhysicalPlan) string

EncodeFlatPlan encodes a FlatPhysicalPlan with compression.

func EncodePlan

func EncodePlan(p Plan) string

EncodePlan is used to encodePlan the plan to the plan tree with compressing. Deprecated: FlattenPhysicalPlan() + EncodeFlatPlan() is preferred.

func EraseLastSemicolon

func EraseLastSemicolon(stmt ast.StmtNode)

EraseLastSemicolon removes last semicolon of sql.

func EraseLastSemicolonInSQL

func EraseLastSemicolonInSQL(sql string) string

EraseLastSemicolonInSQL removes last semicolon of the SQL.

func ExpandVirtualColumn

func ExpandVirtualColumn(columns []*model.ColumnInfo, schema *expression.Schema,
	colsInfo []*model.ColumnInfo) []*model.ColumnInfo

ExpandVirtualColumn expands the virtual column's dependent columns to ts's schema and column.

func ExprsHasSideEffects

func ExprsHasSideEffects(exprs []expression.Expression) bool

ExprsHasSideEffects checks if any of the expressions has side effects.

func ExtractCorColumnsBySchema

func ExtractCorColumnsBySchema(corCols []*expression.CorrelatedColumn, schema *expression.Schema, resolveIndex bool) []*expression.CorrelatedColumn

ExtractCorColumnsBySchema only extracts the correlated columns that match the specified schema. e.g. If the correlated columns from plan are [t1.a, t2.a, t3.a] and specified schema is [t2.a, t2.b, t2.c], only [t2.a] is returned.

func ExtractCorColumnsBySchema4PhysicalPlan

func ExtractCorColumnsBySchema4PhysicalPlan(p PhysicalPlan, schema *expression.Schema) []*expression.CorrelatedColumn

ExtractCorColumnsBySchema4PhysicalPlan only extracts the correlated columns that match the specified schema. e.g. If the correlated columns from plan are [t1.a, t2.a, t3.a] and specified schema is [t2.a, t2.b, t2.c], only [t2.a] is returned.

func ExtractCorrelatedCols4LogicalPlan

func ExtractCorrelatedCols4LogicalPlan(p LogicalPlan) []*expression.CorrelatedColumn

ExtractCorrelatedCols4LogicalPlan recursively extracts all of the correlated columns from a plan tree by calling LogicalPlan.ExtractCorrelatedCols.

func ExtractCorrelatedCols4PhysicalPlan

func ExtractCorrelatedCols4PhysicalPlan(p PhysicalPlan) []*expression.CorrelatedColumn

ExtractCorrelatedCols4PhysicalPlan recursively extracts all of the correlated columns from a plan tree by calling PhysicalPlan.ExtractCorrelatedCols.

func ExtractLimitFromAst

func ExtractLimitFromAst(node ast.Node, sctx sessionctx.Context) ([]uint64, error)

ExtractLimitFromAst extract limit offset and count from ast for plan cache key encode

func FDToString

func FDToString(p LogicalPlan) string

FDToString explains fd transfer over a Plan, returns description string.

func FindColumnInfoByID

func FindColumnInfoByID(colInfos []*model.ColumnInfo, id int64) *model.ColumnInfo

FindColumnInfoByID finds ColumnInfo in cols by ID.

func GenHintsFromFlatPlan

func GenHintsFromFlatPlan(flat *FlatPhysicalPlan) []*ast.TableOptimizerHint

GenHintsFromFlatPlan generates hints from a FlatPhysicalPlan.

func GenHintsFromPhysicalPlan

func GenHintsFromPhysicalPlan(p Plan) []*ast.TableOptimizerHint

GenHintsFromPhysicalPlan generates hints from physical plan. Deprecated: FlattenPhysicalPlan() + GenHintsFromFlatPlan() is preferred.

func GeneratePlanCacheStmtWithAST

func GeneratePlanCacheStmtWithAST(ctx context.Context, sctx sessionctx.Context, paramSQL string, paramStmt ast.StmtNode) (*PlanCacheStmt, Plan, int, error)

GeneratePlanCacheStmtWithAST generates the PlanCacheStmt structure for this AST. paramSQL is the corresponding parameterized sql like 'select * from t where a<? and b>?'. paramStmt is the Node of paramSQL.

func GetBindSQL4PlanCache

func GetBindSQL4PlanCache(sctx sessionctx.Context, stmt *PlanCacheStmt) (string, bool)

GetBindSQL4PlanCache used to get the bindSQL for plan cache to build the plan cache key.

func GetCommonHandleDatum

func GetCommonHandleDatum(cols HandleCols, row chunk.Row) []types.Datum

GetCommonHandleDatum gets the original data for the common handle.

func GetDBTableInfo

func GetDBTableInfo(visitInfo []visitInfo) []stmtctx.TableEntry

GetDBTableInfo gets the accessed dbs and tables info.

func GetDupAgnosticAggCols

func GetDupAgnosticAggCols(
	p LogicalPlan,
	oldAggCols []*expression.Column,
) (isAgg bool, newAggCols []*expression.Column)

GetDupAgnosticAggCols checks whether a LogicalPlan is LogicalAggregation. It extracts all the columns from the duplicate agnostic aggregate functions. The returned column set is nil if not all the aggregate functions are duplicate agnostic. Only the following functions are considered to be duplicate agnostic:

  1. MAX(arg)
  2. MIN(arg)
  3. FIRST_ROW(arg)
  4. Other agg functions with DISTINCT flag, like SUM(DISTINCT arg)

func GetExplainAnalyzeRowsForPlan

func GetExplainAnalyzeRowsForPlan(plan *Explain) (rows [][]string)

GetExplainAnalyzeRowsForPlan get explain rows for plan.

func GetExplainRowsForPlan

func GetExplainRowsForPlan(plan Plan) (rows [][]string)

GetExplainRowsForPlan get explain rows for plan.

func GetPhysicalIDsAndPartitionNames

func GetPhysicalIDsAndPartitionNames(tblInfo *model.TableInfo, partitionNames []model.CIStr) ([]int64, []string, error)

GetPhysicalIDsAndPartitionNames returns physical IDs and names of these partitions.

func GetPlanCost

func GetPlanCost(p PhysicalPlan, taskType property.TaskType, option *PlanCostOption) (float64, error)

GetPlanCost returns the cost of this plan.

func GetPropByOrderByItems

func GetPropByOrderByItems(items []*util.ByItems) (*property.PhysicalProperty, bool)

GetPropByOrderByItems will check if this sort property can be pushed or not. In order to simplify the problem, we only consider the case that all expression are columns.

func GetPropByOrderByItemsContainScalarFunc

func GetPropByOrderByItemsContainScalarFunc(items []*util.ByItems) (*property.PhysicalProperty, bool, bool)

GetPropByOrderByItemsContainScalarFunc will check if this sort property can be pushed or not. In order to simplify the problem, we only consider the case that all expression are columns or some special scalar functions.

func GetStats4Test

func GetStats4Test(p LogicalPlan) *property.StatsInfo

GetStats4Test is a exporter just for test.

func GetStatsInfo

func GetStatsInfo(i interface{}) map[string]uint64

GetStatsInfo gets the statistics info from a physical plan tree. Deprecated: FlattenPhysicalPlan() + GetStatsInfoFromFlatPlan() is preferred.

func GetStatsInfoFromFlatPlan

func GetStatsInfoFromFlatPlan(flat *FlatPhysicalPlan) map[string]uint64

GetStatsInfoFromFlatPlan gets the statistics info from a FlatPhysicalPlan.

func GetUpdateColumnsInfo

func GetUpdateColumnsInfo(tblID2Table map[int64]table.Table, tblColPosInfos TblColPosInfoSlice, size int) []*table.Column

GetUpdateColumnsInfo get the update columns info.

func HasMaxOneRow

func HasMaxOneRow(p LogicalPlan, childMaxOneRow []bool) bool

HasMaxOneRow returns if the LogicalPlan will output at most one row.

func InPrepare

func InPrepare(p *preprocessor)

InPrepare is a PreprocessOpt that indicates preprocess is executing under prepare statement.

func InTxnRetry

func InTxnRetry(p *preprocessor)

InTxnRetry is a PreprocessOpt that indicates preprocess is executing under transaction retry.

func InitTxnContextProvider

func InitTxnContextProvider(p *preprocessor)

InitTxnContextProvider is a PreprocessOpt that indicates preprocess should init transaction's context

func IsAutoCommitTxn

func IsAutoCommitTxn(ctx sessionctx.Context) bool

IsAutoCommitTxn checks if session is in autocommit mode and not InTxn used for fast plan like point get

func IsColsAllFromOuterTable

func IsColsAllFromOuterTable(cols []*expression.Column, outerUniqueIDs set.Int64Set) bool

IsColsAllFromOuterTable check whether the cols all from outer plan

func IsDefaultExprSameColumn

func IsDefaultExprSameColumn(names types.NameSlice, node ast.ExprNode) bool

IsDefaultExprSameColumn - DEFAULT or col = DEFAULT(col)

func IsPointGetWithPKOrUniqueKeyByAutoCommit

func IsPointGetWithPKOrUniqueKeyByAutoCommit(ctx sessionctx.Context, p Plan) (bool, error)

IsPointGetWithPKOrUniqueKeyByAutoCommit returns true when meets following conditions:

  1. ctx is auto commit tagged
  2. session is not InTxn
  3. plan is point get by pk, or point get by unique index (no double read)

func IsPointPlanShortPathOK

func IsPointPlanShortPathOK(sctx sessionctx.Context, is infoschema.InfoSchema, stmt *PlanCacheStmt) (bool, error)

IsPointPlanShortPathOK check if we can execute using plan cached in prepared structure Be careful with the short path, current precondition is ths cached plan satisfying IsPointGetWithPKOrUniqueKeyByAutoCommit

func IsSelectForUpdateLockType

func IsSelectForUpdateLockType(lockType ast.SelectLockType) bool

IsSelectForUpdateLockType checks if the select lock type is for update type.

func IsTiFlashContained

func IsTiFlashContained(plan Plan) (tiFlashPushDown, tiFlashExchangePushDown bool)

IsTiFlashContained returns whether the plan contains TiFlash related executors.

func JSONToString

func JSONToString(j []*ExplainInfoForEncode) (string, error)

JSONToString convert json to string

func MatchItems

func MatchItems(p *property.PhysicalProperty, items []*util.ByItems) bool

MatchItems checks if this prop's columns can match by items totally.

func MockContext

func MockContext() sessionctx.Context

MockContext is only used for plan related tests.

func MockHashPartitionTable

func MockHashPartitionTable() *model.TableInfo

MockHashPartitionTable mocks a hash partition table for test

func MockListPartitionTable

func MockListPartitionTable() *model.TableInfo

MockListPartitionTable mocks a list partition table for test

func MockNoPKTable

func MockNoPKTable() *model.TableInfo

MockNoPKTable is only used for plan related tests.

func MockPartitionInfoSchema

func MockPartitionInfoSchema(definitions []model.PartitionDefinition) infoschema.InfoSchema

MockPartitionInfoSchema mocks an info schema for partition table.

func MockRangePartitionTable

func MockRangePartitionTable() *model.TableInfo

MockRangePartitionTable mocks a range partition table for test

func MockSignedTable

func MockSignedTable() *model.TableInfo

MockSignedTable is only used for plan related tests.

func MockStateNoneColumnTable

func MockStateNoneColumnTable() *model.TableInfo

MockStateNoneColumnTable is only used for plan related tests.

func MockUnsignedTable

func MockUnsignedTable() *model.TableInfo

MockUnsignedTable is only used for plan related tests.

func MockView

func MockView() *model.TableInfo

MockView is only used for plan related tests.

func NewPlanCacheKey

func NewPlanCacheKey(sessionVars *variable.SessionVars, stmtText, stmtDB string, schemaVersion int64,
	lastUpdatedSchemaVersion int64, bindSQL string) (kvcache.Key, error)

NewPlanCacheKey creates a new planCacheKey object. Note: lastUpdatedSchemaVersion will only be set in the case of rc or for update read in order to differentiate the cache key. In other cases, it will be 0.

func NewProjInjector

func NewProjInjector() *projInjector

NewProjInjector builds a projInjector.

func NonPreparedPlanCacheable

func NonPreparedPlanCacheable(node ast.Node, is infoschema.InfoSchema) bool

NonPreparedPlanCacheable checks whether the input ast is cacheable for non-prepared plan cache with empty session context, which is mainly for testing.

func NonPreparedPlanCacheableWithCtx

func NonPreparedPlanCacheableWithCtx(sctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema) bool

NonPreparedPlanCacheableWithCtx checks whether the input ast is cacheable for non-prepared plan cache. Only support: select {field} from {single-table} where {cond} and {cond} ... {cond}: {col} {op} {val} {op}: >, <, =

func NormalizeFlatPlan

func NormalizeFlatPlan(flat *FlatPhysicalPlan) (normalized string, digest *parser.Digest)

NormalizeFlatPlan normalizes a FlatPhysicalPlan and generates plan digest.

func NormalizePlan

func NormalizePlan(p Plan) (normalized string, digest *parser.Digest)

NormalizePlan is used to normalize the plan and generate plan digest. Deprecated: FlattenPhysicalPlan() + NormalizeFlatPlan() is preferred.

func ParameterizeAST

func ParameterizeAST(ctx context.Context, sctx sessionctx.Context, stmt ast.StmtNode) (paramSQL string, params []*driver.ValueExpr, err error)

ParameterizeAST parameterizes this StmtNode. e.g. `select * from t where a<10 and b<23` --> `select * from t where a<? and b<?`, [10, 23]. NOTICE: this function may modify the input stmt.

func Params2Expressions

func Params2Expressions(params []*driver.ValueExpr) []expression.Expression

Params2Expressions converts these parameters to an expression list.

func PartitionPruning

func PartitionPruning(ctx sessionctx.Context, tbl table.PartitionedTable, conds []expression.Expression, partitionNames []model.CIStr,
	columns []*expression.Column, names types.NameSlice) ([]int, error)

PartitionPruning finds all used partitions according to query conditions, it will return nil if condition match none of partitions. The return value is a array of the idx in the partition definitions array, use pi.Definitions[idx] to get the partition ID

func Preprocess

func Preprocess(ctx context.Context, sctx sessionctx.Context, node ast.Node, preprocessOpt ...PreprocessOpt) error

Preprocess resolves table names of the node, and checks some statements' validation. preprocessReturn used to extract the infoschema for the tableName and the timestamp from the asof clause.

func RebuildPlan4CachedPlan

func RebuildPlan4CachedPlan(p Plan) error

RebuildPlan4CachedPlan will rebuild this plan under current user parameters.

func RecursiveDeriveStats4Test

func RecursiveDeriveStats4Test(p LogicalPlan) (*property.StatsInfo, error)

RecursiveDeriveStats4Test is a exporter just for test.

func RemoveUnnecessaryFirstRow

func RemoveUnnecessaryFirstRow(
	sctx sessionctx.Context,
	finalGbyItems []expression.Expression,
	partialAggFuncs []*aggregation.AggFuncDesc,
	partialGbyItems []expression.Expression,
	partialSchema *expression.Schema,
	firstRowFuncMap map[*aggregation.AggFuncDesc]*aggregation.AggFuncDesc) []*aggregation.AggFuncDesc

RemoveUnnecessaryFirstRow removes unnecessary FirstRow of the aggregation. This function can be used for both LogicalAggregation and PhysicalAggregation. When the select column is same with the group by key, the column can be removed and gets value from the group by key. e.g select a, count(b) from t group by a; The schema is [firstrow(a), count(b), a]. The column firstrow(a) is unnecessary. Can optimize the schema to [count(b), a] , and change the index to get value.

func ReplaceColumnOfExpr

func ReplaceColumnOfExpr(expr expression.Expression, proj *LogicalProjection, schema *expression.Schema) expression.Expression

ReplaceColumnOfExpr replaces column of expression by another LogicalProjection.

func RequestLoadStats

func RequestLoadStats(ctx sessionctx.Context, neededHistItems []model.TableItemID, syncWait int64) error

RequestLoadStats send load column/index stats requests to stats handle

func ResolveExprAndReplace

func ResolveExprAndReplace(origin expression.Expression, replace map[string]*expression.Column)

ResolveExprAndReplace replaces columns fields of expressions by children logical plans.

func RestoreASTWithParams

func RestoreASTWithParams(ctx context.Context, _ sessionctx.Context, stmt ast.StmtNode, params []*driver.ValueExpr) error

RestoreASTWithParams restore this parameterized AST with specific parameters. e.g. `select * from t where a<? and b<?`, [10, 23] --> `select * from t where a<10 and b<23`.

func SetPstmtIDSchemaVersion

func SetPstmtIDSchemaVersion(key kvcache.Key, stmtText string, schemaVersion int64, isolationReadEngines map[kv.StoreType]struct{})

SetPstmtIDSchemaVersion implements PstmtCacheKeyMutator interface to change pstmtID and schemaVersion of cacheKey. so we can reuse Key instead of new every time.

func SplitSelCondsWithVirtualColumn

func SplitSelCondsWithVirtualColumn(conds []expression.Expression) (withoutVirt []expression.Expression, withVirt []expression.Expression)

SplitSelCondsWithVirtualColumn filter the select conditions which contain virtual column

func SyncWaitStatsLoad

func SyncWaitStatsLoad(plan LogicalPlan) error

SyncWaitStatsLoad sync-wait for stats load until timeout

func ToString

func ToString(p Plan) string

ToString explains a Plan, returns description string.

func TryAddExtraLimit

func TryAddExtraLimit(ctx sessionctx.Context, node ast.StmtNode) ast.StmtNode

TryAddExtraLimit trys to add an extra limit for SELECT or UNION statement when sql_select_limit is set.

func VisitInfo4PrivCheck

func VisitInfo4PrivCheck(is infoschema.InfoSchema, node ast.Node, vs []visitInfo) (privVisitInfo []visitInfo)

VisitInfo4PrivCheck generates privilege check infos because privilege check of local temporary tables is different with normal tables. `CREATE` statement needs `CREATE TEMPORARY TABLE` privilege from the database, and subsequent statements do not need any privileges.

Types

type AccessObject

type AccessObject interface {
	String() string
	NormalizedString() string
	// SetIntoPB transform itself into a protobuf message and set into the binary plan.
	SetIntoPB(*tipb.ExplainOperator)
}

AccessObject represents what is accessed by an operator. It corresponds to the "access object" column in an EXPLAIN statement result.

type AdminPlugins

type AdminPlugins struct {
	Action  AdminPluginsAction
	Plugins []string
	// contains filtered or unexported fields
}

AdminPlugins administrates tidb plugins.

func (*AdminPlugins) MemoryUsage

func (s *AdminPlugins) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*AdminPlugins) OutputNames

func (s *AdminPlugins) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*AdminPlugins) ResolveIndices

func (p *AdminPlugins) ResolveIndices() (err error)

func (*AdminPlugins) Schema

func (s *AdminPlugins) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*AdminPlugins) SetOutputNames

func (s *AdminPlugins) SetOutputNames(names types.NameSlice)

func (*AdminPlugins) SetSchema

func (s *AdminPlugins) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type AdminPluginsAction

type AdminPluginsAction int

AdminPluginsAction indicate action will be taken on plugins.

const (
	// Enable indicates enable plugins.
	Enable AdminPluginsAction = iota + 1
	// Disable indicates disable plugins.
	Disable
)

type AdminResetTelemetryID

type AdminResetTelemetryID struct {
	// contains filtered or unexported fields
}

AdminResetTelemetryID regenerates a new telemetry tracking ID.

func (*AdminResetTelemetryID) MemoryUsage

func (s *AdminResetTelemetryID) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*AdminResetTelemetryID) OutputNames

func (s *AdminResetTelemetryID) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*AdminResetTelemetryID) ResolveIndices

func (p *AdminResetTelemetryID) ResolveIndices() (err error)

func (*AdminResetTelemetryID) Schema

func (s *AdminResetTelemetryID) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*AdminResetTelemetryID) SetOutputNames

func (s *AdminResetTelemetryID) SetOutputNames(names types.NameSlice)

func (*AdminResetTelemetryID) SetSchema

func (s *AdminResetTelemetryID) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type AdminShowTelemetry

type AdminShowTelemetry struct {
	// contains filtered or unexported fields
}

AdminShowTelemetry displays telemetry status including tracking ID, status and so on.

func (*AdminShowTelemetry) MemoryUsage

func (s *AdminShowTelemetry) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*AdminShowTelemetry) OutputNames

func (s *AdminShowTelemetry) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*AdminShowTelemetry) ResolveIndices

func (p *AdminShowTelemetry) ResolveIndices() (err error)

func (*AdminShowTelemetry) Schema

func (s *AdminShowTelemetry) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*AdminShowTelemetry) SetOutputNames

func (s *AdminShowTelemetry) SetOutputNames(names types.NameSlice)

func (*AdminShowTelemetry) SetSchema

func (s *AdminShowTelemetry) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type AggInfo

type AggInfo struct {
	AggFuncs     []*aggregation.AggFuncDesc
	GroupByItems []expression.Expression
	Schema       *expression.Schema
}

AggInfo stores the information of an Aggregation.

func BuildFinalModeAggregation

func BuildFinalModeAggregation(
	sctx sessionctx.Context, original *AggInfo, partialIsCop bool, isMPPTask bool) (partial, final *AggInfo, firstRowFuncMap map[*aggregation.AggFuncDesc]*aggregation.AggFuncDesc)

BuildFinalModeAggregation splits either LogicalAggregation or PhysicalAggregation to finalAgg and partial1Agg, returns the information of partial and final agg. partialIsCop means whether partial agg is a cop task. When partialIsCop is false, we do not set the AggMode for partialAgg cause it may be split further when building the aggregate executor(e.g. buildHashAgg will split the AggDesc further for parallel executing). firstRowFuncMap is a map between partial first_row to final first_row, will be used in RemoveUnnecessaryFirstRow

type AggMppRunMode

type AggMppRunMode int

AggMppRunMode defines the running mode of aggregation in MPP

const (
	// NoMpp means the default value which does not run in MPP
	NoMpp AggMppRunMode = iota
	// Mpp1Phase runs only 1 phase but requires its child's partition property
	Mpp1Phase
	// Mpp2Phase runs partial agg + final agg with hash partition
	Mpp2Phase
	// MppTiDB runs agg on TiDB (and a partial agg on TiFlash if in 2 phase agg)
	MppTiDB
	// MppScalar also has 2 phases. The second phase runs in a single task.
	MppScalar
)

type AggregateFuncExtractor

type AggregateFuncExtractor struct {

	// AggFuncs is the collected AggregateFuncExprs.
	AggFuncs []*ast.AggregateFuncExpr
	// contains filtered or unexported fields
}

AggregateFuncExtractor visits Expr tree. It collects AggregateFuncExpr from AST Node.

func (*AggregateFuncExtractor) Enter

func (*AggregateFuncExtractor) Enter(n ast.Node) (ast.Node, bool)

Enter implements Visitor interface.

func (*AggregateFuncExtractor) Leave

func (a *AggregateFuncExtractor) Leave(n ast.Node) (ast.Node, bool)

Leave implements Visitor interface.

type Analyze

type Analyze struct {
	ColTasks   []AnalyzeColumnsTask
	IdxTasks   []AnalyzeIndexTask
	Opts       map[ast.AnalyzeOptionType]uint64
	OptionsMap map[int64]V2AnalyzeOptions
	// contains filtered or unexported fields
}

Analyze represents an analyze plan

func (*Analyze) MemoryUsage

func (s *Analyze) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*Analyze) OutputNames

func (s *Analyze) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Analyze) ResolveIndices

func (p *Analyze) ResolveIndices() (err error)

func (*Analyze) Schema

func (s *Analyze) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Analyze) SetOutputNames

func (s *Analyze) SetOutputNames(names types.NameSlice)

func (*Analyze) SetSchema

func (s *Analyze) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type AnalyzeColumnsTask

type AnalyzeColumnsTask struct {
	HandleCols       HandleCols
	CommonHandleInfo *model.IndexInfo
	ColsInfo         []*model.ColumnInfo
	TblInfo          *model.TableInfo
	Indexes          []*model.IndexInfo
	AnalyzeInfo
}

AnalyzeColumnsTask is used for analyze columns.

type AnalyzeIndexTask

type AnalyzeIndexTask struct {
	IndexInfo *model.IndexInfo
	TblInfo   *model.TableInfo
	AnalyzeInfo
}

AnalyzeIndexTask is used for analyze index.

type AnalyzeInfo

type AnalyzeInfo struct {
	DBName        string
	TableName     string
	PartitionName string
	TableID       statistics.AnalyzeTableID
	Incremental   bool
	StatsVersion  int
	V2Options     *V2AnalyzeOptions
}

AnalyzeInfo is used to store the database name, table name and partition name of analyze task.

type BatchPointGetPlan

type BatchPointGetPlan struct {
	TblInfo          *model.TableInfo
	IndexInfo        *model.IndexInfo
	PartitionInfos   []*model.PartitionDefinition
	Handles          []kv.Handle
	HandleType       *types.FieldType
	HandleParams     []*expression.Constant // record all Parameters for Plan-Cache
	IndexValues      [][]types.Datum
	IndexValueParams [][]*expression.Constant // record all Parameters for Plan-Cache
	IndexColTypes    []*types.FieldType
	AccessConditions []expression.Expression
	IdxCols          []*expression.Column
	IdxColLens       []int
	PartitionColPos  int
	PartitionExpr    *tables.PartitionExpr
	KeepOrder        bool
	Desc             bool
	Lock             bool
	LockWaitTime     int64
	Columns          []*model.ColumnInfo

	// SinglePart indicates whether this BatchPointGetPlan is just for a single partition, instead of the whole partition table.
	// If the BatchPointGetPlan is built in fast path, this value if false; if the plan is generated in physical optimization for a partition,
	// this value would be true. This value would decide the behavior of BatchPointGetExec, i.e, whether to compute the table ID of the partition
	// on the fly.
	SinglePart bool
	// PartTblID is the table ID for the specific table partition.
	PartTblID int64
	// contains filtered or unexported fields
}

BatchPointGetPlan represents a physical plan which contains a bunch of keys reference the same table and use the same `unique key`

func (*BatchPointGetPlan) AccessObject

func (p *BatchPointGetPlan) AccessObject() AccessObject

AccessObject implements physicalScan interface.

func (*BatchPointGetPlan) Children

func (*BatchPointGetPlan) Children() []PhysicalPlan

Children gets all the children.

func (*BatchPointGetPlan) Clone

func (p *BatchPointGetPlan) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*BatchPointGetPlan) Cost

func (p *BatchPointGetPlan) Cost() float64

Cost implements PhysicalPlan interface

func (*BatchPointGetPlan) ExplainInfo

func (p *BatchPointGetPlan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*BatchPointGetPlan) ExplainNormalizedInfo

func (p *BatchPointGetPlan) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*BatchPointGetPlan) ExtractCorrelatedCols

func (*BatchPointGetPlan) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*BatchPointGetPlan) GetAvgRowSize

func (p *BatchPointGetPlan) GetAvgRowSize() float64

GetAvgRowSize return the average row size.

func (*BatchPointGetPlan) GetChildReqProps

func (*BatchPointGetPlan) GetChildReqProps(_ int) *property.PhysicalProperty

GetChildReqProps gets the required property by child index.

func (*BatchPointGetPlan) GetCost

func (p *BatchPointGetPlan) GetCost(opt *physicalOptimizeOp) float64

GetCost returns cost of the PointGetPlan.

func (BatchPointGetPlan) Init

Init initializes BatchPointGetPlan.

func (*BatchPointGetPlan) MemoryUsage

func (p *BatchPointGetPlan) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of BatchPointGetPlan

func (*BatchPointGetPlan) OperatorInfo

func (p *BatchPointGetPlan) OperatorInfo(normalized bool) string

OperatorInfo implements dataAccesser interface.

func (*BatchPointGetPlan) OutputNames

func (p *BatchPointGetPlan) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*BatchPointGetPlan) ResolveIndices

func (p *BatchPointGetPlan) ResolveIndices() error

ResolveIndices resolves the indices for columns. After doing this, the columns can evaluate the rows by their indices.

func (*BatchPointGetPlan) Schema

func (s *BatchPointGetPlan) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*BatchPointGetPlan) SetChild

func (*BatchPointGetPlan) SetChild(_ int, _ PhysicalPlan)

SetChild sets a specific child for the plan.

func (*BatchPointGetPlan) SetChildren

func (*BatchPointGetPlan) SetChildren(...PhysicalPlan)

SetChildren sets the children for the plan.

func (*BatchPointGetPlan) SetCost

func (p *BatchPointGetPlan) SetCost(cost float64)

SetCost implements PhysicalPlan interface

func (*BatchPointGetPlan) SetOutputNames

func (p *BatchPointGetPlan) SetOutputNames(names types.NameSlice)

SetOutputNames sets the outputting name by the given slice.

func (*BatchPointGetPlan) SetSchema

func (s *BatchPointGetPlan) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*BatchPointGetPlan) StatsCount

func (p *BatchPointGetPlan) StatsCount() float64

StatsCount will return the the RowCount of property.StatsInfo for this plan.

func (*BatchPointGetPlan) ToPB

func (*BatchPointGetPlan) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB converts physical plan to tipb executor.

type CTEClass

type CTEClass struct {
	// The union between seed part and recursive part is DISTINCT or DISTINCT ALL.
	IsDistinct bool

	// storageID for this CTE.
	IDForStorage int

	HasLimit  bool
	LimitBeg  uint64
	LimitEnd  uint64
	IsInApply bool

	ColumnMap map[string]*expression.Column
	// contains filtered or unexported fields
}

CTEClass holds the information and plan for a CTE. Most of the fields in this struct are the same as cteInfo. But the cteInfo is used when building the plan, and CTEClass is used also for building the executor.

func (*CTEClass) MemoryUsage

func (cc *CTEClass) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of CTEClass

type CTEDefinition

type CTEDefinition PhysicalCTE

CTEDefinition is CTE definition for explain.

func (*CTEDefinition) ExplainID

func (p *CTEDefinition) ExplainID() fmt.Stringer

ExplainID overrides the ExplainID.

func (*CTEDefinition) ExplainInfo

func (p *CTEDefinition) ExplainInfo() string

ExplainInfo overrides the ExplainInfo

func (*CTEDefinition) MemoryUsage

func (p *CTEDefinition) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of CTEDefinition

type CancelDDLJobs

type CancelDDLJobs struct {
	JobIDs []int64
	// contains filtered or unexported fields
}

CancelDDLJobs represents a cancel DDL jobs plan.

func (*CancelDDLJobs) MemoryUsage

func (s *CancelDDLJobs) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*CancelDDLJobs) OutputNames

func (s *CancelDDLJobs) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*CancelDDLJobs) ResolveIndices

func (p *CancelDDLJobs) ResolveIndices() (err error)

func (*CancelDDLJobs) Schema

func (s *CancelDDLJobs) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*CancelDDLJobs) SetOutputNames

func (s *CancelDDLJobs) SetOutputNames(names types.NameSlice)

func (*CancelDDLJobs) SetSchema

func (s *CancelDDLJobs) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type Change

type Change struct {
	*ast.ChangeStmt
	// contains filtered or unexported fields
}

Change represents a change plan.

func (*Change) MemoryUsage

func (s *Change) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*Change) OutputNames

func (s *Change) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Change) ResolveIndices

func (p *Change) ResolveIndices() (err error)

func (*Change) Schema

func (s *Change) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Change) SetOutputNames

func (s *Change) SetOutputNames(names types.NameSlice)

func (*Change) SetSchema

func (s *Change) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type CheckIndexRange

type CheckIndexRange struct {
	Table     *ast.TableName
	IndexName string

	HandleRanges []ast.HandleRange
	// contains filtered or unexported fields
}

CheckIndexRange is used for checking index data, output the index values that handle within begin and end.

func (*CheckIndexRange) MemoryUsage

func (s *CheckIndexRange) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*CheckIndexRange) OutputNames

func (s *CheckIndexRange) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*CheckIndexRange) ResolveIndices

func (p *CheckIndexRange) ResolveIndices() (err error)

func (*CheckIndexRange) Schema

func (s *CheckIndexRange) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*CheckIndexRange) SetOutputNames

func (s *CheckIndexRange) SetOutputNames(names types.NameSlice)

func (*CheckIndexRange) SetSchema

func (s *CheckIndexRange) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type CheckTable

type CheckTable struct {
	DBName             string
	Table              table.Table
	IndexInfos         []*model.IndexInfo
	IndexLookUpReaders []*PhysicalIndexLookUpReader
	CheckIndex         bool
	// contains filtered or unexported fields
}

CheckTable is used for checking table data, built from the 'admin check table' statement.

func (*CheckTable) MemoryUsage

func (s *CheckTable) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*CheckTable) OutputNames

func (s *CheckTable) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*CheckTable) ResolveIndices

func (p *CheckTable) ResolveIndices() (err error)

func (*CheckTable) Schema

func (s *CheckTable) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*CheckTable) SetOutputNames

func (s *CheckTable) SetOutputNames(names types.NameSlice)

func (*CheckTable) SetSchema

func (s *CheckTable) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ChecksumTable

type ChecksumTable struct {
	Tables []*ast.TableName
	// contains filtered or unexported fields
}

ChecksumTable is used for calculating table checksum, built from the `admin checksum table` statement.

func (*ChecksumTable) MemoryUsage

func (s *ChecksumTable) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*ChecksumTable) OutputNames

func (s *ChecksumTable) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*ChecksumTable) ResolveIndices

func (p *ChecksumTable) ResolveIndices() (err error)

func (*ChecksumTable) Schema

func (s *ChecksumTable) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*ChecksumTable) SetOutputNames

func (s *ChecksumTable) SetOutputNames(names types.NameSlice)

func (*ChecksumTable) SetSchema

func (s *ChecksumTable) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type CleanupIndex

type CleanupIndex struct {
	Table     *ast.TableName
	IndexName string
	// contains filtered or unexported fields
}

CleanupIndex is used to delete dangling index data.

func (*CleanupIndex) MemoryUsage

func (s *CleanupIndex) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*CleanupIndex) OutputNames

func (s *CleanupIndex) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*CleanupIndex) ResolveIndices

func (p *CleanupIndex) ResolveIndices() (err error)

func (*CleanupIndex) Schema

func (s *CleanupIndex) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*CleanupIndex) SetOutputNames

func (s *CleanupIndex) SetOutputNames(names types.NameSlice)

func (*CleanupIndex) SetSchema

func (s *CleanupIndex) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ClusterLogTableExtractor

type ClusterLogTableExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component
	SkipRequest bool

	// NodeTypes represents all components types we should send request to.
	// e.g:
	// 1. SELECT * FROM cluster_log WHERE type='tikv'
	// 2. SELECT * FROM cluster_log WHERE type in ('tikv', 'tidb')
	NodeTypes set.StringSet

	// Instances represents all components instances we should send request to.
	// e.g:
	// 1. SELECT * FROM cluster_log WHERE instance='192.168.1.7:2379'
	// 2. SELECT * FROM cluster_log WHERE instance in ('192.168.1.7:2379', '192.168.1.9:2379')
	Instances set.StringSet

	// StartTime represents the beginning time of log message
	// e.g: SELECT * FROM cluster_log WHERE time>'2019-10-10 10:10:10.999'
	StartTime int64
	// EndTime represents the ending time of log message
	// e.g: SELECT * FROM cluster_log WHERE time<'2019-10-11 10:10:10.999'
	EndTime int64
	// Pattern is used to filter the log message
	// e.g:
	// 1. SELECT * FROM cluster_log WHERE message like '%gc%'
	// 2. SELECT * FROM cluster_log WHERE message regexp '.*'
	Patterns  []string
	LogLevels set.StringSet
	// contains filtered or unexported fields
}

ClusterLogTableExtractor is used to extract some predicates of `cluster_config`

func (*ClusterLogTableExtractor) Extract

Extract implements the MemTablePredicateExtractor Extract interface

type ClusterTableExtractor

type ClusterTableExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component
	SkipRequest bool

	// NodeTypes represents all components types we should send request to.
	// e.g:
	// 1. SELECT * FROM cluster_config WHERE type='tikv'
	// 2. SELECT * FROM cluster_config WHERE type in ('tikv', 'tidb')
	NodeTypes set.StringSet

	// Instances represents all components instances we should send request to.
	// e.g:
	// 1. SELECT * FROM cluster_config WHERE instance='192.168.1.7:2379'
	// 2. SELECT * FROM cluster_config WHERE type in ('192.168.1.7:2379', '192.168.1.9:2379')
	Instances set.StringSet
	// contains filtered or unexported fields
}

ClusterTableExtractor is used to extract some predicates of cluster table.

func (*ClusterTableExtractor) Extract

Extract implements the MemTablePredicateExtractor Extract interface

type ColWithCmpFuncManager

type ColWithCmpFuncManager struct {
	TargetCol *expression.Column

	OpType []string

	TmpConstant []*expression.Constant
	// contains filtered or unexported fields
}

ColWithCmpFuncManager is used in index join to handle the column with compare functions(>=, >, <, <=). It stores the compare functions and build ranges in execution phase.

func (*ColWithCmpFuncManager) BuildRangesByRow

func (cwc *ColWithCmpFuncManager) BuildRangesByRow(ctx sessionctx.Context, row chunk.Row) ([]*ranger.Range, error)

BuildRangesByRow will build range of the given row. It will eval each function's arg then call BuildRange.

func (*ColWithCmpFuncManager) CompareRow

func (cwc *ColWithCmpFuncManager) CompareRow(lhs, rhs chunk.Row) int

CompareRow compares the rows for deduplicate.

func (*ColWithCmpFuncManager) MemoryUsage

func (cwc *ColWithCmpFuncManager) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of ColWithCmpFuncManager

func (*ColWithCmpFuncManager) String

func (cwc *ColWithCmpFuncManager) String() string

String implements Stringer interface.

type ColumnsTableExtractor

type ColumnsTableExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component
	SkipRequest bool

	TableSchema set.StringSet

	TableName set.StringSet
	// ColumnName represents all column name we should filter in memtable.
	ColumnName set.StringSet

	TableSchemaPatterns []string

	TableNamePatterns []string

	ColumnNamePatterns []string
	// contains filtered or unexported fields
}

ColumnsTableExtractor is used to extract some predicates of columns table.

func (*ColumnsTableExtractor) Extract

func (e *ColumnsTableExtractor) Extract(_ sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) (remained []expression.Expression)

Extract implements the MemTablePredicateExtractor Extract interface

type CommonHandleCols

type CommonHandleCols struct {
	// contains filtered or unexported fields
}

CommonHandleCols implements the kv.HandleCols interface.

func NewCommonHandleCols

func NewCommonHandleCols(sc *stmtctx.StatementContext, tblInfo *model.TableInfo, idxInfo *model.IndexInfo,
	tableColumns []*expression.Column) *CommonHandleCols

NewCommonHandleCols creates a new CommonHandleCols.

func (*CommonHandleCols) BuildHandle

func (cb *CommonHandleCols) BuildHandle(row chunk.Row) (kv.Handle, error)

BuildHandle implements the kv.HandleCols interface.

func (*CommonHandleCols) BuildHandleByDatums

func (cb *CommonHandleCols) BuildHandleByDatums(row []types.Datum) (kv.Handle, error)

BuildHandleByDatums implements the kv.HandleCols interface.

func (*CommonHandleCols) BuildHandleFromIndexRow

func (cb *CommonHandleCols) BuildHandleFromIndexRow(row chunk.Row) (kv.Handle, error)

BuildHandleFromIndexRow implements the kv.HandleCols interface.

func (*CommonHandleCols) Compare

func (cb *CommonHandleCols) Compare(a, b []types.Datum, ctors []collate.Collator) (int, error)

Compare implements the kv.HandleCols interface.

func (*CommonHandleCols) GetCol

func (cb *CommonHandleCols) GetCol(idx int) *expression.Column

GetCol implements the kv.HandleCols interface.

func (*CommonHandleCols) GetFieldsTypes

func (cb *CommonHandleCols) GetFieldsTypes() []*types.FieldType

GetFieldsTypes implements the kv.HandleCols interface.

func (*CommonHandleCols) IsInt

func (*CommonHandleCols) IsInt() bool

IsInt implements the kv.HandleCols interface.

func (*CommonHandleCols) MemoryUsage

func (cb *CommonHandleCols) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of CommonHandleCols

func (*CommonHandleCols) NumCols

func (cb *CommonHandleCols) NumCols() int

NumCols implements the kv.HandleCols interface.

func (*CommonHandleCols) ResolveIndices

func (cb *CommonHandleCols) ResolveIndices(schema *expression.Schema) (HandleCols, error)

ResolveIndices implements the kv.HandleCols interface.

func (*CommonHandleCols) String

func (cb *CommonHandleCols) String() string

String implements the kv.HandleCols interface.

type CompactTable

type CompactTable struct {
	ReplicaKind    ast.CompactReplicaKind
	TableInfo      *model.TableInfo
	PartitionNames []model.CIStr
	// contains filtered or unexported fields
}

CompactTable represents a "ALTER TABLE [NAME] COMPACT ..." plan.

func (*CompactTable) MemoryUsage

func (s *CompactTable) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*CompactTable) OutputNames

func (s *CompactTable) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*CompactTable) ResolveIndices

func (p *CompactTable) ResolveIndices() (err error)

func (*CompactTable) Schema

func (s *CompactTable) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*CompactTable) SetOutputNames

func (s *CompactTable) SetOutputNames(names types.NameSlice)

func (*CompactTable) SetSchema

func (s *CompactTable) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type DDL

type DDL struct {
	Statement ast.DDLNode
	// contains filtered or unexported fields
}

DDL represents a DDL statement plan.

func (*DDL) MemoryUsage

func (s *DDL) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*DDL) OutputNames

func (s *DDL) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*DDL) ResolveIndices

func (p *DDL) ResolveIndices() (err error)

func (*DDL) Schema

func (s *DDL) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*DDL) SetOutputNames

func (s *DDL) SetOutputNames(names types.NameSlice)

func (*DDL) SetSchema

func (s *DDL) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type DataSource

type DataSource struct {
	IndexHints []indexHintInfo

	Columns []*model.ColumnInfo
	DBName  model.CIStr

	TableAsName *model.CIStr

	// TblCols contains the original columns of table before being pruned, and it
	// is used for estimating table scan cost.
	TblCols []*expression.Column

	// TblColHists contains the Histogram of all original table columns,
	// it is converted from statisticTable, and used for IO/network cost estimating.
	TblColHists *statistics.HistColl

	SampleInfo *TableSampleInfo
	// contains filtered or unexported fields
}

DataSource represents a tableScan without condition push down.

func (*DataSource) AddExtraPhysTblIDColumn

func (ds *DataSource) AddExtraPhysTblIDColumn() *expression.Column

AddExtraPhysTblIDColumn for partition table. 'select ... for update' on a partition table need to know the partition ID to construct the lock key, so this column is added to the chunk row. Also needed for checking against the sessions transaction buffer

func (*DataSource) AddPrefix4ShardIndexes

func (ds *DataSource) AddPrefix4ShardIndexes(sc sessionctx.Context, conds []expression.Expression) []expression.Expression

AddPrefix4ShardIndexes add expression prefix for shard index. e.g. an index is test.uk(tidb_shard(a), a). It transforms the sql "SELECT * FROM test WHERE a = 10" to "SELECT * FROM test WHERE tidb_shard(a) = val AND a = 10", val is the value of tidb_shard(10). It also transforms the sql "SELECT * FROM test WHERE a IN (10, 20, 30)" to "SELECT * FROM test WHERE tidb_shard(a) = val1 AND a = 10 OR tidb_shard(a) = val2 AND a = 20" @param[in] conds the original condtion of this datasource @retval - the new condition after adding expression prefix

func (*DataSource) BuildKeyInfo

func (ds *DataSource) BuildKeyInfo(selfSchema *expression.Schema, _ []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*DataSource) Convert2Gathers

func (ds *DataSource) Convert2Gathers() (gathers []LogicalPlan)

Convert2Gathers builds logical TiKVSingleGathers from DataSource.

func (*DataSource) DeriveStats

func (ds *DataSource) DeriveStats(_ []*property.StatsInfo, _ *expression.Schema, _ []*expression.Schema, colGroups [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*DataSource) ExplainInfo

func (ds *DataSource) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*DataSource) ExtractCorrelatedCols

func (ds *DataSource) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*DataSource) ExtractFD

func (ds *DataSource) ExtractFD() *fd.FDSet

ExtractFD implements the LogicalPlan interface.

func (DataSource) Init

func (ds DataSource) Init(ctx sessionctx.Context, offset int) *DataSource

Init initializes DataSource.

func (*DataSource) OutputNames

func (s *DataSource) OutputNames() types.NameSlice

func (*DataSource) PredicatePushDown

func (ds *DataSource) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*DataSource) PreparePossibleProperties

func (ds *DataSource) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*DataSource) PruneColumns

func (ds *DataSource) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*DataSource) Schema

func (s *DataSource) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*DataSource) SetOutputNames

func (s *DataSource) SetOutputNames(names types.NameSlice)

func (*DataSource) SetSchema

func (s *DataSource) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*DataSource) TableInfo

func (ds *DataSource) TableInfo() *model.TableInfo

TableInfo returns the *TableInfo of data source.

type Deallocate

type Deallocate struct {
	Name string
	// contains filtered or unexported fields
}

Deallocate represents deallocate plan.

func (*Deallocate) MemoryUsage

func (s *Deallocate) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*Deallocate) OutputNames

func (s *Deallocate) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Deallocate) ResolveIndices

func (p *Deallocate) ResolveIndices() (err error)

func (*Deallocate) Schema

func (s *Deallocate) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Deallocate) SetOutputNames

func (s *Deallocate) SetOutputNames(names types.NameSlice)

func (*Deallocate) SetSchema

func (s *Deallocate) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type Delete

type Delete struct {
	IsMultiTable bool

	SelectPlan PhysicalPlan

	TblColPosInfos TblColPosInfoSlice

	FKChecks   map[int64][]*FKCheck
	FKCascades map[int64][]*FKCascade
	// contains filtered or unexported fields
}

Delete represents a delete plan.

func (Delete) Init

func (p Delete) Init(ctx sessionctx.Context) *Delete

Init initializes Delete.

func (*Delete) MemoryUsage

func (p *Delete) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of Delete

func (*Delete) OutputNames

func (s *Delete) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Delete) ResolveIndices

func (p *Delete) ResolveIndices() (err error)

func (*Delete) Schema

func (s *Delete) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Delete) SetOutputNames

func (s *Delete) SetOutputNames(names types.NameSlice)

func (*Delete) SetSchema

func (s *Delete) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type DynamicPartitionAccessObject

type DynamicPartitionAccessObject struct {
	Database      string
	Table         string
	AllPartitions bool
	Partitions    []string
	// contains filtered or unexported fields
}

DynamicPartitionAccessObject represents the partitions accessed by the children of this operator. It's mainly used in dynamic pruning mode.

func (*DynamicPartitionAccessObject) String

type DynamicPartitionAccessObjects

type DynamicPartitionAccessObjects []*DynamicPartitionAccessObject

DynamicPartitionAccessObjects is a list of DynamicPartitionAccessObject.

func (DynamicPartitionAccessObjects) NormalizedString

func (d DynamicPartitionAccessObjects) NormalizedString() string

NormalizedString implements AccessObject.

func (DynamicPartitionAccessObjects) SetIntoPB

func (d DynamicPartitionAccessObjects) SetIntoPB(pb *tipb.ExplainOperator)

SetIntoPB implements AccessObject.

func (DynamicPartitionAccessObjects) String

type ErrExprLoc

type ErrExprLoc struct {
	Offset int
	Loc    string
}

ErrExprLoc is for generate the ErrFieldNotInGroupBy error info

type Execute

type Execute struct {
	Name     string
	Params   []expression.Expression
	PrepStmt *PlanCacheStmt
	Stmt     ast.StmtNode
	Plan     Plan
	// contains filtered or unexported fields
}

Execute represents prepare plan.

func (*Execute) MemoryUsage

func (s *Execute) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*Execute) OutputNames

func (s *Execute) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Execute) ResolveIndices

func (p *Execute) ResolveIndices() (err error)

func (*Execute) Schema

func (s *Execute) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Execute) SetOutputNames

func (s *Execute) SetOutputNames(names types.NameSlice)

func (*Execute) SetSchema

func (s *Execute) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type Explain

type Explain struct {
	TargetPlan       Plan
	Format           string
	Analyze          bool
	ExecStmt         ast.StmtNode
	RuntimeStatsColl *execdetails.RuntimeStatsColl

	Rows        [][]string
	ExplainRows [][]string
	// contains filtered or unexported fields
}

Explain represents a explain plan.

func (*Explain) MemoryUsage

func (s *Explain) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*Explain) OutputNames

func (s *Explain) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Explain) RenderResult

func (e *Explain) RenderResult() error

RenderResult renders the explain result as specified format.

func (*Explain) ResolveIndices

func (p *Explain) ResolveIndices() (err error)

func (*Explain) Schema

func (s *Explain) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Explain) SetOutputNames

func (s *Explain) SetOutputNames(names types.NameSlice)

func (*Explain) SetSchema

func (s *Explain) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ExplainInfoForEncode

type ExplainInfoForEncode struct {
	ID                  string                  `json:"id"`
	EstRows             string                  `json:"estRows"`
	ActRows             string                  `json:"actRows,omitempty"`
	TaskType            string                  `json:"taskType"`
	AccessObject        string                  `json:"accessObject,omitempty"`
	ExecuteInfo         string                  `json:"executeInfo,omitempty"`
	OperatorInfo        string                  `json:"operatorInfo,omitempty"`
	EstCost             string                  `json:"estCost,omitempty"`
	CostFormula         string                  `json:"costFormula,omitempty"`
	MemoryInfo          string                  `json:"memoryInfo,omitempty"`
	DiskInfo            string                  `json:"diskInfo,omitempty"`
	TotalMemoryConsumed string                  `json:"totalMemoryConsumed,omitempty"`
	SubOperators        []*ExplainInfoForEncode `json:"subOperators,omitempty"`
}

ExplainInfoForEncode store explain info for JSON encode

type ExprColumnMap

type ExprColumnMap map[expression.Expression]*expression.Column

ExprColumnMap is used to store all expressions of indexed generated columns in a table, and map them to the generated columns, thus we can substitute the expression in a query to an indexed generated column.

type FKCascade

type FKCascade struct {
	Tp         FKCascadeType
	ReferredFK *model.ReferredFKInfo
	ChildTable table.Table
	FK         *model.FKInfo
	FKCols     []*model.ColumnInfo
	FKIdx      *model.IndexInfo
	// CascadePlans contains the child cascade plan.
	// CascadePlans will be filled during execution, so only `explain analyze` statement result contains the cascade plan,
	// `explain` statement result doesn't contain the cascade plan.
	CascadePlans []Plan
	// contains filtered or unexported fields
}

FKCascade indicates the foreign key constraint cascade behaviour.

func (*FKCascade) AccessObject

func (f *FKCascade) AccessObject() AccessObject

AccessObject implements dataAccesser interface.

func (*FKCascade) Children

func (p *FKCascade) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*FKCascade) Clone

func (p *FKCascade) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*FKCascade) ExplainInfo

func (f *FKCascade) ExplainInfo() string

ExplainInfo implement Plan interface.

func (*FKCascade) ExplainNormalizedInfo

func (*FKCascade) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*FKCascade) ExtractCorrelatedCols

func (*FKCascade) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*FKCascade) GetChildReqProps

func (p *FKCascade) GetChildReqProps(idx int) *property.PhysicalProperty

func (FKCascade) Init

func (p FKCascade) Init(ctx sessionctx.Context) *FKCascade

Init initializes FKCascade

func (*FKCascade) MemoryUsage

func (f *FKCascade) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of FKCascade

func (*FKCascade) OperatorInfo

func (f *FKCascade) OperatorInfo(normalized bool) string

OperatorInfo implements dataAccesser interface.

func (*FKCascade) ResolveIndices

func (p *FKCascade) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*FKCascade) Schema

func (p *FKCascade) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*FKCascade) SetChild

func (p *FKCascade) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*FKCascade) SetChildren

func (p *FKCascade) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*FKCascade) StatsCount

func (p *FKCascade) StatsCount() float64

func (*FKCascade) ToPB

func (p *FKCascade) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type FKCascadeType

type FKCascadeType int8

FKCascadeType indicates in which (delete/update) statements.

const (
	// FKCascadeOnDelete indicates in delete statement.
	FKCascadeOnDelete FKCascadeType = 1
	// FKCascadeOnUpdate indicates in update statement.
	FKCascadeOnUpdate FKCascadeType = 2
)

type FKCheck

type FKCheck struct {
	FK         *model.FKInfo
	ReferredFK *model.ReferredFKInfo
	Tbl        table.Table
	Idx        table.Index
	Cols       []model.CIStr

	IdxIsPrimaryKey bool
	IdxIsExclusive  bool

	CheckExist bool
	FailedErr  error
	// contains filtered or unexported fields
}

FKCheck indicates the foreign key constraint checker.

func (*FKCheck) AccessObject

func (f *FKCheck) AccessObject() AccessObject

AccessObject implements dataAccesser interface.

func (*FKCheck) Children

func (p *FKCheck) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*FKCheck) Clone

func (p *FKCheck) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*FKCheck) ExplainInfo

func (f *FKCheck) ExplainInfo() string

ExplainInfo implement Plan interface.

func (*FKCheck) ExplainNormalizedInfo

func (*FKCheck) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*FKCheck) ExtractCorrelatedCols

func (*FKCheck) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*FKCheck) GetChildReqProps

func (p *FKCheck) GetChildReqProps(idx int) *property.PhysicalProperty

func (FKCheck) Init

func (p FKCheck) Init(ctx sessionctx.Context) *FKCheck

Init initializes FKCheck.

func (*FKCheck) MemoryUsage

func (f *FKCheck) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of FKCheck

func (*FKCheck) OperatorInfo

func (f *FKCheck) OperatorInfo(normalized bool) string

OperatorInfo implements dataAccesser interface.

func (*FKCheck) ResolveIndices

func (p *FKCheck) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*FKCheck) Schema

func (p *FKCheck) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*FKCheck) SetChild

func (p *FKCheck) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*FKCheck) SetChildren

func (p *FKCheck) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*FKCheck) StatsCount

func (p *FKCheck) StatsCount() float64

func (*FKCheck) ToPB

func (p *FKCheck) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type FieldSlice

type FieldSlice []*types.FieldType

FieldSlice is the slice of the types.FieldType

func (FieldSlice) CheckTypesCompatibility4PC

func (s FieldSlice) CheckTypesCompatibility4PC(tps []*types.FieldType) bool

CheckTypesCompatibility4PC compares FieldSlice with []*types.FieldType Currently this is only used in plan cache to check whether the types of parameters are compatible. If the types of parameters are compatible, we can use the cached plan.

type FlatOperator

type FlatOperator struct {
	// A reference to the original operator.
	Origin Plan

	// ChildrenIdx is the indexes of the children of this operator in the FlatPlanTree.
	// It's ordered from small to large.
	ChildrenIdx []int
	// ChildrenEndIdx is the index of the last operator of children subtrees of this operator in the FlatPlanTree.
	ChildrenEndIdx int

	// NeedReverseDriverSide means if we need to reverse the order of children to keep build side before probe side.
	//
	// Specifically, it means if the below are all true:
	// 1. this operator has two children
	// 2. the first child's Label is the probe side and the second's is the build side.
	//
	// If you call FlattenPhysicalPlan with buildSideFirst true, NeedReverseDriverSide will be useless.
	NeedReverseDriverSide bool

	Depth     uint32
	Label     OperatorLabel
	IsRoot    bool
	StoreType kv.StoreType
	// ReqType is only meaningful when IsRoot is false.
	ReqType ReadReqType

	// The below two fields are mainly for text tree formatting. See texttree.PrettyIdentifier().
	TextTreeIndent string
	IsLastChild    bool

	IsPhysicalPlan bool
}

FlatOperator is a simplified operator. It contains a reference to the original operator and some usually needed information.

type FlatPhysicalPlan

type FlatPhysicalPlan struct {
	Main FlatPlanTree
	CTEs []FlatPlanTree

	// InExecute means if the original plan tree contains Execute operator.
	//
	// Be careful when trying to use this, InExecute is true doesn't mean we are handling an EXECUTE statement.
	// When collecting information from the plan in an EXECUTE statement, usually we directly use the plan
	// in Execute.Plan, not Execute itself, so InExecute will be false.
	//
	// When will InExecute be true? When you're using "EXPLAIN FOR CONNECTION" to get the last plan of
	// a connection (usually we will record Explain.TargetPlan for an EXPLAIN statement) and that plan
	// is from an EXECUTE statement, we will collect from Execute itself, not directly from Execute.Plan,
	// then InExecute will be true.
	InExecute bool

	// InExplain means if the original plan tree contains Explain operator.
	InExplain bool
	// contains filtered or unexported fields
}

FlatPhysicalPlan provides an easier structure to traverse a plan and collect needed information. Note: Although it's named FlatPhysicalPlan, there also could be Insert, Delete and Update at the beginning of Main.

func FlattenPhysicalPlan

func FlattenPhysicalPlan(p Plan, buildSideFirst bool) *FlatPhysicalPlan

FlattenPhysicalPlan generates a FlatPhysicalPlan from a PhysicalPlan, Insert, Delete, Update, Explain or Execute.

type FlatPlanTree

type FlatPlanTree []*FlatOperator

FlatPlanTree is a simplified plan tree. It arranges all operators in the tree as a slice, ordered by the order of traversing the tree, which means a depth-first traversal plus some special rule for some operators.

func (FlatPlanTree) GetSelectPlan

func (e FlatPlanTree) GetSelectPlan() (FlatPlanTree, int)

GetSelectPlan skips Insert, Delete, and Update at the beginning of the FlatPlanTree and the foreign key check/cascade plan at the end of the FlatPlanTree. Note:

It returns a reference to the original FlatPlanTree, please avoid modifying the returned value.
The second return value is the offset. Because the returned FlatPlanTree is a part of the original slice, you need to minus them by the offset when using the returned FlatOperator.Depth and FlatOperator.ChildrenIdx.

type Fragment

type Fragment struct {
	// following field are filled during getPlanFragment.
	TableScan         *PhysicalTableScan          // result physical table scan
	ExchangeReceivers []*PhysicalExchangeReceiver // data receivers

	// following fields are filled after scheduling.
	ExchangeSender *PhysicalExchangeSender // data exporter

	IsRoot bool
	// contains filtered or unexported fields
}

Fragment is cut from the whole pushed-down plan by network communication. Communication by pfs are always through shuffling / broadcasting / passing through.

func GenerateRootMPPTasks

func GenerateRootMPPTasks(ctx sessionctx.Context, startTs uint64, mppQueryID kv.MPPQueryID, sender *PhysicalExchangeSender, is infoschema.InfoSchema) ([]*Fragment, error)

GenerateRootMPPTasks generate all mpp tasks and return root ones.

func (*Fragment) MemoryUsage

func (f *Fragment) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of Fragment

type FrameBound

type FrameBound struct {
	Type      ast.BoundType
	UnBounded bool
	Num       uint64
	// CalcFuncs is used for range framed windows.
	// We will build the date_add or date_sub functions for frames like `INTERVAL '2:30' MINUTE_SECOND FOLLOWING`,
	// and plus or minus for frames like `1 preceding`.
	CalcFuncs []expression.Expression
	// CmpFuncs is used to decide whether one row is included in the current frame.
	CmpFuncs []expression.CompareFunc
}

FrameBound is the boundary of a frame.

func (*FrameBound) Clone

func (fb *FrameBound) Clone() *FrameBound

Clone copies a frame bound totally.

func (*FrameBound) ToPB

func (fb *FrameBound) ToPB(ctx sessionctx.Context) (*tipb.WindowFrameBound, error)

ToPB converts FrameBound to tipb structure.

type HandleCols

type HandleCols interface {
	// BuildHandle builds a Handle from a row.
	BuildHandle(row chunk.Row) (kv.Handle, error)
	// BuildHandleByDatums builds a Handle from a datum slice.
	BuildHandleByDatums(row []types.Datum) (kv.Handle, error)
	// BuildHandleFromIndexRow builds a Handle from index row data.
	// The last column(s) of `row` must be the handle column(s).
	BuildHandleFromIndexRow(row chunk.Row) (kv.Handle, error)
	// ResolveIndices resolves handle column indices.
	ResolveIndices(schema *expression.Schema) (HandleCols, error)
	// IsInt returns if the HandleCols is a single tnt column.
	IsInt() bool
	// String implements the fmt.Stringer interface.
	String() string
	// GetCol gets the column by idx.
	GetCol(idx int) *expression.Column
	// NumCols returns the number of columns.
	NumCols() int
	// Compare compares two datum rows by handle order.
	Compare(a, b []types.Datum, ctors []collate.Collator) (int, error)
	// GetFieldsTypes return field types of columns.
	GetFieldsTypes() []*types.FieldType
	// MemoryUsage return the memory usage
	MemoryUsage() int64
}

HandleCols is the interface that holds handle columns.

func BuildHandleColsForAnalyze

func BuildHandleColsForAnalyze(ctx sessionctx.Context, tblInfo *model.TableInfo, allColumns bool, colsInfo []*model.ColumnInfo) HandleCols

BuildHandleColsForAnalyze returns HandleCols for ANALYZE.

func NewIntHandleCols

func NewIntHandleCols(col *expression.Column) HandleCols

NewIntHandleCols creates a new IntHandleCols.

type HashJoinCPUCostDetail

type HashJoinCPUCostDetail struct {
	BuildRowCount       float64                  `json:"buildRowCount"`
	CPUFactor           float64                  `json:"cpuFactor"`
	ConcurrencyFactor   float64                  `json:"concurrencyFactor"`
	ProbeCost           *HashJoinProbeCostDetail `json:"probeCost"`
	HashJoinConcurrency uint                     `json:"hashJoinConcurrency"`
	Spill               bool                     `json:"spill"`
	Cost                float64                  `json:"cost"`
	UseOuterToBuild     bool                     `json:"useOuterToBuild"`
}

HashJoinCPUCostDetail indicates cpu cost detail

type HashJoinDiskCostDetail

type HashJoinDiskCostDetail struct {
	Spill           bool                         `json:"spill"`
	UseOuterToBuild bool                         `json:"useOuterToBuild"`
	BuildRowCount   float64                      `json:"buildRowCount"`
	DiskFactor      float64                      `json:"diskFactor"`
	RowSize         float64                      `json:"rowSize"`
	ProbeDiskCost   *HashJoinProbeDiskCostDetail `json:"probeDiskCost"`
	Cost            float64                      `json:"cost"`
}

HashJoinDiskCostDetail indicates disk cost detail

type HashJoinMemoryCostDetail

type HashJoinMemoryCostDetail struct {
	Spill         bool    `json:"spill"`
	MemQuota      int64   `json:"memQuota"`
	RowSize       float64 `json:"rowSize"`
	BuildRowCount float64 `json:"buildRowCount"`
	MemoryFactor  float64 `json:"memoryFactor"`
	Cost          float64 `json:"cost"`
}

HashJoinMemoryCostDetail indicates memory cost detail

type HashJoinProbeCostDetail

type HashJoinProbeCostDetail struct {
	NumPairs        float64 `json:"numPairs"`
	HasConditions   bool    `json:"hasConditions"`
	SelectionFactor float64 `json:"selectionFactor"`
	ProbeRowCount   float64 `json:"probeRowCount"`
	Cost            float64 `json:"cost"`
}

HashJoinProbeCostDetail indicates probe cpu cost detail

type HashJoinProbeDiskCostDetail

type HashJoinProbeDiskCostDetail struct {
	SelectionFactor float64 `json:"selectionFactor"`
	NumPairs        float64 `json:"numPairs"`
	HasConditions   bool    `json:"hasConditions"`
	Cost            float64 `json:"cost"`
}

HashJoinProbeDiskCostDetail indicates probe disk cost detail

type HotRegionsHistoryTableExtractor

type HotRegionsHistoryTableExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any pd server.
	SkipRequest bool

	// StartTime represents the beginning time of update time.
	// e.g: SELECT * FROM tidb_hot_regions_history WHERE update_time>'2019-10-10 10:10:10.999'
	StartTime int64
	// EndTime represents the ending time of update time.
	// e.g: SELECT * FROM tidb_hot_regions_history WHERE update_time<'2019-10-11 10:10:10.999'
	EndTime int64

	// RegionIDs/StoreIDs/PeerIDs represents all region/store/peer ids we should filter in PD to reduce network IO.
	// e.g:
	// 1. SELECT * FROM tidb_hot_regions_history WHERE region_id=1
	// 2. SELECT * FROM tidb_hot_regions_history WHERE table_id in (11, 22)
	// Leave range operation to above selection executor.
	RegionIDs []uint64
	StoreIDs  []uint64
	PeerIDs   []uint64
	// IsLearners/IsLeaders represents whether we should request for learner/leader role in PD to reduce network IO.
	// e.g:
	// 1. SELECT * FROM tidb_hot_regions_history WHERE is_learner=1
	// 2. SELECT * FROM tidb_hot_regions_history WHERE is_learner in (0,1) -> request all
	IsLearners []bool
	IsLeaders  []bool

	// HotRegionTypes represents all hot region types we should filter in PD to reduce network IO.
	// e.g:
	// 1. SELECT * FROM tidb_hot_regions_history WHERE type='read'
	// 2. SELECT * FROM tidb_hot_regions_history WHERE type in ('read', 'write')
	// 3. SELECT * FROM tidb_hot_regions_history WHERE type='read' and type='write' -> SkipRequest = true
	HotRegionTypes set.StringSet
	// contains filtered or unexported fields
}

HotRegionsHistoryTableExtractor is used to extract some predicates of `tidb_hot_regions_history`

func (*HotRegionsHistoryTableExtractor) Extract

Extract implements the MemTablePredicateExtractor Extract interface

type IndexAccess

type IndexAccess struct {
	Name             string
	Cols             []string
	IsClusteredIndex bool
}

IndexAccess represents the index accessed by an operator.

func (*IndexAccess) ToPB

func (a *IndexAccess) ToPB() *tipb.IndexAccess

ToPB turns itself into a protobuf message.

type IndexAdvise

type IndexAdvise struct {
	IsLocal     bool
	Path        string
	MaxMinutes  uint64
	MaxIndexNum *ast.MaxIndexNumClause
	LinesInfo   *ast.LinesClause
	// contains filtered or unexported fields
}

IndexAdvise represents a index advise plan.

func (*IndexAdvise) MemoryUsage

func (s *IndexAdvise) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*IndexAdvise) OutputNames

func (s *IndexAdvise) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*IndexAdvise) ResolveIndices

func (p *IndexAdvise) ResolveIndices() (err error)

func (*IndexAdvise) Schema

func (s *IndexAdvise) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*IndexAdvise) SetOutputNames

func (s *IndexAdvise) SetOutputNames(names types.NameSlice)

func (*IndexAdvise) SetSchema

func (s *IndexAdvise) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type Insert

type Insert struct {
	Table table.Table

	Columns []*ast.ColumnName
	Lists   [][]expression.Expression
	SetList []*expression.Assignment

	OnDuplicate        []*expression.Assignment
	Schema4OnDuplicate *expression.Schema

	GenCols InsertGeneratedColumns

	SelectPlan PhysicalPlan

	IsReplace bool

	// NeedFillDefaultValue is true when expr in value list reference other column.
	NeedFillDefaultValue bool

	AllAssignmentsAreConstant bool

	RowLen int

	FKChecks   []*FKCheck
	FKCascades []*FKCascade
	// contains filtered or unexported fields
}

Insert represents an insert plan.

func (Insert) Init

func (p Insert) Init(ctx sessionctx.Context) *Insert

Init initializes Insert.

func (*Insert) MemoryUsage

func (p *Insert) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of Insert

func (*Insert) OutputNames

func (s *Insert) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Insert) ResolveIndices

func (p *Insert) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*Insert) Schema

func (s *Insert) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Insert) SetOutputNames

func (s *Insert) SetOutputNames(names types.NameSlice)

func (*Insert) SetSchema

func (s *Insert) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type InsertGeneratedColumns

type InsertGeneratedColumns struct {
	Columns      []*ast.ColumnName
	Exprs        []expression.Expression
	OnDuplicates []*expression.Assignment
}

InsertGeneratedColumns is for completing generated columns in Insert. We resolve generation expressions in plan, and eval those in executor.

func (*InsertGeneratedColumns) MemoryUsage

func (i *InsertGeneratedColumns) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of InsertGeneratedColumns

type InspectionResultTableExtractor

type InspectionResultTableExtractor struct {

	// SkipInspection means the where clause always false, we don't need to request any component
	SkipInspection bool
	// Rules represents rules applied to, and we should apply all inspection rules if there is no rules specified
	// e.g: SELECT * FROM inspection_result WHERE rule in ('ddl', 'config')
	Rules set.StringSet
	// Items represents items applied to, and we should apply all inspection item if there is no rules specified
	// e.g: SELECT * FROM inspection_result WHERE item in ('ddl.lease', 'raftstore.threadpool')
	Items set.StringSet
	// contains filtered or unexported fields
}

InspectionResultTableExtractor is used to extract some predicates of `inspection_result`

func (*InspectionResultTableExtractor) Extract

func (e *InspectionResultTableExtractor) Extract(
	_ sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) (remained []expression.Expression)

Extract implements the MemTablePredicateExtractor Extract interface

type InspectionRuleTableExtractor

type InspectionRuleTableExtractor struct {
	SkipRequest bool
	Types       set.StringSet
	// contains filtered or unexported fields
}

InspectionRuleTableExtractor is used to extract some predicates of `inspection_rules`

func (*InspectionRuleTableExtractor) Extract

func (e *InspectionRuleTableExtractor) Extract(
	_ sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) (remained []expression.Expression)

Extract implements the MemTablePredicateExtractor Extract interface

type InspectionSummaryTableExtractor

type InspectionSummaryTableExtractor struct {

	// SkipInspection means the where clause always false, we don't need to request any component
	SkipInspection bool
	// Rules represents rules applied to, and we should apply all inspection rules if there is no rules specified
	// e.g: SELECT * FROM inspection_summary WHERE rule in ('ddl', 'config')
	Rules       set.StringSet
	MetricNames set.StringSet
	Quantiles   []float64
	// contains filtered or unexported fields
}

InspectionSummaryTableExtractor is used to extract some predicates of `inspection_summary`

func (*InspectionSummaryTableExtractor) Extract

func (e *InspectionSummaryTableExtractor) Extract(
	_ sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) (remained []expression.Expression)

Extract implements the MemTablePredicateExtractor Extract interface

type IntHandleCols

type IntHandleCols struct {
	// contains filtered or unexported fields
}

IntHandleCols implements the kv.HandleCols interface.

func (*IntHandleCols) BuildHandle

func (ib *IntHandleCols) BuildHandle(row chunk.Row) (kv.Handle, error)

BuildHandle implements the kv.HandleCols interface.

func (*IntHandleCols) BuildHandleByDatums

func (ib *IntHandleCols) BuildHandleByDatums(row []types.Datum) (kv.Handle, error)

BuildHandleByDatums implements the kv.HandleCols interface.

func (*IntHandleCols) BuildHandleFromIndexRow

func (*IntHandleCols) BuildHandleFromIndexRow(row chunk.Row) (kv.Handle, error)

BuildHandleFromIndexRow implements the kv.HandleCols interface.

func (*IntHandleCols) Compare

func (ib *IntHandleCols) Compare(a, b []types.Datum, ctors []collate.Collator) (int, error)

Compare implements the kv.HandleCols interface.

func (*IntHandleCols) GetCol

func (ib *IntHandleCols) GetCol(idx int) *expression.Column

GetCol implements the kv.HandleCols interface.

func (*IntHandleCols) GetFieldsTypes

func (*IntHandleCols) GetFieldsTypes() []*types.FieldType

GetFieldsTypes implements the kv.HandleCols interface.

func (*IntHandleCols) IsInt

func (*IntHandleCols) IsInt() bool

IsInt implements the kv.HandleCols interface.

func (*IntHandleCols) MemoryUsage

func (ib *IntHandleCols) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of IntHandleCols

func (*IntHandleCols) NumCols

func (*IntHandleCols) NumCols() int

NumCols implements the kv.HandleCols interface.

func (*IntHandleCols) ResolveIndices

func (ib *IntHandleCols) ResolveIndices(schema *expression.Schema) (HandleCols, error)

ResolveIndices implements the kv.HandleCols interface.

func (*IntHandleCols) String

func (ib *IntHandleCols) String() string

String implements the kv.HandleCols interface.

type JoinType

type JoinType int

JoinType contains CrossJoin, InnerJoin, LeftOuterJoin, RightOuterJoin, FullOuterJoin, SemiJoin.

const (
	// InnerJoin means inner join.
	InnerJoin JoinType = iota
	// LeftOuterJoin means left join.
	LeftOuterJoin
	// RightOuterJoin means right join.
	RightOuterJoin
	// SemiJoin means if row a in table A matches some rows in B, just output a.
	SemiJoin
	// AntiSemiJoin means if row a in table A does not match any row in B, then output a.
	AntiSemiJoin
	// LeftOuterSemiJoin means if row a in table A matches some rows in B, output (a, true), otherwise, output (a, false).
	LeftOuterSemiJoin
	// AntiLeftOuterSemiJoin means if row a in table A matches some rows in B, output (a, false), otherwise, output (a, true).
	AntiLeftOuterSemiJoin
)

func (JoinType) IsOuterJoin

func (tp JoinType) IsOuterJoin() bool

IsOuterJoin returns if this joiner is an outer joiner

func (JoinType) IsSemiJoin

func (tp JoinType) IsSemiJoin() bool

IsSemiJoin returns if this joiner is a semi/anti-semi joiner

func (JoinType) String

func (tp JoinType) String() string

type LRUPlanCache

type LRUPlanCache struct {
	// contains filtered or unexported fields
}

LRUPlanCache is a dedicated least recently used cache, Only used for plan cache.

func NewLRUPlanCache

func NewLRUPlanCache(capacity uint, guard float64, quota uint64, sctx sessionctx.Context) *LRUPlanCache

NewLRUPlanCache creates a PCLRUCache object, whose capacity is "capacity". NOTE: "capacity" should be a positive value.

func (*LRUPlanCache) Close

func (l *LRUPlanCache) Close()

Close do some clean work for LRUPlanCache when close the session

func (*LRUPlanCache) Delete

func (l *LRUPlanCache) Delete(key kvcache.Key)

Delete deletes the multi-values from the LRU Cache.

func (*LRUPlanCache) DeleteAll

func (l *LRUPlanCache) DeleteAll()

DeleteAll deletes all elements from the LRU Cache.

func (*LRUPlanCache) Get

func (l *LRUPlanCache) Get(key kvcache.Key, paramTypes []*types.FieldType, limitParams []uint64) (value kvcache.Value, ok bool)

Get tries to find the corresponding value according to the given key.

func (*LRUPlanCache) MemoryUsage

func (l *LRUPlanCache) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of LRUPlanCache

func (*LRUPlanCache) Put

func (l *LRUPlanCache) Put(key kvcache.Key, value kvcache.Value, paramTypes []*types.FieldType, limitParams []uint64)

Put puts the (key, value) pair into the LRU Cache.

func (*LRUPlanCache) SetCapacity

func (l *LRUPlanCache) SetCapacity(capacity uint) error

SetCapacity sets capacity of the cache.

func (*LRUPlanCache) Size

func (l *LRUPlanCache) Size() int

Size gets the current cache size.

type LoadData

type LoadData struct {
	FileLocRef  ast.FileLocRefTp
	OnDuplicate ast.OnDuplicateKeyHandlingType
	Path        string
	Table       *ast.TableName
	Columns     []*ast.ColumnName
	FieldsInfo  *ast.FieldsClause
	LinesInfo   *ast.LinesClause
	IgnoreLines uint64

	ColumnAssignments  []*ast.Assignment
	ColumnsAndUserVars []*ast.ColumnNameOrUserVar

	GenCols InsertGeneratedColumns
	// contains filtered or unexported fields
}

LoadData represents a loaddata plan.

func (LoadData) Init

func (p LoadData) Init(ctx sessionctx.Context) *LoadData

Init initializes LoadData.

func (*LoadData) MemoryUsage

func (s *LoadData) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*LoadData) OutputNames

func (s *LoadData) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*LoadData) ResolveIndices

func (p *LoadData) ResolveIndices() (err error)

func (*LoadData) Schema

func (s *LoadData) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LoadData) SetOutputNames

func (s *LoadData) SetOutputNames(names types.NameSlice)

func (*LoadData) SetSchema

func (s *LoadData) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LoadStats

type LoadStats struct {
	Path string
	// contains filtered or unexported fields
}

LoadStats represents a load stats plan.

func (*LoadStats) MemoryUsage

func (s *LoadStats) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*LoadStats) OutputNames

func (s *LoadStats) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*LoadStats) ResolveIndices

func (p *LoadStats) ResolveIndices() (err error)

func (*LoadStats) Schema

func (s *LoadStats) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LoadStats) SetOutputNames

func (s *LoadStats) SetOutputNames(names types.NameSlice)

func (*LoadStats) SetSchema

func (s *LoadStats) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LockStats

type LockStats struct {
	Tables []*ast.TableName
	// contains filtered or unexported fields
}

LockStats represents a lock stats for table

func (*LockStats) MemoryUsage

func (s *LockStats) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*LockStats) OutputNames

func (s *LockStats) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*LockStats) ResolveIndices

func (p *LockStats) ResolveIndices() (err error)

func (*LockStats) Schema

func (s *LockStats) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LockStats) SetOutputNames

func (s *LockStats) SetOutputNames(names types.NameSlice)

func (*LockStats) SetSchema

func (s *LockStats) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalAggregation

type LogicalAggregation struct {
	AggFuncs     []*aggregation.AggFuncDesc
	GroupByItems []expression.Expression
	// contains filtered or unexported fields
}

LogicalAggregation represents an aggregate plan.

func (*LogicalAggregation) BuildKeyInfo

func (la *LogicalAggregation) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalAggregation) CopyAggHints

func (la *LogicalAggregation) CopyAggHints(agg *LogicalAggregation)

CopyAggHints copies the aggHints from another LogicalAggregation.

func (*LogicalAggregation) DeriveStats

func (la *LogicalAggregation) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema, colGroups [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalAggregation) ExplainInfo

func (p *LogicalAggregation) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalAggregation) ExtractColGroups

func (la *LogicalAggregation) ExtractColGroups(_ [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalAggregation) ExtractCorrelatedCols

func (la *LogicalAggregation) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalAggregation) ExtractFD

func (la *LogicalAggregation) ExtractFD() *fd.FDSet

ExtractFD implements the logical plan interface, extracting the FD from bottom up. 1: In most of the cases, using FDs to check the only_full_group_by problem should be done in the buildAggregation phase by extracting the bottom-up FDs graph from the `p` --- the sub plan tree that has already been built.

2: and this requires that some conditions push-down into the `p` like selection should be done before building aggregation, otherwise, 'a=1 and a can occur in the select lists of a group by' will be miss-checked because it doesn't be implied in the known FDs graph.

3: when a logical agg is built, it's schema columns indicates what the permitted-non-agg columns is. Therefore, we shouldn't depend on logicalAgg.ExtractFD() to finish the only_full_group_by checking problem rather than by 1 & 2.

func (*LogicalAggregation) GetGroupByCols

func (la *LogicalAggregation) GetGroupByCols() []*expression.Column

GetGroupByCols returns the columns that are group-by items. For example, `group by a, b, c+d` will return [a, b].

func (*LogicalAggregation) GetPotentialPartitionKeys

func (la *LogicalAggregation) GetPotentialPartitionKeys() []*property.MPPPartitionColumn

GetPotentialPartitionKeys return potential partition keys for aggregation, the potential partition keys are the group by keys

func (*LogicalAggregation) GetUsedCols

func (la *LogicalAggregation) GetUsedCols() (usedCols []*expression.Column)

GetUsedCols extracts all of the Columns used by agg including GroupByItems and AggFuncs.

func (*LogicalAggregation) HasDistinct

func (la *LogicalAggregation) HasDistinct() bool

HasDistinct shows whether LogicalAggregation has functions with distinct.

func (*LogicalAggregation) HasOrderBy

func (la *LogicalAggregation) HasOrderBy() bool

HasOrderBy shows whether LogicalAggregation has functions with order-by items.

func (LogicalAggregation) Init

Init initializes LogicalAggregation.

func (*LogicalAggregation) IsCompleteModeAgg

func (la *LogicalAggregation) IsCompleteModeAgg() bool

IsCompleteModeAgg returns if all of the AggFuncs are CompleteMode.

func (*LogicalAggregation) IsPartialModeAgg

func (la *LogicalAggregation) IsPartialModeAgg() bool

IsPartialModeAgg returns if all of the AggFuncs are partialMode.

func (*LogicalAggregation) OutputNames

func (s *LogicalAggregation) OutputNames() types.NameSlice

func (*LogicalAggregation) PredicatePushDown

func (la *LogicalAggregation) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) (ret []expression.Expression, retPlan LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalAggregation) PreparePossibleProperties

func (la *LogicalAggregation) PreparePossibleProperties(_ *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalAggregation) PruneColumns

func (la *LogicalAggregation) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalAggregation) ResetHintIfConflicted

func (la *LogicalAggregation) ResetHintIfConflicted() (preferHash bool, preferStream bool)

ResetHintIfConflicted resets the aggHints.preferAggType if they are conflicted, and returns the two preferAggType hints.

func (*LogicalAggregation) Schema

func (s *LogicalAggregation) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalAggregation) SetOutputNames

func (s *LogicalAggregation) SetOutputNames(names types.NameSlice)

func (*LogicalAggregation) SetSchema

func (s *LogicalAggregation) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalApply

type LogicalApply struct {
	LogicalJoin

	CorCols []*expression.CorrelatedColumn
	// NoDecorrelate is from /*+ no_decorrelate() */ hint.
	NoDecorrelate bool
}

LogicalApply gets one row from outer executor and gets one row from inner executor according to outer row.

func (*LogicalApply) DeriveStats

func (la *LogicalApply) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema, colGroups [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalApply) ExplainInfo

func (p *LogicalApply) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalApply) ExtractColGroups

func (la *LogicalApply) ExtractColGroups(colGroups [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalApply) ExtractCorrelatedCols

func (la *LogicalApply) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalApply) ExtractFD

func (la *LogicalApply) ExtractFD() *fd.FDSet

ExtractFD implements the LogicalPlan interface.

func (*LogicalApply) GetHashJoin

func (la *LogicalApply) GetHashJoin(prop *property.PhysicalProperty) *PhysicalHashJoin

GetHashJoin is public for cascades planner.

func (LogicalApply) Init

func (la LogicalApply) Init(ctx sessionctx.Context, offset int) *LogicalApply

Init initializes LogicalApply.

func (*LogicalApply) OutputNames

func (s *LogicalApply) OutputNames() types.NameSlice

func (*LogicalApply) PruneColumns

func (la *LogicalApply) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalApply) Schema

func (s *LogicalApply) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalApply) SetOutputNames

func (s *LogicalApply) SetOutputNames(names types.NameSlice)

func (*LogicalApply) SetSchema

func (s *LogicalApply) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalCTE

type LogicalCTE struct {
	// contains filtered or unexported fields
}

LogicalCTE is for CTE.

func (*LogicalCTE) BuildKeyInfo

func (p *LogicalCTE) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalCTE) DeriveStats

func (p *LogicalCTE) DeriveStats(_ []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalCTE) ExtractCorrelatedCols

func (p *LogicalCTE) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (LogicalCTE) Init

func (p LogicalCTE) Init(ctx sessionctx.Context, offset int) *LogicalCTE

Init only assigns type and context.

func (*LogicalCTE) OutputNames

func (s *LogicalCTE) OutputNames() types.NameSlice

func (*LogicalCTE) PredicatePushDown

func (p *LogicalCTE) PredicatePushDown(predicates []expression.Expression, _ *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalCTE) Schema

func (s *LogicalCTE) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalCTE) SetOutputNames

func (s *LogicalCTE) SetOutputNames(names types.NameSlice)

func (*LogicalCTE) SetSchema

func (s *LogicalCTE) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalCTETable

type LogicalCTETable struct {
	// contains filtered or unexported fields
}

LogicalCTETable is for CTE table

func (*LogicalCTETable) BuildKeyInfo

func (p *LogicalCTETable) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalCTETable) DeriveStats

DeriveStats implement LogicalPlan DeriveStats interface.

func (LogicalCTETable) Init

func (p LogicalCTETable) Init(ctx sessionctx.Context, offset int) *LogicalCTETable

Init only assigns type and context.

func (*LogicalCTETable) OutputNames

func (s *LogicalCTETable) OutputNames() types.NameSlice

func (*LogicalCTETable) Schema

func (s *LogicalCTETable) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalCTETable) SetOutputNames

func (s *LogicalCTETable) SetOutputNames(names types.NameSlice)

func (*LogicalCTETable) SetSchema

func (s *LogicalCTETable) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalIndexScan

type LogicalIndexScan struct {

	// DataSource should be read-only here.
	Source       *DataSource
	IsDoubleRead bool

	EqCondCount int
	AccessConds expression.CNFExprs
	Ranges      []*ranger.Range

	Index          *model.IndexInfo
	Columns        []*model.ColumnInfo
	FullIdxCols    []*expression.Column
	FullIdxColLens []int
	IdxCols        []*expression.Column
	IdxColLens     []int
	// contains filtered or unexported fields
}

LogicalIndexScan is the logical index scan operator for TiKV.

func (*LogicalIndexScan) BuildKeyInfo

func (is *LogicalIndexScan) BuildKeyInfo(selfSchema *expression.Schema, _ []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalIndexScan) DeriveStats

func (is *LogicalIndexScan) DeriveStats(_ []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implements LogicalPlan DeriveStats interface.

func (*LogicalIndexScan) ExplainInfo

func (p *LogicalIndexScan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalIndexScan) GetPhysicalIndexScan

func (s *LogicalIndexScan) GetPhysicalIndexScan(_ *expression.Schema, stats *property.StatsInfo) *PhysicalIndexScan

GetPhysicalIndexScan returns PhysicalIndexScan for the logical IndexScan.

func (LogicalIndexScan) Init

func (is LogicalIndexScan) Init(ctx sessionctx.Context, offset int) *LogicalIndexScan

Init initializes LogicalIndexScan.

func (*LogicalIndexScan) MatchIndexProp

func (p *LogicalIndexScan) MatchIndexProp(prop *property.PhysicalProperty) (match bool)

MatchIndexProp checks if the indexScan can match the required property.

func (*LogicalIndexScan) OutputNames

func (s *LogicalIndexScan) OutputNames() types.NameSlice

func (*LogicalIndexScan) PreparePossibleProperties

func (is *LogicalIndexScan) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalIndexScan) Schema

func (s *LogicalIndexScan) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalIndexScan) SetOutputNames

func (s *LogicalIndexScan) SetOutputNames(names types.NameSlice)

func (*LogicalIndexScan) SetSchema

func (s *LogicalIndexScan) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalJoin

type LogicalJoin struct {
	JoinType JoinType

	StraightJoin bool

	EqualConditions []*expression.ScalarFunction
	NAEQConditions  []*expression.ScalarFunction
	LeftConditions  expression.CNFExprs
	RightConditions expression.CNFExprs
	OtherConditions expression.CNFExprs

	// DefaultValues is only used for left/right outer join, which is values the inner row's should be when the outer table
	// doesn't match any inner table's row.
	// That it's nil just means the default values is a slice of NULL.
	// Currently, only `aggregation push down` phase will set this.
	DefaultValues []types.Datum
	// contains filtered or unexported fields
}

LogicalJoin is the logical join plan.

func (*LogicalJoin) AppendJoinConds

func (p *LogicalJoin) AppendJoinConds(eq []*expression.ScalarFunction, left, right, other []expression.Expression)

AppendJoinConds appends new join conditions.

func (*LogicalJoin) AttachOnConds

func (p *LogicalJoin) AttachOnConds(onConds []expression.Expression)

AttachOnConds extracts on conditions for join and set the `EqualConditions`, `LeftConditions`, `RightConditions` and `OtherConditions` by the result of extract.

func (*LogicalJoin) BuildKeyInfo

func (p *LogicalJoin) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalJoin) DeriveStats

func (p *LogicalJoin) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema, colGroups [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface. If the type of join is SemiJoin, the selectivity of it will be same as selection's. If the type of join is LeftOuterSemiJoin, it will not add or remove any row. The last column is a boolean value, whose NDV should be two. If the type of join is inner/outer join, the output of join(s, t) should be N(s) * N(t) / (V(s.key) * V(t.key)) * Min(s.key, t.key). N(s) stands for the number of rows in relation s. V(s.key) means the NDV of join key in s. This is a quite simple strategy: We assume every bucket of relation which will participate join has the same number of rows, and apply cross join for every matched bucket.

func (*LogicalJoin) ExplainInfo

func (p *LogicalJoin) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalJoin) ExtractColGroups

func (p *LogicalJoin) ExtractColGroups(colGroups [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalJoin) ExtractCorrelatedCols

func (p *LogicalJoin) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalJoin) ExtractFD

func (p *LogicalJoin) ExtractFD() *fd.FDSet

ExtractFD implements the interface LogicalPlan.

func (*LogicalJoin) ExtractJoinKeys

func (p *LogicalJoin) ExtractJoinKeys(childIdx int) *expression.Schema

ExtractJoinKeys extract join keys as a schema for child with childIdx.

func (*LogicalJoin) ExtractOnCondition

func (p *LogicalJoin) ExtractOnCondition(
	conditions []expression.Expression,
	leftSchema *expression.Schema,
	rightSchema *expression.Schema,
	deriveLeft bool,
	deriveRight bool) (eqCond []*expression.ScalarFunction, leftCond []expression.Expression,
	rightCond []expression.Expression, otherCond []expression.Expression)

ExtractOnCondition divide conditions in CNF of join node into 4 groups. These conditions can be where conditions, join conditions, or collection of both. If deriveLeft/deriveRight is set, we would try to derive more conditions for left/right plan.

func (*LogicalJoin) GetJoinKeys

func (p *LogicalJoin) GetJoinKeys() (leftKeys, rightKeys []*expression.Column, isNullEQ []bool, hasNullEQ bool)

GetJoinKeys extracts join keys(columns) from EqualConditions. It returns left join keys, right join keys and an `isNullEQ` array which means the `joinKey[i]` is a `NullEQ` function. The `hasNullEQ` means whether there is a `NullEQ` of a join key.

func (*LogicalJoin) GetMergeJoin

func (p *LogicalJoin) GetMergeJoin(prop *property.PhysicalProperty, schema *expression.Schema, statsInfo *property.StatsInfo, leftStatsInfo *property.StatsInfo, rightStatsInfo *property.StatsInfo) []PhysicalPlan

GetMergeJoin convert the logical join to physical merge join based on the physical property.

func (*LogicalJoin) GetNAJoinKeys

func (p *LogicalJoin) GetNAJoinKeys() (leftKeys, rightKeys []*expression.Column)

GetNAJoinKeys extracts join keys(columns) from NAEqualCondition.

func (*LogicalJoin) GetPotentialPartitionKeys

func (p *LogicalJoin) GetPotentialPartitionKeys() (leftKeys, rightKeys []*property.MPPPartitionColumn)

GetPotentialPartitionKeys return potential partition keys for join, the potential partition keys are the join keys of EqualConditions

func (LogicalJoin) Init

func (p LogicalJoin) Init(ctx sessionctx.Context, offset int) *LogicalJoin

Init initializes LogicalJoin.

func (*LogicalJoin) OutputNames

func (s *LogicalJoin) OutputNames() types.NameSlice

func (*LogicalJoin) PredicatePushDown

func (p *LogicalJoin) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) (ret []expression.Expression, retPlan LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalJoin) PreparePossibleProperties

func (p *LogicalJoin) PreparePossibleProperties(_ *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalJoin) PruneColumns

func (p *LogicalJoin) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalJoin) Schema

func (s *LogicalJoin) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalJoin) SetOutputNames

func (s *LogicalJoin) SetOutputNames(names types.NameSlice)

func (*LogicalJoin) SetSchema

func (s *LogicalJoin) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*LogicalJoin) Shallow

func (p *LogicalJoin) Shallow() *LogicalJoin

Shallow shallow copies a LogicalJoin struct.

type LogicalLimit

type LogicalLimit struct {
	Offset uint64
	Count  uint64
	// contains filtered or unexported fields
}

LogicalLimit represents offset and limit plan.

func (*LogicalLimit) BuildKeyInfo

func (p *LogicalLimit) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalLimit) DeriveStats

func (p *LogicalLimit) DeriveStats(childStats []*property.StatsInfo, _ *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalLimit) ExplainInfo

func (p *LogicalLimit) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalLimit) HashCode

func (p *LogicalLimit) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalLimit) Init

func (p LogicalLimit) Init(ctx sessionctx.Context, offset int) *LogicalLimit

Init initializes LogicalLimit.

func (*LogicalLimit) OutputNames

func (s *LogicalLimit) OutputNames() types.NameSlice

func (*LogicalLimit) PredicatePushDown

func (p *LogicalLimit) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalLimit) PruneColumns

func (p *LogicalLimit) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalLimit) Schema

func (s *LogicalLimit) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalLimit) SetOutputNames

func (s *LogicalLimit) SetOutputNames(names types.NameSlice)

func (*LogicalLimit) SetSchema

func (s *LogicalLimit) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalLock

type LogicalLock struct {
	Lock *ast.SelectLockInfo
	// contains filtered or unexported fields
}

LogicalLock represents a select lock plan.

func (*LogicalLock) BuildKeyInfo

func (p *LogicalLock) BuildKeyInfo(_ *expression.Schema, _ []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalLock) Children

func (p *LogicalLock) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalLock) DeriveStats

func (p *LogicalLock) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalLock) ExplainInfo

func (*LogicalLock) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalLock) ExtractColGroups

func (p *LogicalLock) ExtractColGroups(_ [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalLock) ExtractCorrelatedCols

func (*LogicalLock) ExtractCorrelatedCols() []*expression.CorrelatedColumn

func (*LogicalLock) ExtractFD

func (p *LogicalLock) ExtractFD() *fd.FDSet

ExtractFD return the children[0]'s fdSet if there are no adding/removing fd in this logic plan.

func (*LogicalLock) GetLogicalTS4TaskMap

func (p *LogicalLock) GetLogicalTS4TaskMap() uint64

GetLogicalTS4TaskMap get the logical TimeStamp now to help rollback the TaskMap changes after that.

func (*LogicalLock) HashCode

func (p *LogicalLock) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalLock) Init

Init initializes LogicalLock.

func (*LogicalLock) MaxOneRow

func (p *LogicalLock) MaxOneRow() bool

func (*LogicalLock) OutputNames

func (p *LogicalLock) OutputNames() types.NameSlice

func (*LogicalLock) PredicatePushDown

func (p *LogicalLock) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan interface.

func (*LogicalLock) PreparePossibleProperties

func (*LogicalLock) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalLock) PruneColumns

func (p *LogicalLock) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalLock) Schema

func (p *LogicalLock) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*LogicalLock) SetChild

func (p *LogicalLock) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalLock) SetChildren

func (p *LogicalLock) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

func (*LogicalLock) SetOutputNames

func (p *LogicalLock) SetOutputNames(names types.NameSlice)

type LogicalMaxOneRow

type LogicalMaxOneRow struct {
	// contains filtered or unexported fields
}

LogicalMaxOneRow checks if a query returns no more than one row.

func (*LogicalMaxOneRow) BuildKeyInfo

func (p *LogicalMaxOneRow) BuildKeyInfo(_ *expression.Schema, _ []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalMaxOneRow) Children

func (p *LogicalMaxOneRow) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalMaxOneRow) DeriveStats

func (p *LogicalMaxOneRow) DeriveStats(_ []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalMaxOneRow) ExplainInfo

func (*LogicalMaxOneRow) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalMaxOneRow) ExtractColGroups

func (p *LogicalMaxOneRow) ExtractColGroups(_ [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalMaxOneRow) ExtractCorrelatedCols

func (*LogicalMaxOneRow) ExtractCorrelatedCols() []*expression.CorrelatedColumn

func (*LogicalMaxOneRow) ExtractFD

func (p *LogicalMaxOneRow) ExtractFD() *fd.FDSet

ExtractFD return the children[0]'s fdSet if there are no adding/removing fd in this logic plan.

func (*LogicalMaxOneRow) GetLogicalTS4TaskMap

func (p *LogicalMaxOneRow) GetLogicalTS4TaskMap() uint64

GetLogicalTS4TaskMap get the logical TimeStamp now to help rollback the TaskMap changes after that.

func (*LogicalMaxOneRow) HashCode

func (p *LogicalMaxOneRow) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalMaxOneRow) Init

Init initializes LogicalMaxOneRow.

func (*LogicalMaxOneRow) MaxOneRow

func (p *LogicalMaxOneRow) MaxOneRow() bool

func (*LogicalMaxOneRow) OutputNames

func (p *LogicalMaxOneRow) OutputNames() types.NameSlice

func (*LogicalMaxOneRow) PredicatePushDown

func (p *LogicalMaxOneRow) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalMaxOneRow) PreparePossibleProperties

func (*LogicalMaxOneRow) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalMaxOneRow) PruneColumns

func (p *LogicalMaxOneRow) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalMaxOneRow) Schema

func (p *LogicalMaxOneRow) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalMaxOneRow) SetChild

func (p *LogicalMaxOneRow) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalMaxOneRow) SetChildren

func (p *LogicalMaxOneRow) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

func (*LogicalMaxOneRow) SetOutputNames

func (p *LogicalMaxOneRow) SetOutputNames(names types.NameSlice)

type LogicalMemTable

type LogicalMemTable struct {
	Extractor MemTablePredicateExtractor
	DBName    model.CIStr
	TableInfo *model.TableInfo
	Columns   []*model.ColumnInfo
	// QueryTimeRange is used to specify the time range for metrics summary tables and inspection tables
	// e.g: select /*+ time_range('2020-02-02 12:10:00', '2020-02-02 13:00:00') */ from metrics_summary;
	//      select /*+ time_range('2020-02-02 12:10:00', '2020-02-02 13:00:00') */ from metrics_summary_by_label;
	//      select /*+ time_range('2020-02-02 12:10:00', '2020-02-02 13:00:00') */ from inspection_summary;
	//      select /*+ time_range('2020-02-02 12:10:00', '2020-02-02 13:00:00') */ from inspection_result;
	QueryTimeRange QueryTimeRange
	// contains filtered or unexported fields
}

LogicalMemTable represents a memory table or virtual table Some memory tables wants to take the ownership of some predications e.g SELECT * FROM cluster_log WHERE type='tikv' AND address='192.16.5.32' Assume that the table `cluster_log` is a memory table, which is used to retrieve logs from remote components. In the above situation we should send log search request to the target TiKV (192.16.5.32) directly instead of requesting all cluster components log search gRPC interface to retrieve log message and filtering them in TiDB node.

func (*LogicalMemTable) BuildKeyInfo

func (p *LogicalMemTable) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalMemTable) DeriveStats

func (p *LogicalMemTable) DeriveStats(_ []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (LogicalMemTable) Init

func (p LogicalMemTable) Init(ctx sessionctx.Context, offset int) *LogicalMemTable

Init initializes LogicalMemTable.

func (*LogicalMemTable) OutputNames

func (s *LogicalMemTable) OutputNames() types.NameSlice

func (*LogicalMemTable) PredicatePushDown

func (p *LogicalMemTable) PredicatePushDown(predicates []expression.Expression, _ *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalMemTable) PruneColumns

func (p *LogicalMemTable) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalMemTable) Schema

func (s *LogicalMemTable) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalMemTable) SetOutputNames

func (s *LogicalMemTable) SetOutputNames(names types.NameSlice)

func (*LogicalMemTable) SetSchema

func (s *LogicalMemTable) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalPartitionUnionAll

type LogicalPartitionUnionAll struct {
	LogicalUnionAll
}

LogicalPartitionUnionAll represents the LogicalUnionAll plan is for partition table.

func (*LogicalPartitionUnionAll) BuildKeyInfo

func (p *LogicalPartitionUnionAll) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (LogicalPartitionUnionAll) Init

Init initializes LogicalPartitionUnionAll.

func (*LogicalPartitionUnionAll) OutputNames

func (s *LogicalPartitionUnionAll) OutputNames() types.NameSlice

func (*LogicalPartitionUnionAll) Schema

func (s *LogicalPartitionUnionAll) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalPartitionUnionAll) SetOutputNames

func (s *LogicalPartitionUnionAll) SetOutputNames(names types.NameSlice)

func (*LogicalPartitionUnionAll) SetSchema

func (s *LogicalPartitionUnionAll) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalPlan

type LogicalPlan interface {
	Plan

	// HashCode encodes a LogicalPlan to fast compare whether a LogicalPlan equals to another.
	// We use a strict encode method here which ensures there is no conflict.
	HashCode() []byte

	// PredicatePushDown pushes down the predicates in the where/on/having clauses as deeply as possible.
	// It will accept a predicate that is an expression slice, and return the expressions that can't be pushed.
	// Because it might change the root if the having clause exists, we need to return a plan that represents a new root.
	PredicatePushDown([]expression.Expression, *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

	// PruneColumns prunes the unused columns.
	PruneColumns([]*expression.Column, *logicalOptimizeOp) error

	// BuildKeyInfo will collect the information of unique keys into schema.
	// Because this method is also used in cascades planner, we cannot use
	// things like `p.schema` or `p.children` inside it. We should use the `selfSchema`
	// and `childSchema` instead.
	BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

	// DeriveStats derives statistic info for current plan node given child stats.
	// We need selfSchema, childSchema here because it makes this method can be used in
	// cascades planner, where LogicalPlan might not record its children or schema.
	DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema, colGroups [][]*expression.Column) (*property.StatsInfo, error)

	// ExtractColGroups extracts column groups from child operator whose DNVs are required by the current operator.
	// For example, if current operator is LogicalAggregation of `Group By a, b`, we indicate the child operators to maintain
	// and propagate the NDV info of column group (a, b), to improve the row count estimation of current LogicalAggregation.
	// The parameter colGroups are column groups required by upper operators, besides from the column groups derived from
	// current operator, we should pass down parent colGroups to child operator as many as possible.
	ExtractColGroups(colGroups [][]*expression.Column) [][]*expression.Column

	// PreparePossibleProperties is only used for join and aggregation. Like group by a,b,c, all permutation of (a,b,c) is
	// valid, but the ordered indices in leaf plan is limited. So we can get all possible order properties by a pre-walking.
	PreparePossibleProperties(schema *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

	// ExtractCorrelatedCols extracts correlated columns inside the LogicalPlan.
	ExtractCorrelatedCols() []*expression.CorrelatedColumn

	// MaxOneRow means whether this operator only returns max one row.
	MaxOneRow() bool

	// Get all the children.
	Children() []LogicalPlan

	// SetChildren sets the children for the plan.
	SetChildren(...LogicalPlan)

	// SetChild sets the ith child for the plan.
	SetChild(i int, child LogicalPlan)

	// ExtractFD derive the FDSet from the tree bottom up.
	ExtractFD() *fd.FDSet
	// contains filtered or unexported methods
}

LogicalPlan is a tree of logical operators. We can do a lot of logical optimizations to it, like predicate pushdown and column pruning.

func Conds2TableDual

func Conds2TableDual(p LogicalPlan, conds []expression.Expression) LogicalPlan

Conds2TableDual builds a LogicalTableDual if cond is constant false or null.

func LogicalOptimizeTest

func LogicalOptimizeTest(ctx context.Context, flag uint64, logic LogicalPlan) (LogicalPlan, error)

LogicalOptimizeTest is just exported for test.

type LogicalProjection

type LogicalProjection struct {
	Exprs []expression.Expression

	// CalculateNoDelay indicates this Projection is the root Plan and should be
	// calculated without delay and will not return any result to client.
	// Currently it is "true" only when the current sql query is a "DO" statement.
	// See "https://dev.mysql.com/doc/refman/5.7/en/do.html" for more detail.
	CalculateNoDelay bool

	// AvoidColumnEvaluator is a temporary variable which is ONLY used to avoid
	// building columnEvaluator for the expressions of Projection which is
	// built by buildProjection4Union.
	// This can be removed after column pool being supported.
	// Related issue: TiDB#8141(https://github.com/lemon-mint/tidb/v7/issues/8141)
	AvoidColumnEvaluator bool
	// contains filtered or unexported fields
}

LogicalProjection represents a select fields plan.

func ConvertAggToProj

func ConvertAggToProj(agg *LogicalAggregation, schema *expression.Schema) (bool, *LogicalProjection)

ConvertAggToProj convert aggregation to projection.

func (*LogicalProjection) BuildKeyInfo

func (p *LogicalProjection) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalProjection) DeriveStats

func (p *LogicalProjection) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema, colGroups [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalProjection) ExplainInfo

func (p *LogicalProjection) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalProjection) ExtractColGroups

func (p *LogicalProjection) ExtractColGroups(colGroups [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalProjection) ExtractCorrelatedCols

func (p *LogicalProjection) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalProjection) ExtractFD

func (p *LogicalProjection) ExtractFD() *fd.FDSet

ExtractFD implements the logical plan interface, extracting the FD from bottom up.

func (*LogicalProjection) GetUsedCols

func (p *LogicalProjection) GetUsedCols() (usedCols []*expression.Column)

GetUsedCols extracts all of the Columns used by proj.

func (*LogicalProjection) HashCode

func (p *LogicalProjection) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalProjection) Init

Init initializes LogicalProjection.

func (*LogicalProjection) OutputNames

func (s *LogicalProjection) OutputNames() types.NameSlice

func (*LogicalProjection) PredicatePushDown

func (p *LogicalProjection) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) (ret []expression.Expression, retPlan LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalProjection) PreparePossibleProperties

func (p *LogicalProjection) PreparePossibleProperties(_ *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalProjection) PruneColumns

func (p *LogicalProjection) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface. If any expression has SetVar function or Sleep function, we do not prune it.

func (*LogicalProjection) Schema

func (s *LogicalProjection) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalProjection) SetOutputNames

func (s *LogicalProjection) SetOutputNames(names types.NameSlice)

func (*LogicalProjection) SetSchema

func (s *LogicalProjection) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*LogicalProjection) TryToGetChildProp

func (p *LogicalProjection) TryToGetChildProp(prop *property.PhysicalProperty) (*property.PhysicalProperty, bool)

TryToGetChildProp will check if this sort property can be pushed or not. When a sort column will be replaced by scalar function, we refuse it. When a sort column will be replaced by a constant, we just remove it.

type LogicalSelection

type LogicalSelection struct {

	// Originally the WHERE or ON condition is parsed into a single expression,
	// but after we converted to CNF(Conjunctive normal form), it can be
	// split into a list of AND conditions.
	Conditions []expression.Expression
	// contains filtered or unexported fields
}

LogicalSelection represents a where or having predicate.

func (*LogicalSelection) BuildKeyInfo

func (p *LogicalSelection) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalSelection) Children

func (p *LogicalSelection) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalSelection) DeriveStats

func (p *LogicalSelection) DeriveStats(childStats []*property.StatsInfo, _ *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalSelection) ExplainInfo

func (p *LogicalSelection) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalSelection) ExtractColGroups

func (p *LogicalSelection) ExtractColGroups(_ [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalSelection) ExtractCorrelatedCols

func (p *LogicalSelection) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalSelection) ExtractFD

func (p *LogicalSelection) ExtractFD() *fd.FDSet

ExtractFD implements the LogicalPlan interface.

func (*LogicalSelection) GetLogicalTS4TaskMap

func (p *LogicalSelection) GetLogicalTS4TaskMap() uint64

GetLogicalTS4TaskMap get the logical TimeStamp now to help rollback the TaskMap changes after that.

func (*LogicalSelection) HashCode

func (p *LogicalSelection) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalSelection) Init

Init initializes LogicalSelection.

func (*LogicalSelection) MaxOneRow

func (p *LogicalSelection) MaxOneRow() bool

func (*LogicalSelection) OutputNames

func (p *LogicalSelection) OutputNames() types.NameSlice

func (*LogicalSelection) PredicatePushDown

func (p *LogicalSelection) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalSelection) PreparePossibleProperties

func (*LogicalSelection) PreparePossibleProperties(_ *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalSelection) PruneColumns

func (p *LogicalSelection) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalSelection) Schema

func (p *LogicalSelection) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*LogicalSelection) SetChild

func (p *LogicalSelection) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalSelection) SetChildren

func (p *LogicalSelection) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

func (*LogicalSelection) SetOutputNames

func (p *LogicalSelection) SetOutputNames(names types.NameSlice)

type LogicalShow

type LogicalShow struct {
	ShowContents

	Extractor ShowPredicateExtractor
	// contains filtered or unexported fields
}

LogicalShow represents a show plan.

func (*LogicalShow) BuildKeyInfo

func (p *LogicalShow) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalShow) DeriveStats

func (p *LogicalShow) DeriveStats(_ []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (LogicalShow) Init

Init initializes LogicalShow.

func (*LogicalShow) OutputNames

func (s *LogicalShow) OutputNames() types.NameSlice

func (*LogicalShow) Schema

func (s *LogicalShow) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalShow) SetOutputNames

func (s *LogicalShow) SetOutputNames(names types.NameSlice)

func (*LogicalShow) SetSchema

func (s *LogicalShow) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalShowDDLJobs

type LogicalShowDDLJobs struct {
	JobNumber int64
	// contains filtered or unexported fields
}

LogicalShowDDLJobs is for showing DDL job list.

func (*LogicalShowDDLJobs) BuildKeyInfo

func (p *LogicalShowDDLJobs) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalShowDDLJobs) DeriveStats

func (p *LogicalShowDDLJobs) DeriveStats(_ []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (LogicalShowDDLJobs) Init

Init initializes LogicalShowDDLJobs.

func (*LogicalShowDDLJobs) OutputNames

func (s *LogicalShowDDLJobs) OutputNames() types.NameSlice

func (*LogicalShowDDLJobs) Schema

func (s *LogicalShowDDLJobs) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalShowDDLJobs) SetOutputNames

func (s *LogicalShowDDLJobs) SetOutputNames(names types.NameSlice)

func (*LogicalShowDDLJobs) SetSchema

func (s *LogicalShowDDLJobs) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalSort

type LogicalSort struct {
	ByItems []*util.ByItems
	// contains filtered or unexported fields
}

LogicalSort stands for the order by plan.

func (*LogicalSort) BuildKeyInfo

func (p *LogicalSort) BuildKeyInfo(_ *expression.Schema, _ []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalSort) Children

func (p *LogicalSort) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalSort) DeriveStats

func (p *LogicalSort) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalSort) ExplainInfo

func (p *LogicalSort) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalSort) ExtractColGroups

func (p *LogicalSort) ExtractColGroups(_ [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalSort) ExtractCorrelatedCols

func (ls *LogicalSort) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalSort) ExtractFD

func (p *LogicalSort) ExtractFD() *fd.FDSet

ExtractFD return the children[0]'s fdSet if there are no adding/removing fd in this logic plan.

func (*LogicalSort) GetLogicalTS4TaskMap

func (p *LogicalSort) GetLogicalTS4TaskMap() uint64

GetLogicalTS4TaskMap get the logical TimeStamp now to help rollback the TaskMap changes after that.

func (*LogicalSort) HashCode

func (p *LogicalSort) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalSort) Init

func (ls LogicalSort) Init(ctx sessionctx.Context, offset int) *LogicalSort

Init initializes LogicalSort.

func (*LogicalSort) MaxOneRow

func (p *LogicalSort) MaxOneRow() bool

func (*LogicalSort) OutputNames

func (p *LogicalSort) OutputNames() types.NameSlice

func (*LogicalSort) PredicatePushDown

func (p *LogicalSort) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan interface.

func (*LogicalSort) PreparePossibleProperties

func (p *LogicalSort) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalSort) PruneColumns

func (ls *LogicalSort) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface. If any expression can view as a constant in execution stage, such as correlated column, constant, we do prune them. Note that we can't prune the expressions contain non-deterministic functions, such as rand().

func (*LogicalSort) Schema

func (p *LogicalSort) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*LogicalSort) SetChild

func (p *LogicalSort) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalSort) SetChildren

func (p *LogicalSort) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

func (*LogicalSort) SetOutputNames

func (p *LogicalSort) SetOutputNames(names types.NameSlice)

type LogicalTableDual

type LogicalTableDual struct {
	RowCount int
	// contains filtered or unexported fields
}

LogicalTableDual represents a dual table plan.

func (*LogicalTableDual) BuildKeyInfo

func (p *LogicalTableDual) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalTableDual) DeriveStats

func (p *LogicalTableDual) DeriveStats(_ []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalTableDual) ExplainInfo

func (p *LogicalTableDual) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalTableDual) HashCode

func (p *LogicalTableDual) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalTableDual) Init

Init initializes LogicalTableDual.

func (*LogicalTableDual) OutputNames

func (s *LogicalTableDual) OutputNames() types.NameSlice

func (*LogicalTableDual) PredicatePushDown

func (p *LogicalTableDual) PredicatePushDown(predicates []expression.Expression, _ *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalTableDual) PruneColumns

func (p *LogicalTableDual) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalTableDual) Schema

func (s *LogicalTableDual) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalTableDual) SetOutputNames

func (s *LogicalTableDual) SetOutputNames(names types.NameSlice)

func (*LogicalTableDual) SetSchema

func (s *LogicalTableDual) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalTableScan

type LogicalTableScan struct {
	Source      *DataSource
	HandleCols  HandleCols
	AccessConds expression.CNFExprs
	Ranges      []*ranger.Range
	// contains filtered or unexported fields
}

LogicalTableScan is the logical table scan operator for TiKV.

func (*LogicalTableScan) BuildKeyInfo

func (ts *LogicalTableScan) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalTableScan) DeriveStats

func (ts *LogicalTableScan) DeriveStats(_ []*property.StatsInfo, _ *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (_ *property.StatsInfo, err error)

DeriveStats implements LogicalPlan DeriveStats interface.

func (*LogicalTableScan) ExplainInfo

func (p *LogicalTableScan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalTableScan) GetPhysicalScan

func (s *LogicalTableScan) GetPhysicalScan(schema *expression.Schema, stats *property.StatsInfo) *PhysicalTableScan

GetPhysicalScan returns PhysicalTableScan for the LogicalTableScan.

func (LogicalTableScan) Init

func (ts LogicalTableScan) Init(ctx sessionctx.Context, offset int) *LogicalTableScan

Init initializes LogicalTableScan.

func (*LogicalTableScan) OutputNames

func (s *LogicalTableScan) OutputNames() types.NameSlice

func (*LogicalTableScan) PreparePossibleProperties

func (ts *LogicalTableScan) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalTableScan) Schema

func (s *LogicalTableScan) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalTableScan) SetOutputNames

func (s *LogicalTableScan) SetOutputNames(names types.NameSlice)

func (*LogicalTableScan) SetSchema

func (s *LogicalTableScan) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalTopN

type LogicalTopN struct {
	ByItems []*util.ByItems
	Offset  uint64
	Count   uint64
	// contains filtered or unexported fields
}

LogicalTopN represents a top-n plan.

func (*LogicalTopN) BuildKeyInfo

func (lt *LogicalTopN) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalTopN) Children

func (p *LogicalTopN) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalTopN) DeriveStats

func (lt *LogicalTopN) DeriveStats(childStats []*property.StatsInfo, _ *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalTopN) ExplainInfo

func (lt *LogicalTopN) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalTopN) ExtractColGroups

func (p *LogicalTopN) ExtractColGroups(_ [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalTopN) ExtractCorrelatedCols

func (lt *LogicalTopN) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalTopN) ExtractFD

func (p *LogicalTopN) ExtractFD() *fd.FDSet

ExtractFD return the children[0]'s fdSet if there are no adding/removing fd in this logic plan.

func (*LogicalTopN) GetLogicalTS4TaskMap

func (p *LogicalTopN) GetLogicalTS4TaskMap() uint64

GetLogicalTS4TaskMap get the logical TimeStamp now to help rollback the TaskMap changes after that.

func (*LogicalTopN) HashCode

func (p *LogicalTopN) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalTopN) Init

func (lt LogicalTopN) Init(ctx sessionctx.Context, offset int) *LogicalTopN

Init initializes LogicalTopN.

func (*LogicalTopN) MaxOneRow

func (p *LogicalTopN) MaxOneRow() bool

func (*LogicalTopN) OutputNames

func (p *LogicalTopN) OutputNames() types.NameSlice

func (*LogicalTopN) PredicatePushDown

func (p *LogicalTopN) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan interface.

func (*LogicalTopN) PreparePossibleProperties

func (lt *LogicalTopN) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalTopN) PruneColumns

func (lt *LogicalTopN) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface. If any expression can view as a constant in execution stage, such as correlated column, constant, we do prune them. Note that we can't prune the expressions contain non-deterministic functions, such as rand().

func (*LogicalTopN) Schema

func (p *LogicalTopN) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*LogicalTopN) SetChild

func (p *LogicalTopN) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalTopN) SetChildren

func (p *LogicalTopN) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

func (*LogicalTopN) SetOutputNames

func (p *LogicalTopN) SetOutputNames(names types.NameSlice)

type LogicalUnionAll

type LogicalUnionAll struct {
	// contains filtered or unexported fields
}

LogicalUnionAll represents LogicalUnionAll plan.

func (*LogicalUnionAll) BuildKeyInfo

func (p *LogicalUnionAll) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalUnionAll) DeriveStats

func (p *LogicalUnionAll) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (LogicalUnionAll) Init

func (p LogicalUnionAll) Init(ctx sessionctx.Context, offset int) *LogicalUnionAll

Init initializes LogicalUnionAll.

func (*LogicalUnionAll) OutputNames

func (s *LogicalUnionAll) OutputNames() types.NameSlice

func (*LogicalUnionAll) PredicatePushDown

func (p *LogicalUnionAll) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) (ret []expression.Expression, retPlan LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalUnionAll) PruneColumns

func (p *LogicalUnionAll) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalUnionAll) Schema

func (s *LogicalUnionAll) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalUnionAll) SetOutputNames

func (s *LogicalUnionAll) SetOutputNames(names types.NameSlice)

func (*LogicalUnionAll) SetSchema

func (s *LogicalUnionAll) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type LogicalUnionScan

type LogicalUnionScan struct {
	// contains filtered or unexported fields
}

LogicalUnionScan is used in non read-only txn or for scanning a local temporary table whose snapshot data is located in memory.

func (*LogicalUnionScan) BuildKeyInfo

func (p *LogicalUnionScan) BuildKeyInfo(_ *expression.Schema, _ []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalUnionScan) Children

func (p *LogicalUnionScan) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalUnionScan) DeriveStats

func (p *LogicalUnionScan) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, _ [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalUnionScan) ExplainInfo

func (p *LogicalUnionScan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalUnionScan) ExtractColGroups

func (p *LogicalUnionScan) ExtractColGroups(_ [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalUnionScan) ExtractCorrelatedCols

func (*LogicalUnionScan) ExtractCorrelatedCols() []*expression.CorrelatedColumn

func (*LogicalUnionScan) ExtractFD

func (p *LogicalUnionScan) ExtractFD() *fd.FDSet

ExtractFD return the children[0]'s fdSet if there are no adding/removing fd in this logic plan.

func (*LogicalUnionScan) GetLogicalTS4TaskMap

func (p *LogicalUnionScan) GetLogicalTS4TaskMap() uint64

GetLogicalTS4TaskMap get the logical TimeStamp now to help rollback the TaskMap changes after that.

func (*LogicalUnionScan) HashCode

func (p *LogicalUnionScan) HashCode() []byte

HashCode implements LogicalPlan interface.

func (LogicalUnionScan) Init

Init initializes LogicalUnionScan.

func (*LogicalUnionScan) MaxOneRow

func (p *LogicalUnionScan) MaxOneRow() bool

func (*LogicalUnionScan) OutputNames

func (p *LogicalUnionScan) OutputNames() types.NameSlice

func (*LogicalUnionScan) PredicatePushDown

func (p *LogicalUnionScan) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalUnionScan) PreparePossibleProperties

func (*LogicalUnionScan) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalUnionScan) PruneColumns

func (p *LogicalUnionScan) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalUnionScan) Schema

func (p *LogicalUnionScan) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*LogicalUnionScan) SetChild

func (p *LogicalUnionScan) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalUnionScan) SetChildren

func (p *LogicalUnionScan) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

func (*LogicalUnionScan) SetOutputNames

func (p *LogicalUnionScan) SetOutputNames(names types.NameSlice)

type LogicalWindow

type LogicalWindow struct {
	WindowFuncDescs []*aggregation.WindowFuncDesc
	PartitionBy     []property.SortItem
	OrderBy         []property.SortItem
	Frame           *WindowFrame
	// contains filtered or unexported fields
}

LogicalWindow represents a logical window function plan.

func (*LogicalWindow) BuildKeyInfo

func (p *LogicalWindow) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalWindow) DeriveStats

func (p *LogicalWindow) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, _ []*expression.Schema, colGroups [][]*expression.Column) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalWindow) EqualFrame

func (p *LogicalWindow) EqualFrame(ctx sessionctx.Context, newWindow *LogicalWindow) bool

EqualFrame checks whether two LogicalWindow.Frames are equal.

func (*LogicalWindow) EqualOrderBy

func (p *LogicalWindow) EqualOrderBy(ctx sessionctx.Context, newWindow *LogicalWindow) bool

EqualOrderBy checks whether two LogicalWindow.OrderBys are equal.

func (*LogicalWindow) EqualPartitionBy

func (p *LogicalWindow) EqualPartitionBy(_ sessionctx.Context, newWindow *LogicalWindow) bool

EqualPartitionBy checks whether two LogicalWindow.Partitions are equal.

func (*LogicalWindow) ExtractColGroups

func (p *LogicalWindow) ExtractColGroups(colGroups [][]*expression.Column) [][]*expression.Column

ExtractColGroups implements LogicalPlan ExtractColGroups interface.

func (*LogicalWindow) ExtractCorrelatedCols

func (p *LogicalWindow) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalWindow) GetPartitionByCols

func (p *LogicalWindow) GetPartitionByCols() []*expression.Column

GetPartitionByCols extracts 'partition by' columns from the Window.

func (*LogicalWindow) GetPartitionKeys

func (lw *LogicalWindow) GetPartitionKeys() []*property.MPPPartitionColumn

GetPartitionKeys gets partition keys for a logical window, it will assign column id for expressions.

func (*LogicalWindow) GetWindowResultColumns

func (p *LogicalWindow) GetWindowResultColumns() []*expression.Column

GetWindowResultColumns returns the columns storing the result of the window function.

func (LogicalWindow) Init

func (p LogicalWindow) Init(ctx sessionctx.Context, offset int) *LogicalWindow

Init initializes LogicalWindow.

func (*LogicalWindow) OutputNames

func (s *LogicalWindow) OutputNames() types.NameSlice

func (*LogicalWindow) PredicatePushDown

func (p *LogicalWindow) PredicatePushDown(predicates []expression.Expression, opt *logicalOptimizeOp) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalWindow) PreparePossibleProperties

func (p *LogicalWindow) PreparePossibleProperties(_ *expression.Schema, _ ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalWindow) PruneColumns

func (p *LogicalWindow) PruneColumns(parentUsedCols []*expression.Column, opt *logicalOptimizeOp) error

PruneColumns implements LogicalPlan interface.

func (*LogicalWindow) Schema

func (s *LogicalWindow) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*LogicalWindow) SetOutputNames

func (s *LogicalWindow) SetOutputNames(names types.NameSlice)

func (*LogicalWindow) SetSchema

func (s *LogicalWindow) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type MemTablePredicateExtractor

type MemTablePredicateExtractor interface {
	// Extracts predicates which can be pushed down and returns the remained predicates
	Extract(sessionctx.Context, *expression.Schema, []*types.FieldName, []expression.Expression) (remained []expression.Expression)
	// contains filtered or unexported methods
}

MemTablePredicateExtractor is used to extract some predicates from `WHERE` clause and push the predicates down to the data retrieving on reading memory table stage.

e.g: SELECT * FROM cluster_config WHERE type='tikv' AND instance='192.168.1.9:2379' We must request all components in the cluster via HTTP API for retrieving configurations and filter them by `type/instance` columns.

The purpose of defining a `MemTablePredicateExtractor` is to optimize this 1. Define a `ClusterConfigTablePredicateExtractor` 2. Extract the `type/instance` columns on the logic optimizing stage and save them via fields. 3. Passing the extractor to the `ClusterReaderExecExec` executor 4. Executor sends requests to the target components instead of all of the components

type MergeHintInfo

type MergeHintInfo struct {
	// contains filtered or unexported fields
}

MergeHintInfo ...one bool flag for cte

type MetricSummaryTableExtractor

type MetricSummaryTableExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component
	SkipRequest  bool
	MetricsNames set.StringSet
	Quantiles    []float64
	// contains filtered or unexported fields
}

MetricSummaryTableExtractor is used to extract some predicates of metrics_schema tables.

func (*MetricSummaryTableExtractor) Extract

func (e *MetricSummaryTableExtractor) Extract(
	_ sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) (remained []expression.Expression)

Extract implements the MemTablePredicateExtractor Extract interface

type MetricTableExtractor

type MetricTableExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component
	SkipRequest bool
	// StartTime represents the beginning time of metric data.
	StartTime time.Time
	// EndTime represents the ending time of metric data.
	EndTime time.Time
	// LabelConditions represents the label conditions of metric data.
	LabelConditions map[string]set.StringSet
	Quantiles       []float64
	// contains filtered or unexported fields
}

MetricTableExtractor is used to extract some predicates of metrics_schema tables.

func (*MetricTableExtractor) Extract

func (e *MetricTableExtractor) Extract(
	ctx sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) []expression.Expression

Extract implements the MemTablePredicateExtractor Extract interface

func (*MetricTableExtractor) GetMetricTablePromQL

func (e *MetricTableExtractor) GetMetricTablePromQL(sctx sessionctx.Context, lowerTableName string) string

GetMetricTablePromQL uses to get the promQL of metric table.

type NominalSort

type NominalSort struct {

	// These two fields are used to switch ScalarFunctions to Constants. For these
	// NominalSorts, we need to converted to Projections check if the ScalarFunctions
	// are out of bounds. (issue #11653)
	ByItems    []*util.ByItems
	OnlyColumn bool
	// contains filtered or unexported fields
}

NominalSort asks sort properties for its child. It is a fake operator that will not appear in final physical operator tree. It will be eliminated or converted to Projection.

func (*NominalSort) Children

func (p *NominalSort) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*NominalSort) Clone

func (p *NominalSort) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*NominalSort) ExplainInfo

func (*NominalSort) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*NominalSort) ExplainNormalizedInfo

func (*NominalSort) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*NominalSort) ExtractCorrelatedCols

func (*NominalSort) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*NominalSort) GetChildReqProps

func (p *NominalSort) GetChildReqProps(idx int) *property.PhysicalProperty

func (NominalSort) Init

func (p NominalSort) Init(ctx sessionctx.Context, stats *property.StatsInfo, offset int, props ...*property.PhysicalProperty) *NominalSort

Init initializes NominalSort.

func (*NominalSort) MemoryUsage

func (ns *NominalSort) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of NominalSort

func (*NominalSort) ResolveIndices

func (p *NominalSort) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*NominalSort) Schema

func (p *NominalSort) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*NominalSort) SetChild

func (p *NominalSort) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*NominalSort) SetChildren

func (p *NominalSort) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*NominalSort) StatsCount

func (p *NominalSort) StatsCount() float64

func (*NominalSort) ToPB

func (p *NominalSort) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type OperatorLabel

type OperatorLabel uint8

OperatorLabel acts as some additional information to the name, usually it means its relationship with its parent. It's useful for index join, apply, index lookup, cte and so on.

const (
	// Empty means OperatorLabel is meaningless for this operator.
	Empty OperatorLabel = iota
	// BuildSide means this operator is at the build side of its parent
	BuildSide
	// ProbeSide means this operator is at the probe side of its parent
	ProbeSide
	// SeedPart means this operator is the seed part of its parent (a cte)
	SeedPart
	// RecursivePart means this operator is the recursive part of its parent (a cte)
	RecursivePart
)

func (OperatorLabel) String

func (d OperatorLabel) String() string

type OtherAccessObject

type OtherAccessObject string

OtherAccessObject represents other kinds of access.

func (OtherAccessObject) NormalizedString

func (o OtherAccessObject) NormalizedString() string

NormalizedString implements AccessObject.

func (OtherAccessObject) SetIntoPB

func (o OtherAccessObject) SetIntoPB(pb *tipb.ExplainOperator)

SetIntoPB implements AccessObject.

func (OtherAccessObject) String

func (o OtherAccessObject) String() string

type PBPlanBuilder

type PBPlanBuilder struct {
	// contains filtered or unexported fields
}

PBPlanBuilder uses to build physical plan from dag protocol buffers.

func NewPBPlanBuilder

func NewPBPlanBuilder(sctx sessionctx.Context, is infoschema.InfoSchema, ranges []*coprocessor.KeyRange) *PBPlanBuilder

NewPBPlanBuilder creates a new pb plan builder.

func (*PBPlanBuilder) Build

func (b *PBPlanBuilder) Build(executors []*tipb.Executor) (p PhysicalPlan, err error)

Build builds physical plan from dag protocol buffers.

type PartitionInfo

type PartitionInfo struct {
	PruningConds   []expression.Expression
	PartitionNames []model.CIStr
	Columns        []*expression.Column
	ColumnNames    types.NameSlice
}

PartitionInfo indicates partition helper info in physical plan.

func (*PartitionInfo) MemoryUsage

func (pi *PartitionInfo) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PartitionInfo

type PartitionSplitterType

type PartitionSplitterType int

PartitionSplitterType is the type of `Shuffle` executor splitter, which splits data source into partitions.

type PhysicalApply

type PhysicalApply struct {
	PhysicalHashJoin

	CanUseCache bool
	Concurrency int
	OuterSchema []*expression.CorrelatedColumn
}

PhysicalApply represents apply plan, only used for subquery.

func (*PhysicalApply) Clone

func (la *PhysicalApply) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalApply) ExtractCorrelatedCols

func (la *PhysicalApply) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalApply) GetCost

func (p *PhysicalApply) GetCost(lCount, rCount, lCost, rCost float64) float64

GetCost computes the cost of apply operator.

func (PhysicalApply) Init

Init initializes PhysicalApply.

func (*PhysicalApply) MemoryUsage

func (la *PhysicalApply) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalApply

func (*PhysicalApply) ResolveIndices

func (p *PhysicalApply) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

type PhysicalCTE

type PhysicalCTE struct {
	SeedPlan  PhysicalPlan
	RecurPlan PhysicalPlan
	CTE       *CTEClass
	// contains filtered or unexported fields
}

PhysicalCTE is for CTE.

func (*PhysicalCTE) AccessObject

func (p *PhysicalCTE) AccessObject() AccessObject

AccessObject implements physicalScan interface.

func (*PhysicalCTE) ExplainID

func (p *PhysicalCTE) ExplainID() fmt.Stringer

ExplainID overrides the ExplainID.

func (*PhysicalCTE) ExplainInfo

func (p *PhysicalCTE) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalCTE) ExtractCorrelatedCols

func (p *PhysicalCTE) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (PhysicalCTE) Init

Init only assigns type and context.

func (*PhysicalCTE) MemoryUsage

func (p *PhysicalCTE) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalCTE

func (*PhysicalCTE) OperatorInfo

func (p *PhysicalCTE) OperatorInfo(_ bool) string

OperatorInfo implements dataAccesser interface.

func (*PhysicalCTE) ResolveIndices

func (p *PhysicalCTE) ResolveIndices() (err error)

func (*PhysicalCTE) Schema

func (s *PhysicalCTE) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalCTE) SetSchema

func (s *PhysicalCTE) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalCTETable

type PhysicalCTETable struct {
	IDForStorage int
	// contains filtered or unexported fields
}

PhysicalCTETable is for CTE table.

func (*PhysicalCTETable) ExplainInfo

func (p *PhysicalCTETable) ExplainInfo() string

ExplainInfo overrides the ExplainInfo

func (PhysicalCTETable) Init

Init only assigns type and context.

func (*PhysicalCTETable) MemoryUsage

func (p *PhysicalCTETable) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalCTETable

func (*PhysicalCTETable) ResolveIndices

func (p *PhysicalCTETable) ResolveIndices() (err error)

func (*PhysicalCTETable) Schema

func (s *PhysicalCTETable) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalCTETable) SetSchema

func (s *PhysicalCTETable) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalExchangeReceiver

type PhysicalExchangeReceiver struct {
	Tasks []*kv.MPPTask
	// contains filtered or unexported fields
}

PhysicalExchangeReceiver accepts connection and receives data passively.

func (*PhysicalExchangeReceiver) Children

func (p *PhysicalExchangeReceiver) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalExchangeReceiver) Clone

Clone implment PhysicalPlan interface.

func (*PhysicalExchangeReceiver) ExplainInfo

func (p *PhysicalExchangeReceiver) ExplainInfo() (res string)

ExplainInfo implements Plan interface.

func (*PhysicalExchangeReceiver) ExplainNormalizedInfo

func (*PhysicalExchangeReceiver) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*PhysicalExchangeReceiver) ExtractCorrelatedCols

func (*PhysicalExchangeReceiver) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalExchangeReceiver) GetChildReqProps

func (p *PhysicalExchangeReceiver) GetChildReqProps(idx int) *property.PhysicalProperty

func (*PhysicalExchangeReceiver) GetExchangeSender

func (p *PhysicalExchangeReceiver) GetExchangeSender() *PhysicalExchangeSender

GetExchangeSender return the connected sender of this receiver. We assume that its child must be a receiver.

func (PhysicalExchangeReceiver) Init

Init only assigns type and context.

func (*PhysicalExchangeReceiver) MemoryUsage

func (p *PhysicalExchangeReceiver) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalExchangeReceiver

func (*PhysicalExchangeReceiver) ResolveIndices

func (p *PhysicalExchangeReceiver) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalExchangeReceiver) Schema

func (p *PhysicalExchangeReceiver) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalExchangeReceiver) SetChild

func (p *PhysicalExchangeReceiver) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalExchangeReceiver) SetChildren

func (p *PhysicalExchangeReceiver) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalExchangeReceiver) StatsCount

func (p *PhysicalExchangeReceiver) StatsCount() float64

func (*PhysicalExchangeReceiver) ToPB

func (e *PhysicalExchangeReceiver) ToPB(ctx sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB generates the pb structure.

type PhysicalExchangeSender

type PhysicalExchangeSender struct {
	TargetTasks  []*kv.MPPTask
	ExchangeType tipb.ExchangeType
	HashCols     []*property.MPPPartitionColumn
	// Tasks is the mpp task for current PhysicalExchangeSender.
	Tasks []*kv.MPPTask
	// contains filtered or unexported fields
}

PhysicalExchangeSender dispatches data to upstream tasks. That means push mode processing,

func (*PhysicalExchangeSender) Children

func (p *PhysicalExchangeSender) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalExchangeSender) Clone

Clone implment PhysicalPlan interface.

func (*PhysicalExchangeSender) ExplainInfo

func (p *PhysicalExchangeSender) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalExchangeSender) ExplainNormalizedInfo

func (*PhysicalExchangeSender) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*PhysicalExchangeSender) ExtractCorrelatedCols

func (*PhysicalExchangeSender) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalExchangeSender) GetChildReqProps

func (p *PhysicalExchangeSender) GetChildReqProps(idx int) *property.PhysicalProperty

func (PhysicalExchangeSender) Init

Init only assigns type and context.

func (*PhysicalExchangeSender) MemoryUsage

func (p *PhysicalExchangeSender) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalExchangeSender

func (*PhysicalExchangeSender) ResolveIndices

func (p *PhysicalExchangeSender) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalExchangeSender) ResolveIndicesItself

func (p *PhysicalExchangeSender) ResolveIndicesItself() (err error)

ResolveIndicesItself resolve indices for PhyicalPlan itself

func (*PhysicalExchangeSender) Schema

func (p *PhysicalExchangeSender) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalExchangeSender) SetChild

func (p *PhysicalExchangeSender) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalExchangeSender) SetChildren

func (p *PhysicalExchangeSender) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalExchangeSender) StatsCount

func (p *PhysicalExchangeSender) StatsCount() float64

func (*PhysicalExchangeSender) ToPB

func (e *PhysicalExchangeSender) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB generates the pb structure.

type PhysicalHashAgg

type PhysicalHashAgg struct {
	// contains filtered or unexported fields
}

PhysicalHashAgg is hash operator of aggregate.

func NewPhysicalHashAgg

func NewPhysicalHashAgg(la *LogicalAggregation, newStats *property.StatsInfo, prop *property.PhysicalProperty) *PhysicalHashAgg

NewPhysicalHashAgg creates a new PhysicalHashAgg from a LogicalAggregation.

func (*PhysicalHashAgg) Clone

func (p *PhysicalHashAgg) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalHashAgg) ExplainInfo

func (p *PhysicalHashAgg) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalHashAgg) ExplainNormalizedInfo

func (p *PhysicalHashAgg) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalHashAgg) ExtractCorrelatedCols

func (p *PhysicalHashAgg) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalHashAgg) GetCost

func (p *PhysicalHashAgg) GetCost(inputRows float64, isRoot, isMPP bool, costFlag uint64) float64

GetCost computes the cost of hash aggregation considering CPU/memory.

func (PhysicalHashAgg) Init

func (base PhysicalHashAgg) Init(ctx sessionctx.Context, stats *property.StatsInfo, offset int) *basePhysicalAgg

Init initializes basePhysicalAgg.

func (*PhysicalHashAgg) IsFinalAgg

func (p *PhysicalHashAgg) IsFinalAgg() bool

func (*PhysicalHashAgg) MemoryUsage

func (p *PhysicalHashAgg) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalHashAgg

func (*PhysicalHashAgg) ResolveIndices

func (p *PhysicalHashAgg) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalHashAgg) ToPB

func (p *PhysicalHashAgg) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalHashJoin

type PhysicalHashJoin struct {
	Concurrency     uint
	EqualConditions []*expression.ScalarFunction

	NAEqualConditions []*expression.ScalarFunction

	// use the outer table to build a hash table when the outer table is smaller.
	UseOuterToBuild bool
	// contains filtered or unexported fields
}

PhysicalHashJoin represents hash join implementation of LogicalJoin.

func NewPhysicalHashJoin

func NewPhysicalHashJoin(p *LogicalJoin, innerIdx int, useOuterToBuild bool, newStats *property.StatsInfo, prop ...*property.PhysicalProperty) *PhysicalHashJoin

NewPhysicalHashJoin creates a new PhysicalHashJoin from LogicalJoin.

func (*PhysicalHashJoin) Clone

func (p *PhysicalHashJoin) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalHashJoin) ExplainInfo

func (p *PhysicalHashJoin) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalHashJoin) ExplainNormalizedInfo

func (p *PhysicalHashJoin) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalHashJoin) ExtractCorrelatedCols

func (p *PhysicalHashJoin) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalHashJoin) GetCost

func (p *PhysicalHashJoin) GetCost(lCnt, rCnt float64, isMPP bool, costFlag uint64, op *physicalOptimizeOp) float64

GetCost computes cost of hash join operator itself.

func (PhysicalHashJoin) Init

Init initializes PhysicalHashJoin.

func (*PhysicalHashJoin) MemoryUsage

func (p *PhysicalHashJoin) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalHashJoin

func (*PhysicalHashJoin) ResolveIndices

func (p *PhysicalHashJoin) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalHashJoin) ResolveIndicesItself

func (p *PhysicalHashJoin) ResolveIndicesItself() (err error)

ResolveIndicesItself resolve indices for PhyicalPlan itself

func (*PhysicalHashJoin) ToPB

func (p *PhysicalHashJoin) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalIndexHashJoin

type PhysicalIndexHashJoin struct {
	PhysicalIndexJoin
	// KeepOuterOrder indicates whether keeping the output result order as the
	// outer side.
	KeepOuterOrder bool
}

PhysicalIndexHashJoin represents the plan of index look up hash join.

func (*PhysicalIndexHashJoin) ExtractCorrelatedCols

func (p *PhysicalIndexHashJoin) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalIndexHashJoin) GetCost

func (p *PhysicalIndexHashJoin) GetCost(outerCnt, innerCnt, outerCost, innerCost float64, costFlag uint64) float64

GetCost computes the cost of index merge join operator and its children.

func (PhysicalIndexHashJoin) Init

Init initializes PhysicalIndexHashJoin.

func (*PhysicalIndexHashJoin) MemoryUsage

func (p *PhysicalIndexHashJoin) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalIndexHashJoin

type PhysicalIndexJoin

type PhysicalIndexJoin struct {

	// Ranges stores the IndexRanges when the inner plan is index scan.
	Ranges ranger.MutableRanges
	// KeyOff2IdxOff maps the offsets in join key to the offsets in the index.
	KeyOff2IdxOff []int
	// IdxColLens stores the length of each index column.
	IdxColLens []int
	// CompareFilters stores the filters for last column if those filters need to be evaluated during execution.
	// e.g. select * from t, t1 where t.a = t1.a and t.b > t1.b and t.b < t1.b+10
	//      If there's index(t.a, t.b). All the filters can be used to construct index range but t.b > t1.b and t.b < t1.b+10
	//      need to be evaluated after we fetch the data of t1.
	// This struct stores them and evaluate them to ranges.
	CompareFilters *ColWithCmpFuncManager
	// OuterHashKeys indicates the outer keys used to build hash table during
	// execution. OuterJoinKeys is the prefix of OuterHashKeys.
	OuterHashKeys []*expression.Column
	// InnerHashKeys indicates the inner keys used to build hash table during
	// execution. InnerJoinKeys is the prefix of InnerHashKeys.
	InnerHashKeys []*expression.Column
	// contains filtered or unexported fields
}

PhysicalIndexJoin represents the plan of index look up join.

func (*PhysicalIndexJoin) ExplainInfo

func (p *PhysicalIndexJoin) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalIndexJoin) ExplainNormalizedInfo

func (p *PhysicalIndexJoin) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalIndexJoin) ExtractCorrelatedCols

func (p *PhysicalIndexJoin) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalIndexJoin) GetCost

func (p *PhysicalIndexJoin) GetCost(outerCnt, innerCnt, outerCost, innerCost float64, costFlag uint64) float64

GetCost computes the cost of index join operator and its children.

func (PhysicalIndexJoin) Init

Init initializes PhysicalIndexJoin.

func (*PhysicalIndexJoin) MemoryUsage

func (p *PhysicalIndexJoin) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalIndexJoin

func (*PhysicalIndexJoin) ResolveIndices

func (p *PhysicalIndexJoin) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

type PhysicalIndexLookUpReader

type PhysicalIndexLookUpReader struct {

	// IndexPlans flats the indexPlan to construct executor pb.
	IndexPlans []PhysicalPlan
	// TablePlans flats the tablePlan to construct executor pb.
	TablePlans []PhysicalPlan

	Paging bool

	ExtraHandleCol *expression.Column
	// PushedLimit is used to avoid unnecessary table scan tasks of IndexLookUpReader.
	PushedLimit *PushedDownLimit

	CommonHandleCols []*expression.Column

	// Used by partition table.
	PartitionInfo PartitionInfo
	// contains filtered or unexported fields
}

PhysicalIndexLookUpReader is the index look up reader in tidb. It's used in case of double reading.

func (*PhysicalIndexLookUpReader) Clone

Clone implements PhysicalPlan interface.

func (*PhysicalIndexLookUpReader) ExplainInfo

func (p *PhysicalIndexLookUpReader) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalIndexLookUpReader) ExtractCorrelatedCols

func (p *PhysicalIndexLookUpReader) ExtractCorrelatedCols() (corCols []*expression.CorrelatedColumn)

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalIndexLookUpReader) GetAvgTableRowSize

func (p *PhysicalIndexLookUpReader) GetAvgTableRowSize() float64

GetAvgTableRowSize return the average row size of each final row.

func (*PhysicalIndexLookUpReader) GetCost

func (p *PhysicalIndexLookUpReader) GetCost(costFlag uint64) (cost float64)

GetCost computes cost of index lookup operator itself.

func (*PhysicalIndexLookUpReader) GetIndexNetDataSize

func (p *PhysicalIndexLookUpReader) GetIndexNetDataSize() float64

GetIndexNetDataSize return the estimated total size in bytes via network transfer.

func (PhysicalIndexLookUpReader) Init

Init initializes PhysicalIndexLookUpReader.

func (*PhysicalIndexLookUpReader) MemoryUsage

func (p *PhysicalIndexLookUpReader) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalIndexLookUpReader

func (*PhysicalIndexLookUpReader) ResolveIndices

func (p *PhysicalIndexLookUpReader) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalIndexLookUpReader) Schema

func (s *PhysicalIndexLookUpReader) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalIndexLookUpReader) SetSchema

func (s *PhysicalIndexLookUpReader) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalIndexMergeJoin

type PhysicalIndexMergeJoin struct {
	PhysicalIndexJoin

	// KeyOff2KeyOffOrderByIdx maps the offsets in join keys to the offsets in join keys order by index.
	KeyOff2KeyOffOrderByIdx []int
	// CompareFuncs store the compare functions for outer join keys and inner join key.
	CompareFuncs []expression.CompareFunc
	// OuterCompareFuncs store the compare functions for outer join keys and outer join
	// keys, it's for outer rows sort's convenience.
	OuterCompareFuncs []expression.CompareFunc
	// NeedOuterSort means whether outer rows should be sorted to build range.
	NeedOuterSort bool
	// Desc means whether inner child keep desc order.
	Desc bool
}

PhysicalIndexMergeJoin represents the plan of index look up merge join.

func (*PhysicalIndexMergeJoin) ExplainInfo

func (p *PhysicalIndexMergeJoin) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalIndexMergeJoin) ExplainNormalizedInfo

func (p *PhysicalIndexMergeJoin) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalIndexMergeJoin) ExtractCorrelatedCols

func (p *PhysicalIndexMergeJoin) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalIndexMergeJoin) GetCost

func (p *PhysicalIndexMergeJoin) GetCost(outerCnt, innerCnt, outerCost, innerCost float64, costFlag uint64) float64

GetCost computes the cost of index merge join operator and its children.

func (PhysicalIndexMergeJoin) Init

Init initializes PhysicalIndexMergeJoin.

func (*PhysicalIndexMergeJoin) MemoryUsage

func (p *PhysicalIndexMergeJoin) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalIndexMergeJoin

type PhysicalIndexMergeReader

type PhysicalIndexMergeReader struct {

	// IsIntersectionType means whether it's intersection type or union type.
	// Intersection type is for expressions connected by `AND` and union type is for `OR`.
	IsIntersectionType bool
	// AccessMVIndex indicates whether this IndexMergeReader access a MVIndex.
	AccessMVIndex bool

	// PartialPlans flats the partialPlans to construct executor pb.
	PartialPlans [][]PhysicalPlan
	// TablePlans flats the tablePlan to construct executor pb.
	TablePlans []PhysicalPlan

	// Used by partition table.
	PartitionInfo PartitionInfo
	// contains filtered or unexported fields
}

PhysicalIndexMergeReader is the reader using multiple indexes in tidb.

func (*PhysicalIndexMergeReader) ExplainInfo

func (p *PhysicalIndexMergeReader) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalIndexMergeReader) ExtractCorrelatedCols

func (p *PhysicalIndexMergeReader) ExtractCorrelatedCols() (corCols []*expression.CorrelatedColumn)

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalIndexMergeReader) GetAvgTableRowSize

func (p *PhysicalIndexMergeReader) GetAvgTableRowSize() float64

GetAvgTableRowSize return the average row size of table plan.

func (*PhysicalIndexMergeReader) GetPartialReaderNetDataSize

func (p *PhysicalIndexMergeReader) GetPartialReaderNetDataSize(plan PhysicalPlan) float64

GetPartialReaderNetDataSize returns the estimated total response data size of a partial read.

func (PhysicalIndexMergeReader) Init

Init initializes PhysicalIndexMergeReader.

func (*PhysicalIndexMergeReader) MemoryUsage

func (p *PhysicalIndexMergeReader) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalIndexMergeReader

func (*PhysicalIndexMergeReader) ResolveIndices

func (p *PhysicalIndexMergeReader) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalIndexMergeReader) Schema

func (s *PhysicalIndexMergeReader) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalIndexMergeReader) SetSchema

func (s *PhysicalIndexMergeReader) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalIndexReader

type PhysicalIndexReader struct {

	// IndexPlans flats the indexPlan to construct executor pb.
	IndexPlans []PhysicalPlan

	// OutputColumns represents the columns that index reader should return.
	OutputColumns []*expression.Column

	// Used by partition table.
	PartitionInfo PartitionInfo
	// contains filtered or unexported fields
}

PhysicalIndexReader is the index reader in tidb.

func (*PhysicalIndexReader) Clone

func (p *PhysicalIndexReader) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalIndexReader) ExplainInfo

func (p *PhysicalIndexReader) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalIndexReader) ExplainNormalizedInfo

func (p *PhysicalIndexReader) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalIndexReader) ExtractCorrelatedCols

func (p *PhysicalIndexReader) ExtractCorrelatedCols() (corCols []*expression.CorrelatedColumn)

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalIndexReader) GetNetDataSize

func (p *PhysicalIndexReader) GetNetDataSize() float64

GetNetDataSize calculates the cost of the plan in network data transfer.

func (PhysicalIndexReader) Init

Init initializes PhysicalIndexReader.

func (*PhysicalIndexReader) MemoryUsage

func (p *PhysicalIndexReader) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalIndexReader

func (*PhysicalIndexReader) ResolveIndices

func (p *PhysicalIndexReader) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalIndexReader) Schema

func (s *PhysicalIndexReader) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalIndexReader) SetChildren

func (p *PhysicalIndexReader) SetChildren(children ...PhysicalPlan)

SetChildren overrides PhysicalPlan SetChildren interface.

func (*PhysicalIndexReader) SetSchema

func (p *PhysicalIndexReader) SetSchema(_ *expression.Schema)

SetSchema overrides PhysicalPlan SetSchema interface.

type PhysicalIndexScan

type PhysicalIndexScan struct {

	// AccessCondition is used to calculate range.
	AccessCondition []expression.Expression

	Table      *model.TableInfo
	Index      *model.IndexInfo
	IdxCols    []*expression.Column
	IdxColLens []int
	Ranges     []*ranger.Range
	Columns    []*model.ColumnInfo
	DBName     model.CIStr

	TableAsName *model.CIStr

	// Hist is the histogram when the query was issued.
	// It is used for query feedback.
	Hist *statistics.Histogram

	GenExprs map[model.TableItemID]expression.Expression

	Desc      bool
	KeepOrder bool
	// DoubleRead means if the index executor will read kv two times.
	// If the query requires the columns that don't belong to index, DoubleRead will be true.
	DoubleRead bool

	NeedCommonHandle bool
	// contains filtered or unexported fields
}

PhysicalIndexScan represents an index scan plan.

func (*PhysicalIndexScan) AccessObject

func (p *PhysicalIndexScan) AccessObject() AccessObject

AccessObject implements dataAccesser interface.

func (*PhysicalIndexScan) Clone

func (p *PhysicalIndexScan) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalIndexScan) ExplainID

func (p *PhysicalIndexScan) ExplainID() fmt.Stringer

ExplainID overrides the ExplainID in order to match different range.

func (*PhysicalIndexScan) ExplainInfo

func (p *PhysicalIndexScan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalIndexScan) ExplainNormalizedInfo

func (p *PhysicalIndexScan) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalIndexScan) ExtractCorrelatedCols

func (p *PhysicalIndexScan) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (PhysicalIndexScan) Init

Init initializes PhysicalIndexScan.

func (*PhysicalIndexScan) IsPartition

func (p *PhysicalIndexScan) IsPartition() (bool, int64)

IsPartition returns true and partition ID if it works on a partition.

func (*PhysicalIndexScan) IsPointGetByUniqueKey

func (p *PhysicalIndexScan) IsPointGetByUniqueKey(sctx sessionctx.Context) bool

IsPointGetByUniqueKey checks whether is a point get by unique key.

func (*PhysicalIndexScan) MemoryUsage

func (p *PhysicalIndexScan) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalIndexScan

func (*PhysicalIndexScan) OperatorInfo

func (p *PhysicalIndexScan) OperatorInfo(normalized bool) string

OperatorInfo implements dataAccesser interface.

func (*PhysicalIndexScan) ResolveIndices

func (p *PhysicalIndexScan) ResolveIndices() (err error)

func (*PhysicalIndexScan) Schema

func (s *PhysicalIndexScan) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalIndexScan) SetSchema

func (s *PhysicalIndexScan) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*PhysicalIndexScan) TP

func (p *PhysicalIndexScan) TP() string

TP overrides the TP in order to match different range.

func (*PhysicalIndexScan) ToPB

func (p *PhysicalIndexScan) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalLimit

type PhysicalLimit struct {
	Offset uint64
	Count  uint64
	// contains filtered or unexported fields
}

PhysicalLimit is the physical operator of Limit.

func (*PhysicalLimit) Clone

func (p *PhysicalLimit) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalLimit) ExplainInfo

func (p *PhysicalLimit) ExplainInfo() string

ExplainInfo implements Plan interface.

func (PhysicalLimit) Init

Init initializes PhysicalLimit.

func (*PhysicalLimit) MemoryUsage

func (p *PhysicalLimit) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalLimit

func (*PhysicalLimit) ResolveIndices

func (p *PhysicalLimit) ResolveIndices() (err error)

func (*PhysicalLimit) Schema

func (s *PhysicalLimit) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalLimit) SetSchema

func (s *PhysicalLimit) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*PhysicalLimit) ToPB

func (p *PhysicalLimit) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalLock

type PhysicalLock struct {
	Lock *ast.SelectLockInfo

	TblID2Handle       map[int64][]HandleCols
	TblID2PhysTblIDCol map[int64]*expression.Column
	// contains filtered or unexported fields
}

PhysicalLock is the physical operator of lock, which is used for `select ... for update` clause.

func (*PhysicalLock) Children

func (p *PhysicalLock) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalLock) Clone

func (p *PhysicalLock) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalLock) ExplainInfo

func (p *PhysicalLock) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalLock) ExplainNormalizedInfo

func (*PhysicalLock) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*PhysicalLock) ExtractCorrelatedCols

func (*PhysicalLock) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalLock) GetChildReqProps

func (p *PhysicalLock) GetChildReqProps(idx int) *property.PhysicalProperty

func (PhysicalLock) Init

Init initializes PhysicalLock.

func (*PhysicalLock) MemoryUsage

func (pl *PhysicalLock) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalLock

func (*PhysicalLock) ResolveIndices

func (p *PhysicalLock) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalLock) Schema

func (p *PhysicalLock) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalLock) SetChild

func (p *PhysicalLock) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalLock) SetChildren

func (p *PhysicalLock) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalLock) StatsCount

func (p *PhysicalLock) StatsCount() float64

func (*PhysicalLock) ToPB

func (p *PhysicalLock) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalMaxOneRow

type PhysicalMaxOneRow struct {
	// contains filtered or unexported fields
}

PhysicalMaxOneRow is the physical operator of maxOneRow.

func (*PhysicalMaxOneRow) Children

func (p *PhysicalMaxOneRow) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalMaxOneRow) Clone

func (p *PhysicalMaxOneRow) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalMaxOneRow) ExplainInfo

func (*PhysicalMaxOneRow) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalMaxOneRow) ExplainNormalizedInfo

func (*PhysicalMaxOneRow) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*PhysicalMaxOneRow) ExtractCorrelatedCols

func (*PhysicalMaxOneRow) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalMaxOneRow) GetChildReqProps

func (p *PhysicalMaxOneRow) GetChildReqProps(idx int) *property.PhysicalProperty

func (PhysicalMaxOneRow) Init

Init initializes PhysicalMaxOneRow.

func (*PhysicalMaxOneRow) MemoryUsage

func (p *PhysicalMaxOneRow) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalMaxOneRow

func (*PhysicalMaxOneRow) ResolveIndices

func (p *PhysicalMaxOneRow) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalMaxOneRow) Schema

func (p *PhysicalMaxOneRow) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalMaxOneRow) SetChild

func (p *PhysicalMaxOneRow) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalMaxOneRow) SetChildren

func (p *PhysicalMaxOneRow) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalMaxOneRow) StatsCount

func (p *PhysicalMaxOneRow) StatsCount() float64

func (*PhysicalMaxOneRow) ToPB

func (p *PhysicalMaxOneRow) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalMemTable

type PhysicalMemTable struct {
	DBName         model.CIStr
	Table          *model.TableInfo
	Columns        []*model.ColumnInfo
	Extractor      MemTablePredicateExtractor
	QueryTimeRange QueryTimeRange
	// contains filtered or unexported fields
}

PhysicalMemTable reads memory table.

func (*PhysicalMemTable) AccessObject

func (p *PhysicalMemTable) AccessObject() AccessObject

AccessObject implements dataAccesser interface.

func (*PhysicalMemTable) ExplainInfo

func (p *PhysicalMemTable) ExplainInfo() string

ExplainInfo implements Plan interface.

func (PhysicalMemTable) Init

Init initializes PhysicalMemTable.

func (*PhysicalMemTable) MemoryUsage

func (p *PhysicalMemTable) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalMemTable

func (*PhysicalMemTable) OperatorInfo

func (p *PhysicalMemTable) OperatorInfo(_ bool) string

OperatorInfo implements dataAccesser interface.

func (*PhysicalMemTable) ResolveIndices

func (p *PhysicalMemTable) ResolveIndices() (err error)

func (*PhysicalMemTable) Schema

func (s *PhysicalMemTable) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalMemTable) SetSchema

func (s *PhysicalMemTable) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalMergeJoin

type PhysicalMergeJoin struct {
	CompareFuncs []expression.CompareFunc
	// Desc means whether inner child keep desc order.
	Desc bool
	// contains filtered or unexported fields
}

PhysicalMergeJoin represents merge join implementation of LogicalJoin.

func BuildMergeJoinPlan

func BuildMergeJoinPlan(ctx sessionctx.Context, joinType JoinType, leftKeys, rightKeys []*expression.Column) *PhysicalMergeJoin

BuildMergeJoinPlan builds a PhysicalMergeJoin from the given fields. Currently, it is only used for test purpose.

func (*PhysicalMergeJoin) Clone

func (p *PhysicalMergeJoin) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalMergeJoin) ExplainInfo

func (p *PhysicalMergeJoin) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalMergeJoin) ExplainNormalizedInfo

func (p *PhysicalMergeJoin) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalMergeJoin) ExtractCorrelatedCols

func (p *PhysicalMergeJoin) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalMergeJoin) GetCost

func (p *PhysicalMergeJoin) GetCost(lCnt, rCnt float64, costFlag uint64) float64

GetCost computes cost of merge join operator itself.

func (PhysicalMergeJoin) Init

Init initializes PhysicalMergeJoin.

func (*PhysicalMergeJoin) MemoryUsage

func (p *PhysicalMergeJoin) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalMergeJoin

func (*PhysicalMergeJoin) ResolveIndices

func (p *PhysicalMergeJoin) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

type PhysicalPlan

type PhysicalPlan interface {
	Plan

	// ToPB converts physical plan to tipb executor.
	ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

	// GetChildReqProps gets the required property by child index.
	GetChildReqProps(idx int) *property.PhysicalProperty

	// StatsCount returns the count of property.StatsInfo for this plan.
	StatsCount() float64

	// ExtractCorrelatedCols extracts correlated columns inside the PhysicalPlan.
	ExtractCorrelatedCols() []*expression.CorrelatedColumn

	// Children get all the children.
	Children() []PhysicalPlan

	// SetChildren sets the children for the plan.
	SetChildren(...PhysicalPlan)

	// SetChild sets the ith child for the plan.
	SetChild(i int, child PhysicalPlan)

	// ResolveIndices resolves the indices for columns. After doing this, the columns can evaluate the rows by their indices.
	ResolveIndices() error

	// Stats returns the StatsInfo of the plan.
	Stats() *property.StatsInfo

	// ExplainNormalizedInfo returns operator normalized information for generating digest.
	ExplainNormalizedInfo() string

	// Clone clones this physical plan.
	Clone() (PhysicalPlan, error)

	// MemoryUsage return the memory usage of PhysicalPlan
	MemoryUsage() int64
	// contains filtered or unexported methods
}

PhysicalPlan is a tree of the physical operators.

func DoOptimize

func DoOptimize(ctx context.Context, sctx sessionctx.Context, flag uint64, logic LogicalPlan) (PhysicalPlan, float64, error)

DoOptimize optimizes a logical plan to a physical plan.

func InjectExtraProjection

func InjectExtraProjection(plan PhysicalPlan) PhysicalPlan

InjectExtraProjection is used to extract the expressions of specific operators into a physical Projection operator and inject the Projection below the operators. Thus we can accelerate the expression evaluation by eager evaluation. This function will be called in two situations: 1. In postOptimize. 2. TiDB can be used as a coprocessor, when a plan tree been pushed down to TiDB, we need to inject extra projections for the plan tree as well.

func InjectProjBelowAgg

func InjectProjBelowAgg(aggPlan PhysicalPlan, aggFuncs []*aggregation.AggFuncDesc, groupByItems []expression.Expression) PhysicalPlan

InjectProjBelowAgg injects a ProjOperator below AggOperator. So that All scalar functions in aggregation may speed up by vectorized evaluation in the `proj`. If all the args of `aggFuncs`, and all the item of `groupByItems` are columns or constants, we do not need to build the `proj`.

func InjectProjBelowSort

func InjectProjBelowSort(p PhysicalPlan, orderByItems []*util.ByItems) PhysicalPlan

InjectProjBelowSort extracts the ScalarFunctions of `orderByItems` into a PhysicalProjection and injects it below PhysicalTopN/PhysicalSort. The schema of PhysicalSort and PhysicalTopN are the same as the schema of their children. When a projection is injected as the child of PhysicalSort and PhysicalTopN, some extra columns will be added into the schema of the Projection, thus we need to add another Projection upon them to prune the redundant columns.

func SafeClone

func SafeClone(v PhysicalPlan) (_ PhysicalPlan, err error)

SafeClone clones this PhysicalPlan and handles its panic.

func TurnNominalSortIntoProj

func TurnNominalSortIntoProj(p PhysicalPlan, onlyColumn bool, orderByItems []*util.ByItems) PhysicalPlan

TurnNominalSortIntoProj will turn nominal sort into two projections. This is to check if the scalar functions will overflow.

type PhysicalProjection

type PhysicalProjection struct {
	Exprs                []expression.Expression
	CalculateNoDelay     bool
	AvoidColumnEvaluator bool
	// contains filtered or unexported fields
}

PhysicalProjection is the physical operator of projection.

func (*PhysicalProjection) Clone

func (p *PhysicalProjection) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalProjection) ExplainInfo

func (p *PhysicalProjection) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalProjection) ExplainNormalizedInfo

func (p *PhysicalProjection) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalProjection) ExtractCorrelatedCols

func (p *PhysicalProjection) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalProjection) GetCost

func (p *PhysicalProjection) GetCost(count float64) float64

GetCost computes the cost of projection operator itself.

func (PhysicalProjection) Init

Init initializes PhysicalProjection.

func (*PhysicalProjection) MemoryUsage

func (p *PhysicalProjection) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalProjection

func (*PhysicalProjection) ResolveIndices

func (p *PhysicalProjection) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalProjection) ResolveIndicesItself

func (p *PhysicalProjection) ResolveIndicesItself() (err error)

ResolveIndicesItself resolve indices for PhysicalPlan itself

func (*PhysicalProjection) Schema

func (s *PhysicalProjection) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalProjection) SetSchema

func (s *PhysicalProjection) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*PhysicalProjection) ToPB

func (p *PhysicalProjection) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalSelection

type PhysicalSelection struct {
	Conditions []expression.Expression
	// contains filtered or unexported fields
}

PhysicalSelection represents a filter.

func (*PhysicalSelection) Children

func (p *PhysicalSelection) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalSelection) Clone

func (p *PhysicalSelection) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalSelection) ExplainInfo

func (p *PhysicalSelection) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalSelection) ExplainNormalizedInfo

func (p *PhysicalSelection) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalSelection) ExtractCorrelatedCols

func (p *PhysicalSelection) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalSelection) GetChildReqProps

func (p *PhysicalSelection) GetChildReqProps(idx int) *property.PhysicalProperty

func (PhysicalSelection) Init

Init initializes PhysicalSelection.

func (*PhysicalSelection) MemoryUsage

func (p *PhysicalSelection) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalSelection

func (*PhysicalSelection) ResolveIndices

func (p *PhysicalSelection) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalSelection) Schema

func (p *PhysicalSelection) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalSelection) SetChild

func (p *PhysicalSelection) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalSelection) SetChildren

func (p *PhysicalSelection) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalSelection) StatsCount

func (p *PhysicalSelection) StatsCount() float64

func (*PhysicalSelection) ToPB

func (p *PhysicalSelection) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalShow

type PhysicalShow struct {
	ShowContents

	Extractor ShowPredicateExtractor
	// contains filtered or unexported fields
}

PhysicalShow represents a show plan.

func (PhysicalShow) Init

Init initializes PhysicalShow.

func (*PhysicalShow) MemoryUsage

func (p *PhysicalShow) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalShow

func (*PhysicalShow) ResolveIndices

func (p *PhysicalShow) ResolveIndices() (err error)

func (*PhysicalShow) Schema

func (s *PhysicalShow) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalShow) SetSchema

func (s *PhysicalShow) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalShowDDLJobs

type PhysicalShowDDLJobs struct {
	JobNumber int64
	// contains filtered or unexported fields
}

PhysicalShowDDLJobs is for showing DDL job list.

func (PhysicalShowDDLJobs) Init

Init initializes PhysicalShowDDLJobs.

func (*PhysicalShowDDLJobs) MemoryUsage

func (p *PhysicalShowDDLJobs) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalShowDDLJobs

func (*PhysicalShowDDLJobs) ResolveIndices

func (p *PhysicalShowDDLJobs) ResolveIndices() (err error)

func (*PhysicalShowDDLJobs) Schema

func (s *PhysicalShowDDLJobs) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalShowDDLJobs) SetSchema

func (s *PhysicalShowDDLJobs) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalShuffle

type PhysicalShuffle struct {
	Concurrency int
	Tails       []PhysicalPlan
	DataSources []PhysicalPlan

	SplitterType PartitionSplitterType
	ByItemArrays [][]expression.Expression
	// contains filtered or unexported fields
}

PhysicalShuffle represents a shuffle plan. `Tails` and `DataSources` are the last plan within and the first plan following the "shuffle", respectively,

to build the child executors chain.

Take `Window` operator for example:

Shuffle -> Window -> Sort -> DataSource, will be separated into:
  ==> Shuffle: for main thread
  ==> Window -> Sort(:Tail) -> shuffleWorker: for workers
  ==> DataSource: for `fetchDataAndSplit` thread

func (*PhysicalShuffle) Children

func (p *PhysicalShuffle) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalShuffle) Clone

func (p *PhysicalShuffle) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalShuffle) ExplainInfo

func (p *PhysicalShuffle) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalShuffle) ExplainNormalizedInfo

func (*PhysicalShuffle) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*PhysicalShuffle) ExtractCorrelatedCols

func (*PhysicalShuffle) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalShuffle) GetChildReqProps

func (p *PhysicalShuffle) GetChildReqProps(idx int) *property.PhysicalProperty

func (PhysicalShuffle) Init

Init initializes PhysicalShuffle.

func (*PhysicalShuffle) MemoryUsage

func (p *PhysicalShuffle) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalShuffle

func (*PhysicalShuffle) ResolveIndices

func (p *PhysicalShuffle) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalShuffle) Schema

func (p *PhysicalShuffle) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalShuffle) SetChild

func (p *PhysicalShuffle) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalShuffle) SetChildren

func (p *PhysicalShuffle) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalShuffle) StatsCount

func (p *PhysicalShuffle) StatsCount() float64

func (*PhysicalShuffle) ToPB

func (p *PhysicalShuffle) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalShuffleReceiverStub

type PhysicalShuffleReceiverStub struct {

	// Receiver points to `executor.shuffleReceiver`.
	Receiver unsafe.Pointer
	// DataSource is the PhysicalPlan of the Receiver.
	DataSource PhysicalPlan
	// contains filtered or unexported fields
}

PhysicalShuffleReceiverStub represents a receiver stub of `PhysicalShuffle`, and actually, is executed by `executor.shuffleWorker`.

func (PhysicalShuffleReceiverStub) Init

Init initializes PhysicalShuffleReceiverStub.

func (*PhysicalShuffleReceiverStub) MemoryUsage

func (p *PhysicalShuffleReceiverStub) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalShuffleReceiverStub

func (*PhysicalShuffleReceiverStub) ResolveIndices

func (p *PhysicalShuffleReceiverStub) ResolveIndices() (err error)

func (*PhysicalShuffleReceiverStub) Schema

func (s *PhysicalShuffleReceiverStub) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalShuffleReceiverStub) SetSchema

func (s *PhysicalShuffleReceiverStub) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalSimpleWrapper

type PhysicalSimpleWrapper struct {
	Inner Simple
	// contains filtered or unexported fields
}

PhysicalSimpleWrapper is a wrapper of `Simple` to implement physical plan interface.

Used for simple statements executing in coprocessor.

func (*PhysicalSimpleWrapper) Children

func (p *PhysicalSimpleWrapper) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalSimpleWrapper) Clone

func (p *PhysicalSimpleWrapper) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalSimpleWrapper) ExplainInfo

func (*PhysicalSimpleWrapper) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalSimpleWrapper) ExplainNormalizedInfo

func (*PhysicalSimpleWrapper) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*PhysicalSimpleWrapper) ExtractCorrelatedCols

func (*PhysicalSimpleWrapper) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalSimpleWrapper) GetChildReqProps

func (p *PhysicalSimpleWrapper) GetChildReqProps(idx int) *property.PhysicalProperty

func (*PhysicalSimpleWrapper) MemoryUsage

func (p *PhysicalSimpleWrapper) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalSimpleWrapper

func (*PhysicalSimpleWrapper) ResolveIndices

func (p *PhysicalSimpleWrapper) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalSimpleWrapper) Schema

func (p *PhysicalSimpleWrapper) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalSimpleWrapper) SetChild

func (p *PhysicalSimpleWrapper) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalSimpleWrapper) SetChildren

func (p *PhysicalSimpleWrapper) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalSimpleWrapper) StatsCount

func (p *PhysicalSimpleWrapper) StatsCount() float64

func (*PhysicalSimpleWrapper) ToPB

func (p *PhysicalSimpleWrapper) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalSort

type PhysicalSort struct {
	ByItems []*util.ByItems
	// whether this operator only need to sort the data of one partition.
	// it is true only if it is used to sort the sharded data of the window function.
	IsPartialSort bool
	// contains filtered or unexported fields
}

PhysicalSort is the physical operator of sort, which implements a memory sort.

func (*PhysicalSort) Children

func (p *PhysicalSort) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalSort) Clone

func (ls *PhysicalSort) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalSort) ExplainInfo

func (p *PhysicalSort) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalSort) ExplainNormalizedInfo

func (*PhysicalSort) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*PhysicalSort) ExtractCorrelatedCols

func (ls *PhysicalSort) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalSort) GetChildReqProps

func (p *PhysicalSort) GetChildReqProps(idx int) *property.PhysicalProperty

func (*PhysicalSort) GetCost

func (p *PhysicalSort) GetCost(count float64, schema *expression.Schema) float64

GetCost computes the cost of in memory sort.

func (PhysicalSort) Init

func (p PhysicalSort) Init(ctx sessionctx.Context, stats *property.StatsInfo, offset int, props ...*property.PhysicalProperty) *PhysicalSort

Init initializes PhysicalSort.

func (*PhysicalSort) MemoryUsage

func (ls *PhysicalSort) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalSort

func (*PhysicalSort) ResolveIndices

func (p *PhysicalSort) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalSort) Schema

func (p *PhysicalSort) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalSort) SetChild

func (p *PhysicalSort) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalSort) SetChildren

func (p *PhysicalSort) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalSort) StatsCount

func (p *PhysicalSort) StatsCount() float64

func (*PhysicalSort) ToPB

func (p *PhysicalSort) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalStreamAgg

type PhysicalStreamAgg struct {
	// contains filtered or unexported fields
}

PhysicalStreamAgg is stream operator of aggregate.

func (*PhysicalStreamAgg) Clone

func (p *PhysicalStreamAgg) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalStreamAgg) ExplainInfo

func (p *PhysicalStreamAgg) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalStreamAgg) ExplainNormalizedInfo

func (p *PhysicalStreamAgg) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalStreamAgg) ExtractCorrelatedCols

func (p *PhysicalStreamAgg) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalStreamAgg) GetCost

func (p *PhysicalStreamAgg) GetCost(inputRows float64, isRoot, isMPP bool, costFlag uint64) float64

GetCost computes cost of stream aggregation considering CPU/memory.

func (PhysicalStreamAgg) Init

func (base PhysicalStreamAgg) Init(ctx sessionctx.Context, stats *property.StatsInfo, offset int) *basePhysicalAgg

Init initializes basePhysicalAgg.

func (*PhysicalStreamAgg) IsFinalAgg

func (p *PhysicalStreamAgg) IsFinalAgg() bool

func (*PhysicalStreamAgg) MemoryUsage

func (p *PhysicalStreamAgg) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalStreamAgg

func (*PhysicalStreamAgg) ResolveIndices

func (p *PhysicalStreamAgg) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalStreamAgg) ToPB

func (p *PhysicalStreamAgg) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalTableDual

type PhysicalTableDual struct {
	RowCount int
	// contains filtered or unexported fields
}

PhysicalTableDual is the physical operator of dual.

func (*PhysicalTableDual) ExplainInfo

func (p *PhysicalTableDual) ExplainInfo() string

ExplainInfo implements Plan interface.

func (PhysicalTableDual) Init

Init initializes PhysicalTableDual.

func (*PhysicalTableDual) MemoryUsage

func (p *PhysicalTableDual) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalTableDual

func (*PhysicalTableDual) OutputNames

func (p *PhysicalTableDual) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*PhysicalTableDual) ResolveIndices

func (p *PhysicalTableDual) ResolveIndices() (err error)

func (*PhysicalTableDual) Schema

func (s *PhysicalTableDual) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalTableDual) SetOutputNames

func (p *PhysicalTableDual) SetOutputNames(names types.NameSlice)

SetOutputNames sets the outputting name by the given slice.

func (*PhysicalTableDual) SetSchema

func (s *PhysicalTableDual) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalTableReader

type PhysicalTableReader struct {

	// TablePlans flats the tablePlan to construct executor pb.
	TablePlans []PhysicalPlan

	// StoreType indicates table read from which type of store.
	StoreType kv.StoreType

	// ReadReqType is the read request type for current physical table reader, there are 3 kinds of read request: Cop,
	// BatchCop and MPP, currently, the latter two are only used in TiFlash
	ReadReqType ReadReqType

	IsCommonHandle bool

	// Used by partition table.
	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
	// contains filtered or unexported fields
}

PhysicalTableReader is the table reader in tidb.

func (*PhysicalTableReader) Clone

func (p *PhysicalTableReader) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalTableReader) ExplainInfo

func (p *PhysicalTableReader) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalTableReader) ExplainNormalizedInfo

func (*PhysicalTableReader) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalTableReader) ExtractCorrelatedCols

func (p *PhysicalTableReader) ExtractCorrelatedCols() (corCols []*expression.CorrelatedColumn)

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalTableReader) GetAvgRowSize

func (p *PhysicalTableReader) GetAvgRowSize() float64

GetAvgRowSize return the average row size of this plan.

func (*PhysicalTableReader) GetNetDataSize

func (p *PhysicalTableReader) GetNetDataSize() float64

GetNetDataSize calculates the estimated total data size fetched from storage.

func (*PhysicalTableReader) GetTablePlan

func (p *PhysicalTableReader) GetTablePlan() PhysicalPlan

GetTablePlan exports the tablePlan.

func (*PhysicalTableReader) GetTableScan

func (p *PhysicalTableReader) GetTableScan() (*PhysicalTableScan, error)

GetTableScan exports the tableScan that contained in tablePlans and return error when the count of table scan != 1.

func (*PhysicalTableReader) GetTableScans

func (p *PhysicalTableReader) GetTableScans() []*PhysicalTableScan

GetTableScans exports the tableScan that contained in tablePlans.

func (PhysicalTableReader) Init

Init initializes PhysicalTableReader.

func (*PhysicalTableReader) MemoryUsage

func (p *PhysicalTableReader) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalTableReader

func (*PhysicalTableReader) OperatorInfo

func (p *PhysicalTableReader) OperatorInfo(_ bool) string

OperatorInfo return other operator information to be explained.

func (*PhysicalTableReader) ResolveIndices

func (p *PhysicalTableReader) ResolveIndices() error

ResolveIndices implements Plan interface.

func (*PhysicalTableReader) Schema

func (s *PhysicalTableReader) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalTableReader) SetChildren

func (p *PhysicalTableReader) SetChildren(children ...PhysicalPlan)

SetChildren overrides PhysicalPlan SetChildren interface.

func (*PhysicalTableReader) SetSchema

func (s *PhysicalTableReader) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalTableSample

type PhysicalTableSample struct {
	TableSampleInfo *TableSampleInfo
	TableInfo       table.Table
	Desc            bool
	// contains filtered or unexported fields
}

PhysicalTableSample represents a table sample plan. It returns the sample rows to its parent operand.

func (PhysicalTableSample) Init

Init initializes PhysicalTableSample.

func (*PhysicalTableSample) MemoryUsage

func (p *PhysicalTableSample) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalTableSample

func (*PhysicalTableSample) ResolveIndices

func (p *PhysicalTableSample) ResolveIndices() (err error)

func (*PhysicalTableSample) Schema

func (s *PhysicalTableSample) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalTableSample) SetSchema

func (s *PhysicalTableSample) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalTableScan

type PhysicalTableScan struct {

	// AccessCondition is used to calculate range.
	AccessCondition []expression.Expression

	Table   *model.TableInfo
	Columns []*model.ColumnInfo
	DBName  model.CIStr
	Ranges  []*ranger.Range

	TableAsName *model.CIStr

	// Hist is the histogram when the query was issued.
	// It is used for query feedback.
	Hist *statistics.Histogram

	// HandleIdx is the index of handle, which is only used for admin check table.
	HandleIdx  []int
	HandleCols HandleCols

	StoreType kv.StoreType

	IsMPPOrBatchCop bool // Used for tiflash PartitionTableScan.

	// KeepOrder is true, if sort data by scanning pkcol,
	KeepOrder bool
	Desc      bool

	PartitionInfo PartitionInfo

	SampleInfo *TableSampleInfo
	// contains filtered or unexported fields
}

PhysicalTableScan represents a table scan plan.

func (*PhysicalTableScan) AccessObject

func (p *PhysicalTableScan) AccessObject() AccessObject

AccessObject implements dataAccesser interface.

func (*PhysicalTableScan) Clone

func (ts *PhysicalTableScan) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalTableScan) ExplainID

func (p *PhysicalTableScan) ExplainID() fmt.Stringer

ExplainID overrides the ExplainID in order to match different range.

func (*PhysicalTableScan) ExplainInfo

func (p *PhysicalTableScan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalTableScan) ExplainNormalizedInfo

func (p *PhysicalTableScan) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalTableScan) ExtractCorrelatedCols

func (ts *PhysicalTableScan) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (PhysicalTableScan) Init

Init initializes PhysicalTableScan.

func (*PhysicalTableScan) IsPartition

func (ts *PhysicalTableScan) IsPartition() (bool, int64)

IsPartition returns true and partition ID if it's actually a partition.

func (*PhysicalTableScan) MemoryUsage

func (ts *PhysicalTableScan) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalTableScan

func (*PhysicalTableScan) OperatorInfo

func (p *PhysicalTableScan) OperatorInfo(normalized bool) string

OperatorInfo implements dataAccesser interface.

func (*PhysicalTableScan) ResolveCorrelatedColumns

func (ts *PhysicalTableScan) ResolveCorrelatedColumns() ([]*ranger.Range, error)

ResolveCorrelatedColumns resolves the correlated columns in range access. We already limit range mem usage when building ranges in optimizer phase, so we don't need and shouldn't limit range mem usage when rebuilding ranges during the execution phase.

func (*PhysicalTableScan) ResolveIndices

func (p *PhysicalTableScan) ResolveIndices() (err error)

func (*PhysicalTableScan) Schema

func (s *PhysicalTableScan) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalTableScan) SetIsChildOfIndexLookUp

func (ts *PhysicalTableScan) SetIsChildOfIndexLookUp(isIsChildOfIndexLookUp bool)

SetIsChildOfIndexLookUp is to set the bool if is a child of IndexLookUpReader

func (*PhysicalTableScan) SetSchema

func (s *PhysicalTableScan) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*PhysicalTableScan) TP

func (p *PhysicalTableScan) TP() string

TP overrides the TP in order to match different range.

func (*PhysicalTableScan) ToPB

func (p *PhysicalTableScan) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalTopN

type PhysicalTopN struct {
	ByItems []*util.ByItems
	Offset  uint64
	Count   uint64
	// contains filtered or unexported fields
}

PhysicalTopN is the physical operator of topN.

func (*PhysicalTopN) Children

func (p *PhysicalTopN) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalTopN) Clone

func (lt *PhysicalTopN) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalTopN) ExplainInfo

func (p *PhysicalTopN) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalTopN) ExplainNormalizedInfo

func (p *PhysicalTopN) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalTopN) ExtractCorrelatedCols

func (lt *PhysicalTopN) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalTopN) GetChildReqProps

func (p *PhysicalTopN) GetChildReqProps(idx int) *property.PhysicalProperty

func (*PhysicalTopN) GetCost

func (p *PhysicalTopN) GetCost(count float64, isRoot bool) float64

GetCost computes cost of TopN operator itself.

func (PhysicalTopN) Init

func (p PhysicalTopN) Init(ctx sessionctx.Context, stats *property.StatsInfo, offset int, props ...*property.PhysicalProperty) *PhysicalTopN

Init initializes PhysicalTopN.

func (*PhysicalTopN) MemoryUsage

func (lt *PhysicalTopN) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalTopN

func (*PhysicalTopN) ResolveIndices

func (p *PhysicalTopN) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalTopN) Schema

func (p *PhysicalTopN) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalTopN) SetChild

func (p *PhysicalTopN) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalTopN) SetChildren

func (p *PhysicalTopN) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalTopN) StatsCount

func (p *PhysicalTopN) StatsCount() float64

func (*PhysicalTopN) ToPB

func (p *PhysicalTopN) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalUnionAll

type PhysicalUnionAll struct {
	// contains filtered or unexported fields
}

PhysicalUnionAll is the physical operator of UnionAll.

func (*PhysicalUnionAll) Clone

func (p *PhysicalUnionAll) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (PhysicalUnionAll) Init

Init initializes PhysicalUnionAll.

func (*PhysicalUnionAll) MemoryUsage

func (p *PhysicalUnionAll) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalUnionAll

func (*PhysicalUnionAll) ResolveIndices

func (p *PhysicalUnionAll) ResolveIndices() (err error)

func (*PhysicalUnionAll) Schema

func (s *PhysicalUnionAll) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalUnionAll) SetSchema

func (s *PhysicalUnionAll) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PhysicalUnionScan

type PhysicalUnionScan struct {
	Conditions []expression.Expression

	HandleCols HandleCols
	// contains filtered or unexported fields
}

PhysicalUnionScan represents a union scan operator.

func (*PhysicalUnionScan) Children

func (p *PhysicalUnionScan) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalUnionScan) Clone

func (p *PhysicalUnionScan) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalUnionScan) ExplainInfo

func (p *PhysicalUnionScan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalUnionScan) ExplainNormalizedInfo

func (*PhysicalUnionScan) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements PhysicalPlan interface.

func (*PhysicalUnionScan) ExtractCorrelatedCols

func (p *PhysicalUnionScan) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PhysicalUnionScan) GetChildReqProps

func (p *PhysicalUnionScan) GetChildReqProps(idx int) *property.PhysicalProperty

func (PhysicalUnionScan) Init

Init initializes PhysicalUnionScan.

func (*PhysicalUnionScan) MemoryUsage

func (p *PhysicalUnionScan) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalUnionScan

func (*PhysicalUnionScan) ResolveIndices

func (p *PhysicalUnionScan) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalUnionScan) Schema

func (p *PhysicalUnionScan) Schema() *expression.Schema

Schema implements Plan Schema interface.

func (*PhysicalUnionScan) SetChild

func (p *PhysicalUnionScan) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalUnionScan) SetChildren

func (p *PhysicalUnionScan) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalUnionScan) StatsCount

func (p *PhysicalUnionScan) StatsCount() float64

func (*PhysicalUnionScan) ToPB

func (p *PhysicalUnionScan) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalWindow

type PhysicalWindow struct {
	WindowFuncDescs []*aggregation.WindowFuncDesc
	PartitionBy     []property.SortItem
	OrderBy         []property.SortItem
	Frame           *WindowFrame
	// contains filtered or unexported fields
}

PhysicalWindow is the physical operator of window function.

func (*PhysicalWindow) Clone

func (p *PhysicalWindow) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PhysicalWindow) ExplainInfo

func (p *PhysicalWindow) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalWindow) ExtractCorrelatedCols

func (p *PhysicalWindow) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (PhysicalWindow) Init

Init initializes PhysicalWindow.

func (*PhysicalWindow) MemoryUsage

func (p *PhysicalWindow) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalWindow

func (*PhysicalWindow) ResolveIndices

func (p *PhysicalWindow) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*PhysicalWindow) Schema

func (s *PhysicalWindow) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PhysicalWindow) SetSchema

func (s *PhysicalWindow) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

func (*PhysicalWindow) ToPB

func (p *PhysicalWindow) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type Plan

type Plan interface {
	// Get the schema.
	Schema() *expression.Schema

	// Get the ID.
	ID() int

	// TP get the plan type.
	TP() string

	// Get the ID in explain statement
	ExplainID() fmt.Stringer

	// ExplainInfo returns operator information to be explained.
	ExplainInfo() string

	SCtx() sessionctx.Context

	// OutputNames returns the outputting names of each column.
	OutputNames() types.NameSlice

	// SetOutputNames sets the outputting name by the given slice.
	SetOutputNames(names types.NameSlice)

	SelectBlockOffset() int
	// contains filtered or unexported methods
}

Plan is the description of an execution flow. It is created from ast.Node first, then optimized by the optimizer, finally used by the executor to create a Cursor which executes the statement.

func BuildLogicalPlanForTest

func BuildLogicalPlanForTest(ctx context.Context, sctx sessionctx.Context, node ast.Node, infoSchema infoschema.InfoSchema) (Plan, types.NameSlice, error)

BuildLogicalPlanForTest builds a logical plan for testing purpose from ast.Node.

func GetPlanFromSessionPlanCache

func GetPlanFromSessionPlanCache(ctx context.Context, sctx sessionctx.Context,
	isNonPrepared bool, is infoschema.InfoSchema, stmt *PlanCacheStmt,
	params []expression.Expression) (plan Plan, names []*types.FieldName, err error)

GetPlanFromSessionPlanCache is the entry point of Plan Cache. It tries to get a valid cached plan from this session's plan cache. If there is no such a plan, it'll call the optimizer to generate a new one. isNonPrepared indicates whether to use the non-prepared plan cache or the prepared plan cache.

func TryFastPlan

func TryFastPlan(ctx sessionctx.Context, node ast.Node) (p Plan)

TryFastPlan tries to use the PointGetPlan for the query.

type PlanBuilder

type PlanBuilder struct {
	// contains filtered or unexported fields
}

PlanBuilder builds Plan from an ast.Node. It just builds the ast node straightforwardly.

func NewPlanBuilder

func NewPlanBuilder(opts ...PlanBuilderOpt) *PlanBuilder

NewPlanBuilder creates a new PlanBuilder.

func (*PlanBuilder) Build

func (b *PlanBuilder) Build(ctx context.Context, node ast.Node) (Plan, error)

Build builds the ast node to a Plan.

func (*PlanBuilder) BuildDataSourceFromView

func (b *PlanBuilder) BuildDataSourceFromView(ctx context.Context, dbName model.CIStr, tableInfo *model.TableInfo, qbNameMap4View map[string][]ast.HintTable, viewHints map[string][]*ast.TableOptimizerHint) (LogicalPlan, error)

BuildDataSourceFromView is used to build LogicalPlan from view qbNameMap4View and viewHints are used for the view's hint. qbNameMap4View maps the query block name to the view table lists. viewHints group the view hints based on the view's query block name.

func (*PlanBuilder) GetIsForUpdateRead

func (b *PlanBuilder) GetIsForUpdateRead() bool

GetIsForUpdateRead gets if the PlanBuilder use forUpdateRead

func (*PlanBuilder) GetOptFlag

func (b *PlanBuilder) GetOptFlag() uint64

GetOptFlag gets the optFlag of the PlanBuilder.

func (*PlanBuilder) GetVisitInfo

func (b *PlanBuilder) GetVisitInfo() []visitInfo

GetVisitInfo gets the visitInfo of the PlanBuilder.

func (*PlanBuilder) Init

Init initialize a PlanBuilder. Return the original PlannerSelectBlockAsName as well, callers decide if PlannerSelectBlockAsName should be restored after using this builder. This is The comman code pattern to use it: NewPlanBuilder().Init(sctx, is, processor)

func (*PlanBuilder) ResetForReuse

func (b *PlanBuilder) ResetForReuse() *PlanBuilder

ResetForReuse reset the plan builder, put it into pool for reuse. After reset for reuse, the object should be equal to a object returned by NewPlanBuilder().

func (*PlanBuilder) TableHints

func (b *PlanBuilder) TableHints() *tableHintInfo

TableHints returns the *tableHintInfo of PlanBuilder.

type PlanBuilderOpt

type PlanBuilderOpt interface {
	Apply(builder *PlanBuilder)
}

PlanBuilderOpt is used to adjust the plan builder.

type PlanBuilderOptAllowCastArray

type PlanBuilderOptAllowCastArray struct{}

PlanBuilderOptAllowCastArray means the plan builder should allow build cast(... as ... array).

func (PlanBuilderOptAllowCastArray) Apply

func (p PlanBuilderOptAllowCastArray) Apply(builder *PlanBuilder)

Apply implements the interface PlanBuilderOpt.

type PlanBuilderOptNoExecution

type PlanBuilderOptNoExecution struct{}

PlanBuilderOptNoExecution means the plan builder should not run any executor during Build().

func (PlanBuilderOptNoExecution) Apply

func (p PlanBuilderOptNoExecution) Apply(builder *PlanBuilder)

Apply implements the interface PlanBuilderOpt.

type PlanCacheStmt

type PlanCacheStmt struct {
	PreparedAst *ast.Prepared
	StmtDB      string // which DB the statement will be processed over
	VisitInfos  []visitInfo
	ColumnInfos interface{}
	// Executor is only used for point get scene.
	// Notice that we should only cache the PointGetExecutor that have a snapshot with MaxTS in it.
	// If the current plan is not PointGet or does not use MaxTS optimization, this value should be nil here.
	Executor interface{}

	StmtCacheable     bool   // Whether this stmt is cacheable.
	UncacheableReason string // Why this stmt is uncacheable.

	NormalizedSQL       string
	NormalizedPlan      string
	SQLDigest           *parser.Digest
	PlanDigest          *parser.Digest
	ForUpdateRead       bool
	SnapshotTSEvaluator func(sessionctx.Context) (uint64, error)
	NormalizedSQL4PC    string
	SQLDigest4PC        string

	// the different between NormalizedSQL, NormalizedSQL4PC and StmtText:
	//  for the query `select * from t where a>1 and b<?`, then
	//  NormalizedSQL: select * from `t` where `a` > ? and `b` < ? --> constants are normalized to '?',
	//  NormalizedSQL4PC: select * from `test` . `t` where `a` > ? and `b` < ? --> schema name is added,
	//  StmtText: select * from t where a>1 and b <? --> just format the original query;
	StmtText string
}

PlanCacheStmt store prepared ast from PrepareExec and other related fields

func GetPreparedStmt

func GetPreparedStmt(stmt *ast.ExecuteStmt, vars *variable.SessionVars) (*PlanCacheStmt, error)

GetPreparedStmt extract the prepared statement from the execute statement.

type PlanCacheValue

type PlanCacheValue struct {
	Plan              Plan
	OutPutNames       []*types.FieldName
	TblInfo2UnionScan map[*model.TableInfo]bool
	// contains filtered or unexported fields
}

PlanCacheValue stores the cached Statement and StmtNode.

func NewPlanCacheValue

func NewPlanCacheValue(plan Plan, names []*types.FieldName, srcMap map[*model.TableInfo]bool,
	paramTypes []*types.FieldType, limitParams []uint64) *PlanCacheValue

NewPlanCacheValue creates a SQLCacheValue.

func (*PlanCacheValue) MemoryUsage

func (v *PlanCacheValue) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PlanCacheValue

type PlanCostOption

type PlanCostOption struct {
	CostFlag uint64
	// contains filtered or unexported fields
}

PlanCostOption indicates option during GetPlanCost

func NewDefaultPlanCostOption

func NewDefaultPlanCostOption() *PlanCostOption

NewDefaultPlanCostOption returns PlanCostOption

func (*PlanCostOption) WithCostFlag

func (op *PlanCostOption) WithCostFlag(flag uint64) *PlanCostOption

WithCostFlag set costflag

func (*PlanCostOption) WithOptimizeTracer

func (op *PlanCostOption) WithOptimizeTracer(tracer *physicalOptimizeOp) *PlanCostOption

WithOptimizeTracer set tracer

type PlanCounterTp

type PlanCounterTp int64

PlanCounterTp is used in hint nth_plan() to indicate which plan to use.

var PlanCounterDisabled PlanCounterTp = -1

PlanCounterDisabled is the default value of PlanCounterTp, indicating that optimizer needn't force a plan.

func (*PlanCounterTp) Dec

func (c *PlanCounterTp) Dec(x int64)

Dec minus PlanCounterTp value by x.

func (*PlanCounterTp) Empty

func (c *PlanCounterTp) Empty() bool

Empty indicates whether the PlanCounterTp is clear now.

func (*PlanCounterTp) IsForce

func (c *PlanCounterTp) IsForce() bool

IsForce indicates whether to force a plan.

type PlanReplayer

type PlanReplayer struct {
	ExecStmt ast.StmtNode
	Analyze  bool
	Load     bool
	File     string

	Capture    bool
	SQLDigest  string
	PlanDigest string
	// contains filtered or unexported fields
}

PlanReplayer represents a plan replayer plan.

func (*PlanReplayer) MemoryUsage

func (s *PlanReplayer) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*PlanReplayer) OutputNames

func (s *PlanReplayer) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*PlanReplayer) ResolveIndices

func (p *PlanReplayer) ResolveIndices() (err error)

func (*PlanReplayer) Schema

func (s *PlanReplayer) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*PlanReplayer) SetOutputNames

func (s *PlanReplayer) SetOutputNames(names types.NameSlice)

func (*PlanReplayer) SetSchema

func (s *PlanReplayer) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PointGetPlan

type PointGetPlan struct {
	TblInfo        *model.TableInfo
	IndexInfo      *model.IndexInfo
	PartitionInfo  *model.PartitionDefinition
	Handle         kv.Handle
	HandleConstant *expression.Constant

	IndexValues      []types.Datum
	IndexConstants   []*expression.Constant
	ColsFieldType    []*types.FieldType
	IdxCols          []*expression.Column
	IdxColLens       []int
	AccessConditions []expression.Expression

	UnsignedHandle bool
	IsTableDual    bool
	Lock           bool

	LockWaitTime int64

	Columns []*model.ColumnInfo
	// contains filtered or unexported fields
}

PointGetPlan is a fast plan for simple point get. When we detect that the statement has a unique equal access condition, this plan is used. This plan is much faster to build and to execute because it avoid the optimization and coprocessor cost.

func (*PointGetPlan) AccessObject

func (p *PointGetPlan) AccessObject() AccessObject

AccessObject implements dataAccesser interface.

func (*PointGetPlan) Children

func (*PointGetPlan) Children() []PhysicalPlan

Children gets all the children.

func (*PointGetPlan) Clone

func (p *PointGetPlan) Clone() (PhysicalPlan, error)

Clone implements PhysicalPlan interface.

func (*PointGetPlan) Cost

func (p *PointGetPlan) Cost() float64

Cost implements PhysicalPlan interface

func (*PointGetPlan) ExplainID

func (p *PointGetPlan) ExplainID() fmt.Stringer

func (*PointGetPlan) ExplainInfo

func (p *PointGetPlan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PointGetPlan) ExplainNormalizedInfo

func (p *PointGetPlan) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PointGetPlan) ExtractCorrelatedCols

func (*PointGetPlan) ExtractCorrelatedCols() []*expression.CorrelatedColumn

ExtractCorrelatedCols implements PhysicalPlan interface.

func (*PointGetPlan) GetAvgRowSize

func (p *PointGetPlan) GetAvgRowSize() float64

GetAvgRowSize return the average row size.

func (*PointGetPlan) GetChildReqProps

func (*PointGetPlan) GetChildReqProps(_ int) *property.PhysicalProperty

GetChildReqProps gets the required property by child index.

func (*PointGetPlan) GetCost

func (p *PointGetPlan) GetCost(opt *physicalOptimizeOp) float64

GetCost returns cost of the PointGetPlan.

func (*PointGetPlan) ID

func (p *PointGetPlan) ID() int

ID implements Plan ID interface.

func (PointGetPlan) Init

Init initializes PointGetPlan.

func (*PointGetPlan) MemoryUsage

func (p *PointGetPlan) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PointGetPlan

func (*PointGetPlan) OperatorInfo

func (p *PointGetPlan) OperatorInfo(normalized bool) string

OperatorInfo implements dataAccesser interface.

func (*PointGetPlan) OutputNames

func (p *PointGetPlan) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*PointGetPlan) ResolveIndices

func (p *PointGetPlan) ResolveIndices() error

ResolveIndices resolves the indices for columns. After doing this, the columns can evaluate the rows by their indices.

func (*PointGetPlan) SCtx

func (p *PointGetPlan) SCtx() sessionctx.Context

Context implements Plan Context interface.

func (*PointGetPlan) Schema

func (p *PointGetPlan) Schema() *expression.Schema

Schema implements the Plan interface.

func (*PointGetPlan) SelectBlockOffset

func (p *PointGetPlan) SelectBlockOffset() int

func (*PointGetPlan) SetChild

func (*PointGetPlan) SetChild(_ int, _ PhysicalPlan)

SetChild sets a specific child for the plan.

func (*PointGetPlan) SetChildren

func (*PointGetPlan) SetChildren(...PhysicalPlan)

SetChildren sets the children for the plan.

func (*PointGetPlan) SetCost

func (p *PointGetPlan) SetCost(cost float64)

SetCost implements PhysicalPlan interface

func (*PointGetPlan) SetOutputNames

func (p *PointGetPlan) SetOutputNames(names types.NameSlice)

SetOutputNames sets the outputting name by the given slice.

func (*PointGetPlan) Stats

func (p *PointGetPlan) Stats() *property.StatsInfo

Stats implements Plan Stats interface.

func (*PointGetPlan) StatsCount

func (*PointGetPlan) StatsCount() float64

StatsCount will return the the RowCount of property.StatsInfo for this plan.

func (*PointGetPlan) TP

func (p *PointGetPlan) TP() string

TP implements Plan interface.

func (*PointGetPlan) ToPB

func (*PointGetPlan) ToPB(_ sessionctx.Context, _ kv.StoreType) (*tipb.Executor, error)

ToPB converts physical plan to tipb executor.

type PointPlanVal

type PointPlanVal struct {
	Plan Plan
}

PointPlanVal is used to store point plan that is pre-built for multi-statement query. Save the plan in a struct so even if the point plan is nil, we don't need to try again.

type Prepare

type Prepare struct {
	Name    string
	SQLText string
	// contains filtered or unexported fields
}

Prepare represents prepare plan.

func (*Prepare) MemoryUsage

func (s *Prepare) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*Prepare) OutputNames

func (s *Prepare) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Prepare) ResolveIndices

func (p *Prepare) ResolveIndices() (err error)

func (*Prepare) Schema

func (s *Prepare) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Prepare) SetOutputNames

func (s *Prepare) SetOutputNames(names types.NameSlice)

func (*Prepare) SetSchema

func (s *Prepare) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type PreprocessOpt

type PreprocessOpt func(*preprocessor)

PreprocessOpt presents optional parameters to `Preprocess` method.

func WithPreprocessorReturn

func WithPreprocessorReturn(ret *PreprocessorReturn) PreprocessOpt

WithPreprocessorReturn returns a PreprocessOpt to initialize the PreprocessorReturn.

type PreprocessorReturn

type PreprocessorReturn struct {
	IsStaleness         bool
	SnapshotTSEvaluator func(sessionctx.Context) (uint64, error)
	// LastSnapshotTS is the last evaluated snapshotTS if any
	// otherwise it defaults to zero
	LastSnapshotTS uint64
	InfoSchema     infoschema.InfoSchema
	// contains filtered or unexported fields
}

PreprocessorReturn is used to retain information obtained in the preprocessor.

type PushedDownLimit

type PushedDownLimit struct {
	Offset uint64
	Count  uint64
}

PushedDownLimit is the limit operator pushed down into PhysicalIndexLookUpReader.

func (*PushedDownLimit) Clone

func (p *PushedDownLimit) Clone() *PushedDownLimit

Clone clones this pushed-down list.

func (*PushedDownLimit) MemoryUsage

func (p *PushedDownLimit) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PushedDownLimit

type QueryTimeRange

type QueryTimeRange struct {
	From time.Time
	To   time.Time
}

QueryTimeRange represents a time range specified by TIME_RANGE hint

func (*QueryTimeRange) Condition

func (tr *QueryTimeRange) Condition() string

Condition returns a WHERE clause base on it's value

func (*QueryTimeRange) MemoryUsage

func (tr *QueryTimeRange) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of QueryTimeRange

type ReadReqType

type ReadReqType uint8

ReadReqType is the read request type of the operator. Currently, only PhysicalTableReader uses this.

const (
	// Cop means read from storage by cop request.
	Cop ReadReqType = iota
	// BatchCop means read from storage by BatchCop request, only used for TiFlash
	BatchCop
	// MPP means read from storage by MPP request, only used for TiFlash
	MPP
)

func (ReadReqType) Name

func (r ReadReqType) Name() string

Name returns the name of read request type.

type RecoverIndex

type RecoverIndex struct {
	Table     *ast.TableName
	IndexName string
	// contains filtered or unexported fields
}

RecoverIndex is used for backfilling corrupted index data.

func (*RecoverIndex) MemoryUsage

func (s *RecoverIndex) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*RecoverIndex) OutputNames

func (s *RecoverIndex) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*RecoverIndex) ResolveIndices

func (p *RecoverIndex) ResolveIndices() (err error)

func (*RecoverIndex) Schema

func (s *RecoverIndex) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*RecoverIndex) SetOutputNames

func (s *RecoverIndex) SetOutputNames(names types.NameSlice)

func (*RecoverIndex) SetSchema

func (s *RecoverIndex) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ReloadExprPushdownBlacklist

type ReloadExprPushdownBlacklist struct {
	// contains filtered or unexported fields
}

ReloadExprPushdownBlacklist reloads the data from expr_pushdown_blacklist table.

func (*ReloadExprPushdownBlacklist) MemoryUsage

func (s *ReloadExprPushdownBlacklist) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*ReloadExprPushdownBlacklist) OutputNames

func (s *ReloadExprPushdownBlacklist) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*ReloadExprPushdownBlacklist) ResolveIndices

func (p *ReloadExprPushdownBlacklist) ResolveIndices() (err error)

func (*ReloadExprPushdownBlacklist) Schema

func (s *ReloadExprPushdownBlacklist) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*ReloadExprPushdownBlacklist) SetOutputNames

func (s *ReloadExprPushdownBlacklist) SetOutputNames(names types.NameSlice)

func (*ReloadExprPushdownBlacklist) SetSchema

func (s *ReloadExprPushdownBlacklist) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ReloadOptRuleBlacklist

type ReloadOptRuleBlacklist struct {
	// contains filtered or unexported fields
}

ReloadOptRuleBlacklist reloads the data from opt_rule_blacklist table.

func (*ReloadOptRuleBlacklist) MemoryUsage

func (s *ReloadOptRuleBlacklist) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*ReloadOptRuleBlacklist) OutputNames

func (s *ReloadOptRuleBlacklist) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*ReloadOptRuleBlacklist) ResolveIndices

func (p *ReloadOptRuleBlacklist) ResolveIndices() (err error)

func (*ReloadOptRuleBlacklist) Schema

func (s *ReloadOptRuleBlacklist) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*ReloadOptRuleBlacklist) SetOutputNames

func (s *ReloadOptRuleBlacklist) SetOutputNames(names types.NameSlice)

func (*ReloadOptRuleBlacklist) SetSchema

func (s *ReloadOptRuleBlacklist) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type SQLBindOpType

type SQLBindOpType int

SQLBindOpType repreents the SQL bind type

const (
	// OpSQLBindCreate represents the operation to create a SQL bind.
	OpSQLBindCreate SQLBindOpType = iota
	// OpSQLBindDrop represents the operation to drop a SQL bind.
	OpSQLBindDrop
	// OpFlushBindings is used to flush plan bindings.
	OpFlushBindings
	// OpCaptureBindings is used to capture plan bindings.
	OpCaptureBindings
	// OpEvolveBindings is used to evolve plan binding.
	OpEvolveBindings
	// OpReloadBindings is used to reload plan binding.
	OpReloadBindings
	// OpSetBindingStatus is used to set binding status.
	OpSetBindingStatus
	// OpSQLBindDropByDigest is used to drop SQL binds by digest
	OpSQLBindDropByDigest
	// OpSetBindingStatusByDigest represents the operation to set SQL binding status by sql digest.
	OpSetBindingStatusByDigest
)

type SQLBindPlan

type SQLBindPlan struct {
	SQLBindOp    SQLBindOpType
	NormdOrigSQL string
	BindSQL      string
	IsGlobal     bool
	BindStmt     ast.StmtNode
	Db           string
	Charset      string
	Collation    string
	NewStatus    string
	Source       string // Source indicate how this binding was created, eg: bindinfo.Manual or bindinfo.History
	SQLDigest    string
	PlanDigest   string
	// contains filtered or unexported fields
}

SQLBindPlan represents a plan for SQL bind.

func (*SQLBindPlan) MemoryUsage

func (s *SQLBindPlan) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*SQLBindPlan) OutputNames

func (s *SQLBindPlan) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*SQLBindPlan) ResolveIndices

func (p *SQLBindPlan) ResolveIndices() (err error)

func (*SQLBindPlan) Schema

func (s *SQLBindPlan) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*SQLBindPlan) SetOutputNames

func (s *SQLBindPlan) SetOutputNames(names types.NameSlice)

func (*SQLBindPlan) SetSchema

func (s *SQLBindPlan) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ScanAccessObject

type ScanAccessObject struct {
	Database   string
	Table      string
	Indexes    []IndexAccess
	Partitions []string
}

ScanAccessObject represents the access to a table. It may also represent the access to indexes and partitions of a table.

func (*ScanAccessObject) NormalizedString

func (s *ScanAccessObject) NormalizedString() string

NormalizedString implements AccessObject.

func (*ScanAccessObject) SetIntoPB

func (s *ScanAccessObject) SetIntoPB(pb *tipb.ExplainOperator)

SetIntoPB implements AccessObject.

func (*ScanAccessObject) String

func (s *ScanAccessObject) String() string

type SelectInto

type SelectInto struct {
	TargetPlan Plan
	IntoOpt    *ast.SelectIntoOption
	// contains filtered or unexported fields
}

SelectInto represents a select-into plan.

func (*SelectInto) MemoryUsage

func (s *SelectInto) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*SelectInto) OutputNames

func (s *SelectInto) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*SelectInto) ResolveIndices

func (p *SelectInto) ResolveIndices() (err error)

func (*SelectInto) Schema

func (s *SelectInto) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*SelectInto) SetOutputNames

func (s *SelectInto) SetOutputNames(names types.NameSlice)

func (*SelectInto) SetSchema

func (s *SelectInto) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type Set

type Set struct {
	VarAssigns []*expression.VarAssignment
	// contains filtered or unexported fields
}

Set represents a plan for set stmt.

func (*Set) MemoryUsage

func (s *Set) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*Set) OutputNames

func (s *Set) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Set) ResolveIndices

func (p *Set) ResolveIndices() (err error)

func (*Set) Schema

func (s *Set) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Set) SetOutputNames

func (s *Set) SetOutputNames(names types.NameSlice)

func (*Set) SetSchema

func (s *Set) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type SetConfig

type SetConfig struct {
	Type     string
	Instance string
	Name     string
	Value    expression.Expression
	// contains filtered or unexported fields
}

SetConfig represents a plan for set config stmt.

func (*SetConfig) MemoryUsage

func (s *SetConfig) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*SetConfig) OutputNames

func (s *SetConfig) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*SetConfig) ResolveIndices

func (p *SetConfig) ResolveIndices() (err error)

func (*SetConfig) Schema

func (s *SetConfig) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*SetConfig) SetOutputNames

func (s *SetConfig) SetOutputNames(names types.NameSlice)

func (*SetConfig) SetSchema

func (s *SetConfig) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ShowBaseExtractor

type ShowBaseExtractor struct {
	ast.ShowStmt
	// contains filtered or unexported fields
}

ShowBaseExtractor is the definition of base extractor for derived predicates.

func (*ShowBaseExtractor) Extract

func (e *ShowBaseExtractor) Extract() bool

Extract implements the ShowPredicateExtractor interface.

func (*ShowBaseExtractor) Field

func (e *ShowBaseExtractor) Field() string

Field will return the variable `field` in ShowBaseExtractor

func (*ShowBaseExtractor) FieldPatternLike

func (e *ShowBaseExtractor) FieldPatternLike() collate.WildcardPattern

FieldPatternLike will return compiled collate.WildcardPattern

type ShowContents

type ShowContents struct {
	Tp                ast.ShowStmtType // Databases/Tables/Columns/....
	DBName            string
	Table             *ast.TableName  // Used for showing columns.
	Partition         model.CIStr     // Use for showing partition
	Column            *ast.ColumnName // Used for `desc table column`.
	IndexName         model.CIStr
	ResourceGroupName string               // Used for showing resource group
	Flag              int                  // Some flag parsed from sql, such as FULL.
	User              *auth.UserIdentity   // Used for show grants.
	Roles             []*auth.RoleIdentity // Used for show grants.

	CountWarningsOrErrors bool // Used for showing count(*) warnings | errors

	Full        bool
	IfNotExists bool       // Used for `show create database if not exists`.
	GlobalScope bool       // Used by show variables.
	Extended    bool       // Used for `show extended columns from ...`
	Limit       *ast.Limit // Used for limit Result Set row number.
}

ShowContents stores the contents for the `SHOW` statement.

func (*ShowContents) MemoryUsage

func (s *ShowContents) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of ShowContents

type ShowDDL

type ShowDDL struct {
	// contains filtered or unexported fields
}

ShowDDL is for showing DDL information.

func (*ShowDDL) MemoryUsage

func (s *ShowDDL) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*ShowDDL) OutputNames

func (s *ShowDDL) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*ShowDDL) ResolveIndices

func (p *ShowDDL) ResolveIndices() (err error)

func (*ShowDDL) Schema

func (s *ShowDDL) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*ShowDDL) SetOutputNames

func (s *ShowDDL) SetOutputNames(names types.NameSlice)

func (*ShowDDL) SetSchema

func (s *ShowDDL) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ShowDDLJobQueries

type ShowDDLJobQueries struct {
	JobIDs []int64
	// contains filtered or unexported fields
}

ShowDDLJobQueries is for showing DDL job queries sql.

func (*ShowDDLJobQueries) MemoryUsage

func (s *ShowDDLJobQueries) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*ShowDDLJobQueries) OutputNames

func (s *ShowDDLJobQueries) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*ShowDDLJobQueries) ResolveIndices

func (p *ShowDDLJobQueries) ResolveIndices() (err error)

func (*ShowDDLJobQueries) Schema

func (s *ShowDDLJobQueries) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*ShowDDLJobQueries) SetOutputNames

func (s *ShowDDLJobQueries) SetOutputNames(names types.NameSlice)

func (*ShowDDLJobQueries) SetSchema

func (s *ShowDDLJobQueries) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ShowDDLJobQueriesWithRange

type ShowDDLJobQueriesWithRange struct {
	Limit  uint64
	Offset uint64
	// contains filtered or unexported fields
}

ShowDDLJobQueriesWithRange is for showing DDL job queries sql with specified limit and offset.

func (*ShowDDLJobQueriesWithRange) MemoryUsage

func (s *ShowDDLJobQueriesWithRange) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*ShowDDLJobQueriesWithRange) OutputNames

func (s *ShowDDLJobQueriesWithRange) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*ShowDDLJobQueriesWithRange) ResolveIndices

func (p *ShowDDLJobQueriesWithRange) ResolveIndices() (err error)

func (*ShowDDLJobQueriesWithRange) Schema

func (s *ShowDDLJobQueriesWithRange) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*ShowDDLJobQueriesWithRange) SetOutputNames

func (s *ShowDDLJobQueriesWithRange) SetOutputNames(names types.NameSlice)

func (*ShowDDLJobQueriesWithRange) SetSchema

func (s *ShowDDLJobQueriesWithRange) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ShowNextRowID

type ShowNextRowID struct {
	TableName *ast.TableName
	// contains filtered or unexported fields
}

ShowNextRowID is for showing the next global row ID.

func (*ShowNextRowID) MemoryUsage

func (s *ShowNextRowID) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*ShowNextRowID) OutputNames

func (s *ShowNextRowID) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*ShowNextRowID) ResolveIndices

func (p *ShowNextRowID) ResolveIndices() (err error)

func (*ShowNextRowID) Schema

func (s *ShowNextRowID) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*ShowNextRowID) SetOutputNames

func (s *ShowNextRowID) SetOutputNames(names types.NameSlice)

func (*ShowNextRowID) SetSchema

func (s *ShowNextRowID) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type ShowPredicateExtractor

type ShowPredicateExtractor interface {
	// Extract predicates which can be pushed down and returns whether the extractor can extract predicates.
	Extract() bool

	Field() string
	FieldPatternLike() collate.WildcardPattern
	// contains filtered or unexported methods
}

ShowPredicateExtractor is used to extract some predicates from `PatternLikeExpr` clause and push the predicates down to the data retrieving on reading memory table stage when use ShowStmt.

e.g: SHOW COLUMNS FROM t LIKE '%abc%' We must request all components from the memory table, and filter the result by the PatternLikeExpr predicate.

it is a way to fix https://github.com/lemon-mint/tidb/v7/issues/29910.

type ShowSlow

type ShowSlow struct {
	*ast.ShowSlow
	// contains filtered or unexported fields
}

ShowSlow is for showing slow queries.

func (*ShowSlow) MemoryUsage

func (s *ShowSlow) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*ShowSlow) OutputNames

func (s *ShowSlow) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*ShowSlow) ResolveIndices

func (p *ShowSlow) ResolveIndices() (err error)

func (*ShowSlow) Schema

func (s *ShowSlow) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*ShowSlow) SetOutputNames

func (s *ShowSlow) SetOutputNames(names types.NameSlice)

func (*ShowSlow) SetSchema

func (s *ShowSlow) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type Simple

type Simple struct {
	Statement ast.StmtNode

	// IsFromRemote indicates whether the statement IS FROM REMOTE TiDB instance in cluster,
	//   and executing in co-processor.
	//   Used for `global kill`. See https://github.com/lemon-mint/tidb/v7/blob/master/docs/design/2020-06-01-global-kill.md.
	IsFromRemote bool

	// StaleTxnStartTS is the StartTS that is used to build a staleness transaction by 'START TRANSACTION READ ONLY' statement.
	StaleTxnStartTS uint64
	// contains filtered or unexported fields
}

Simple represents a simple statement plan which doesn't need any optimization.

func (*Simple) MemoryUsage

func (s *Simple) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of Simple

func (*Simple) OutputNames

func (s *Simple) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Simple) ResolveIndices

func (p *Simple) ResolveIndices() (err error)

func (*Simple) Schema

func (s *Simple) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Simple) SetOutputNames

func (s *Simple) SetOutputNames(names types.NameSlice)

func (*Simple) SetSchema

func (s *Simple) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type SlowQueryExtractor

type SlowQueryExtractor struct {
	SkipRequest bool
	TimeRanges  []*TimeRange
	// Enable is true means the executor should use the time range to locate the slow-log file that need to be parsed.
	// Enable is false, means the executor should keep the behavior compatible with before, which is only parse the
	// current slow-log file.
	Enable bool
	Desc   bool
	// contains filtered or unexported fields
}

SlowQueryExtractor is used to extract some predicates of `slow_query`

func (*SlowQueryExtractor) Extract

func (e *SlowQueryExtractor) Extract(
	ctx sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) []expression.Expression

Extract implements the MemTablePredicateExtractor Extract interface

type SplitRegion

type SplitRegion struct {
	TableInfo      *model.TableInfo
	PartitionNames []model.CIStr
	IndexInfo      *model.IndexInfo
	Lower          []types.Datum
	Upper          []types.Datum
	Num            int
	ValueLists     [][]types.Datum
	// contains filtered or unexported fields
}

SplitRegion represents a split regions plan.

func (*SplitRegion) MemoryUsage

func (s *SplitRegion) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*SplitRegion) OutputNames

func (s *SplitRegion) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*SplitRegion) ResolveIndices

func (p *SplitRegion) ResolveIndices() (err error)

func (*SplitRegion) Schema

func (s *SplitRegion) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*SplitRegion) SetOutputNames

func (s *SplitRegion) SetOutputNames(names types.NameSlice)

func (*SplitRegion) SetSchema

func (s *SplitRegion) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type SplitRegionStatus

type SplitRegionStatus struct {
	Table     table.Table
	IndexInfo *model.IndexInfo
	// contains filtered or unexported fields
}

SplitRegionStatus represents a split regions status plan.

func (*SplitRegionStatus) MemoryUsage

func (s *SplitRegionStatus) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*SplitRegionStatus) OutputNames

func (s *SplitRegionStatus) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*SplitRegionStatus) ResolveIndices

func (p *SplitRegionStatus) ResolveIndices() (err error)

func (*SplitRegionStatus) Schema

func (s *SplitRegionStatus) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*SplitRegionStatus) SetOutputNames

func (s *SplitRegionStatus) SetOutputNames(names types.NameSlice)

func (*SplitRegionStatus) SetSchema

func (s *SplitRegionStatus) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type StatementsSummaryExtractor

type StatementsSummaryExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component
	SkipRequest bool
	// Digests represents digest applied to, and we should apply all digest if there is no digest specified.
	// e.g: SELECT * FROM STATEMENTS_SUMMARY WHERE digest='8019af26debae8aa7642c501dbc43212417b3fb14e6aec779f709976b7e521be'
	Digests set.StringSet
	// Enable is true means the executor should use digest to locate statement summary.
	// Enable is false, means the executor should keep the behavior compatible with before.
	Enable bool
	// contains filtered or unexported fields
}

StatementsSummaryExtractor is used to extract some predicates of statements summary table.

func (*StatementsSummaryExtractor) Extract

func (e *StatementsSummaryExtractor) Extract(
	_ sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) (remained []expression.Expression)

Extract implements the MemTablePredicateExtractor Extract interface

type TableSampleInfo

type TableSampleInfo struct {
	AstNode    *ast.TableSample
	FullSchema *expression.Schema
	Partitions []table.PartitionedTable
}

TableSampleInfo contains the information for PhysicalTableSample.

func NewTableSampleInfo

func NewTableSampleInfo(node *ast.TableSample, fullSchema *expression.Schema, pt []table.PartitionedTable) *TableSampleInfo

NewTableSampleInfo creates a new TableSampleInfo.

func (*TableSampleInfo) MemoryUsage

func (t *TableSampleInfo) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of TableSampleInfo

type TableStorageStatsExtractor

type TableStorageStatsExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component.
	SkipRequest bool
	// TableSchema represents tableSchema applied to, and we should apply all table disk usage if there is no schema specified.
	// e.g: SELECT * FROM information_schema.disk_usage WHERE table_schema in ('test', 'information_schema').
	TableSchema set.StringSet
	// TableName represents tableName applied to, and we should apply all table disk usage if there is no table specified.
	// e.g: SELECT * FROM information_schema.disk_usage WHERE table in ('schemata', 'tables').
	TableName set.StringSet
	// contains filtered or unexported fields
}

TableStorageStatsExtractor is used to extract some predicates of `disk_usage`.

func (*TableStorageStatsExtractor) Extract

Extract implements the MemTablePredicateExtractor Extract interface.

type TblColPosInfo

type TblColPosInfo struct {
	TblID int64
	// Start and End represent the ordinal range [Start, End) of the consecutive columns.
	Start, End int
	// HandleOrdinal represents the ordinal of the handle column.
	HandleCols HandleCols
}

TblColPosInfo represents an mapper from column index to handle index.

func (*TblColPosInfo) MemoryUsage

func (t *TblColPosInfo) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of TblColPosInfo

type TblColPosInfoSlice

type TblColPosInfoSlice []TblColPosInfo

TblColPosInfoSlice attaches the methods of sort.Interface to []TblColPosInfos sorting in increasing order.

func (TblColPosInfoSlice) FindTblIdx

func (c TblColPosInfoSlice) FindTblIdx(colOrdinal int) (int, bool)

FindTblIdx finds the ordinal of the corresponding access column.

func (TblColPosInfoSlice) Len

func (c TblColPosInfoSlice) Len() int

Len implements sort.Interface#Len.

func (TblColPosInfoSlice) Less

func (c TblColPosInfoSlice) Less(i, j int) bool

Less implements sort.Interface#Less.

func (TblColPosInfoSlice) Swap

func (c TblColPosInfoSlice) Swap(i, j int)

Swap implements sort.Interface#Swap.

type TiFlashSystemTableExtractor

type TiFlashSystemTableExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component
	SkipRequest bool
	// TiFlashInstances represents all tiflash instances we should send request to.
	// e.g:
	// 1. SELECT * FROM information_schema.<table_name> WHERE tiflash_instance='192.168.1.7:3930'
	// 2. SELECT * FROM information_schema.<table_name> WHERE tiflash_instance in ('192.168.1.7:3930', '192.168.1.9:3930')
	TiFlashInstances set.StringSet
	// TidbDatabases represents tidbDatabases applied to, and we should apply all tidb database if there is no database specified.
	// e.g: SELECT * FROM information_schema.<table_name> WHERE tidb_database in ('test', 'test2').
	TiDBDatabases string
	// TidbTables represents tidbTables applied to, and we should apply all tidb table if there is no table specified.
	// e.g: SELECT * FROM information_schema.<table_name> WHERE tidb_table in ('t', 't2').
	TiDBTables string
	// contains filtered or unexported fields
}

TiFlashSystemTableExtractor is used to extract some predicates of tiflash system table.

func (*TiFlashSystemTableExtractor) Extract

Extract implements the MemTablePredicateExtractor Extract interface

type TiKVRegionStatusExtractor

type TiKVRegionStatusExtractor struct {
	// contains filtered or unexported fields
}

TiKVRegionStatusExtractor is used to extract single table region scan region from predictions

func (*TiKVRegionStatusExtractor) Extract

func (e *TiKVRegionStatusExtractor) Extract(_ sessionctx.Context,
	schema *expression.Schema,
	names []*types.FieldName,
	predicates []expression.Expression,
) (remained []expression.Expression)

Extract implements the MemTablePredicateExtractor Extract interface

func (*TiKVRegionStatusExtractor) GetTablesID

func (e *TiKVRegionStatusExtractor) GetTablesID() []int64

GetTablesID returns TablesID

type TiKVSingleGather

type TiKVSingleGather struct {
	Source *DataSource
	// IsIndexGather marks if this TiKVSingleGather gathers tuples from an IndexScan.
	// in implementation phase, we need this flag to determine whether to generate
	// PhysicalTableReader or PhysicalIndexReader.
	IsIndexGather bool
	Index         *model.IndexInfo
	// contains filtered or unexported fields
}

TiKVSingleGather is a leaf logical operator of TiDB layer to gather tuples from TiKV regions.

func (*TiKVSingleGather) BuildKeyInfo

func (*TiKVSingleGather) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*TiKVSingleGather) ExplainInfo

func (p *TiKVSingleGather) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*TiKVSingleGather) GetPhysicalIndexReader

func (sg *TiKVSingleGather) GetPhysicalIndexReader(schema *expression.Schema, stats *property.StatsInfo, props ...*property.PhysicalProperty) *PhysicalIndexReader

GetPhysicalIndexReader returns PhysicalIndexReader for logical TiKVSingleGather.

func (*TiKVSingleGather) GetPhysicalTableReader

func (sg *TiKVSingleGather) GetPhysicalTableReader(schema *expression.Schema, stats *property.StatsInfo, props ...*property.PhysicalProperty) *PhysicalTableReader

GetPhysicalTableReader returns PhysicalTableReader for logical TiKVSingleGather.

func (TiKVSingleGather) Init

func (sg TiKVSingleGather) Init(ctx sessionctx.Context, offset int) *TiKVSingleGather

Init initializes TiKVSingleGather.

func (*TiKVSingleGather) OutputNames

func (s *TiKVSingleGather) OutputNames() types.NameSlice

func (*TiKVSingleGather) PreparePossibleProperties

func (*TiKVSingleGather) PreparePossibleProperties(_ *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*TiKVSingleGather) Schema

func (s *TiKVSingleGather) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*TiKVSingleGather) SetOutputNames

func (s *TiKVSingleGather) SetOutputNames(names types.NameSlice)

func (*TiKVSingleGather) SetSchema

func (s *TiKVSingleGather) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type TikvRegionPeersExtractor

type TikvRegionPeersExtractor struct {

	// SkipRequest means the where clause always false, we don't need to request any component
	SkipRequest bool

	// RegionIDs/StoreIDs represents all region/store ids we should filter in PD to reduce network IO.
	// e.g:
	// 1. SELECT * FROM tikv_region_peers WHERE region_id=1
	// 2. SELECT * FROM tikv_region_peers WHERE table_id in (11, 22)
	RegionIDs []uint64
	StoreIDs  []uint64
	// contains filtered or unexported fields
}

TikvRegionPeersExtractor is used to extract some predicates of cluster table.

func (*TikvRegionPeersExtractor) Extract

Extract implements the MemTablePredicateExtractor Extract interface

type TimeRange

type TimeRange struct {
	StartTime time.Time
	EndTime   time.Time
}

TimeRange is used to check whether a given log should be extracted.

type Trace

type Trace struct {
	StmtNode ast.StmtNode
	Format   string

	// OptimizerTrace indicates `trace plan target = 'xxx' <statement>` case
	OptimizerTrace       bool
	OptimizerTraceTarget string
	// contains filtered or unexported fields
}

Trace represents a trace plan.

func (*Trace) MemoryUsage

func (s *Trace) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*Trace) OutputNames

func (s *Trace) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Trace) ResolveIndices

func (p *Trace) ResolveIndices() (err error)

func (*Trace) Schema

func (s *Trace) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Trace) SetOutputNames

func (s *Trace) SetOutputNames(names types.NameSlice)

func (*Trace) SetSchema

func (s *Trace) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type UnlockStats

type UnlockStats struct {
	Tables []*ast.TableName
	// contains filtered or unexported fields
}

UnlockStats represents a unlock stats for table

func (*UnlockStats) MemoryUsage

func (s *UnlockStats) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of baseSchemaProducer

func (*UnlockStats) OutputNames

func (s *UnlockStats) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*UnlockStats) ResolveIndices

func (p *UnlockStats) ResolveIndices() (err error)

func (*UnlockStats) Schema

func (s *UnlockStats) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*UnlockStats) SetOutputNames

func (s *UnlockStats) SetOutputNames(names types.NameSlice)

func (*UnlockStats) SetSchema

func (s *UnlockStats) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type Update

type Update struct {
	OrderedList []*expression.Assignment

	AllAssignmentsAreConstant bool

	VirtualAssignmentsOffset int

	SelectPlan PhysicalPlan

	TblColPosInfos TblColPosInfoSlice

	// Used when partition sets are given.
	// e.g. update t partition(p0) set a = 1;
	PartitionedTable []table.PartitionedTable

	FKChecks   map[int64][]*FKCheck
	FKCascades map[int64][]*FKCascade
	// contains filtered or unexported fields
}

Update represents Update plan.

func (Update) Init

func (p Update) Init(ctx sessionctx.Context) *Update

Init initializes Update.

func (*Update) MemoryUsage

func (p *Update) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of Update

func (*Update) OutputNames

func (s *Update) OutputNames() types.NameSlice

OutputNames returns the outputting names of each column.

func (*Update) ResolveIndices

func (p *Update) ResolveIndices() (err error)

ResolveIndices implements Plan interface.

func (*Update) Schema

func (s *Update) Schema() *expression.Schema

Schema implements the Plan.Schema interface.

func (*Update) SetOutputNames

func (s *Update) SetOutputNames(names types.NameSlice)

func (*Update) SetSchema

func (s *Update) SetSchema(schema *expression.Schema)

SetSchema implements the Plan.SetSchema interface.

type V2AnalyzeOptions

type V2AnalyzeOptions struct {
	PhyTableID  int64
	RawOpts     map[ast.AnalyzeOptionType]uint64
	FilledOpts  map[ast.AnalyzeOptionType]uint64
	ColChoice   model.ColumnChoice
	ColumnList  []*model.ColumnInfo
	IsPartition bool
}

V2AnalyzeOptions is used to hold analyze options information.

type WindowFrame

type WindowFrame struct {
	Type  ast.FrameType
	Start *FrameBound
	End   *FrameBound
}

WindowFrame represents a window function frame.

func (*WindowFrame) Clone

func (wf *WindowFrame) Clone() *WindowFrame

Clone copies a window frame totally.

type WindowFuncExtractor

type WindowFuncExtractor struct {
	// contains filtered or unexported fields
}

WindowFuncExtractor visits Expr tree. It converts ColunmNameExpr to WindowFuncExpr and collects WindowFuncExpr.

func (*WindowFuncExtractor) Enter

func (*WindowFuncExtractor) Enter(n ast.Node) (ast.Node, bool)

Enter implements Visitor interface.

func (*WindowFuncExtractor) Leave

func (a *WindowFuncExtractor) Leave(n ast.Node) (ast.Node, bool)

Leave implements Visitor interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL