core

package
v3.1.0-fork Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: Apache-2.0 Imports: 76 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TiDBMergeJoin is hint enforce merge join.
	TiDBMergeJoin = "tidb_smj"
	// HintSMJ is hint enforce merge join.
	HintSMJ = "merge_join"
	// 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"
	// HintHashAgg is hint enforce hash aggregation.
	HintHashAgg = "hash_agg"
	// HintStreamAgg is hint enforce stream aggregation.
	HintStreamAgg = "stream_agg"
	// HintUseIndex is hint enforce using some indexes.
	HintUseIndex = "use_index"
	// HintIgnoreIndex is hint enforce ignoring some indexes.
	HintIgnoreIndex = "ignore_index"
	// 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"
)
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 (
	// TraceFormatRow indicates row tracing format.
	TraceFormatRow = "row"
	// TraceFormatJSON indicates json tracing format.
	TraceFormatJSON = "json"
	// TraceFormatLog indicates log tracing format.
	TraceFormatLog = "log"
)
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 (
	// PartitionHashSplitterType is the splitter splits by hash.
	PartitionHashSplitterType = iota
)
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 (

	// PreparedPlanCacheCapacity stores the global config "prepared-plan-cache-capacity".
	PreparedPlanCacheCapacity uint = 100
	// PreparedPlanCacheMemoryGuardRatio stores the global config "prepared-plan-cache-memory-guard-ratio".
	PreparedPlanCacheMemoryGuardRatio = 0.1
	// PreparedPlanCacheMaxMemory stores the max memory size defined in the global config "performance-max-memory".
	PreparedPlanCacheMaxMemory atomic2.Uint64 = *atomic2.NewUint64(math.MaxUint64)
)
View Source
var (
	ErrUnsupportedType                 = terror.ClassOptimizer.New(mysql.ErrUnsupportedType, mysql.MySQLErrName[mysql.ErrUnsupportedType])
	ErrAnalyzeMissIndex                = terror.ClassOptimizer.New(mysql.ErrAnalyzeMissIndex, mysql.MySQLErrName[mysql.ErrAnalyzeMissIndex])
	ErrWrongParamCount                 = terror.ClassOptimizer.New(mysql.ErrWrongParamCount, mysql.MySQLErrName[mysql.ErrWrongParamCount])
	ErrSchemaChanged                   = terror.ClassOptimizer.New(mysql.ErrSchemaChanged, mysql.MySQLErrName[mysql.ErrSchemaChanged])
	ErrTablenameNotAllowedHere         = terror.ClassOptimizer.New(mysql.ErrTablenameNotAllowedHere, mysql.MySQLErrName[mysql.ErrTablenameNotAllowedHere])
	ErrNotSupportedYet                 = terror.ClassOptimizer.New(mysql.ErrNotSupportedYet, mysql.MySQLErrName[mysql.ErrNotSupportedYet])
	ErrWrongUsage                      = terror.ClassOptimizer.New(mysql.ErrWrongUsage, mysql.MySQLErrName[mysql.ErrWrongUsage])
	ErrUnknown                         = terror.ClassOptimizer.New(mysql.ErrUnknown, mysql.MySQLErrName[mysql.ErrUnknown])
	ErrUnknownTable                    = terror.ClassOptimizer.New(mysql.ErrUnknownTable, mysql.MySQLErrName[mysql.ErrUnknownTable])
	ErrNoSuchTable                     = terror.ClassOptimizer.New(mysql.ErrNoSuchTable, mysql.MySQLErrName[mysql.ErrNoSuchTable])
	ErrWrongArguments                  = terror.ClassOptimizer.New(mysql.ErrWrongArguments, mysql.MySQLErrName[mysql.ErrWrongArguments])
	ErrWrongNumberOfColumnsInSelect    = terror.ClassOptimizer.New(mysql.ErrWrongNumberOfColumnsInSelect, mysql.MySQLErrName[mysql.ErrWrongNumberOfColumnsInSelect])
	ErrBadGeneratedColumn              = terror.ClassOptimizer.New(mysql.ErrBadGeneratedColumn, mysql.MySQLErrName[mysql.ErrBadGeneratedColumn])
	ErrFieldNotInGroupBy               = terror.ClassOptimizer.New(mysql.ErrFieldNotInGroupBy, mysql.MySQLErrName[mysql.ErrFieldNotInGroupBy])
	ErrBadTable                        = terror.ClassOptimizer.New(mysql.ErrBadTable, mysql.MySQLErrName[mysql.ErrBadTable])
	ErrKeyDoesNotExist                 = terror.ClassOptimizer.New(mysql.ErrKeyDoesNotExist, mysql.MySQLErrName[mysql.ErrKeyDoesNotExist])
	ErrOperandColumns                  = terror.ClassOptimizer.New(mysql.ErrOperandColumns, mysql.MySQLErrName[mysql.ErrOperandColumns])
	ErrInvalidGroupFuncUse             = terror.ClassOptimizer.New(mysql.ErrInvalidGroupFuncUse, mysql.MySQLErrName[mysql.ErrInvalidGroupFuncUse])
	ErrIllegalReference                = terror.ClassOptimizer.New(mysql.ErrIllegalReference, mysql.MySQLErrName[mysql.ErrIllegalReference])
	ErrNoDB                            = terror.ClassOptimizer.New(mysql.ErrNoDB, mysql.MySQLErrName[mysql.ErrNoDB])
	ErrUnknownExplainFormat            = terror.ClassOptimizer.New(mysql.ErrUnknownExplainFormat, mysql.MySQLErrName[mysql.ErrUnknownExplainFormat])
	ErrWrongGroupField                 = terror.ClassOptimizer.New(mysql.ErrWrongGroupField, mysql.MySQLErrName[mysql.ErrWrongGroupField])
	ErrDupFieldName                    = terror.ClassOptimizer.New(mysql.ErrDupFieldName, mysql.MySQLErrName[mysql.ErrDupFieldName])
	ErrNonUpdatableTable               = terror.ClassOptimizer.New(mysql.ErrNonUpdatableTable, mysql.MySQLErrName[mysql.ErrNonUpdatableTable])
	ErrInternal                        = terror.ClassOptimizer.New(mysql.ErrInternal, mysql.MySQLErrName[mysql.ErrInternal])
	ErrNonUniqTable                    = terror.ClassOptimizer.New(mysql.ErrNonuniqTable, mysql.MySQLErrName[mysql.ErrNonuniqTable])
	ErrWindowInvalidWindowFuncUse      = terror.ClassOptimizer.New(mysql.ErrWindowInvalidWindowFuncUse, mysql.MySQLErrName[mysql.ErrWindowInvalidWindowFuncUse])
	ErrWindowInvalidWindowFuncAliasUse = terror.ClassOptimizer.New(mysql.ErrWindowInvalidWindowFuncAliasUse, mysql.MySQLErrName[mysql.ErrWindowInvalidWindowFuncAliasUse])
	ErrWindowNoSuchWindow              = terror.ClassOptimizer.New(mysql.ErrWindowNoSuchWindow, mysql.MySQLErrName[mysql.ErrWindowNoSuchWindow])
	ErrWindowCircularityInWindowGraph  = terror.ClassOptimizer.New(mysql.ErrWindowCircularityInWindowGraph, mysql.MySQLErrName[mysql.ErrWindowCircularityInWindowGraph])
	ErrWindowNoChildPartitioning       = terror.ClassOptimizer.New(mysql.ErrWindowNoChildPartitioning, mysql.MySQLErrName[mysql.ErrWindowNoChildPartitioning])
	ErrWindowNoInherentFrame           = terror.ClassOptimizer.New(mysql.ErrWindowNoInherentFrame, mysql.MySQLErrName[mysql.ErrWindowNoInherentFrame])
	ErrWindowNoRedefineOrderBy         = terror.ClassOptimizer.New(mysql.ErrWindowNoRedefineOrderBy, mysql.MySQLErrName[mysql.ErrWindowNoRedefineOrderBy])
	ErrWindowDuplicateName             = terror.ClassOptimizer.New(mysql.ErrWindowDuplicateName, mysql.MySQLErrName[mysql.ErrWindowDuplicateName])
	ErrPartitionClauseOnNonpartitioned = terror.ClassOptimizer.New(mysql.ErrPartitionClauseOnNonpartitioned, mysql.MySQLErrName[mysql.ErrPartitionClauseOnNonpartitioned])
	ErrWindowFrameStartIllegal         = terror.ClassOptimizer.New(mysql.ErrWindowFrameStartIllegal, mysql.MySQLErrName[mysql.ErrWindowFrameStartIllegal])
	ErrWindowFrameEndIllegal           = terror.ClassOptimizer.New(mysql.ErrWindowFrameEndIllegal, mysql.MySQLErrName[mysql.ErrWindowFrameEndIllegal])
	ErrWindowFrameIllegal              = terror.ClassOptimizer.New(mysql.ErrWindowFrameIllegal, mysql.MySQLErrName[mysql.ErrWindowFrameIllegal])
	ErrWindowRangeFrameOrderType       = terror.ClassOptimizer.New(mysql.ErrWindowRangeFrameOrderType, mysql.MySQLErrName[mysql.ErrWindowRangeFrameOrderType])
	ErrWindowRangeFrameTemporalType    = terror.ClassOptimizer.New(mysql.ErrWindowRangeFrameTemporalType, mysql.MySQLErrName[mysql.ErrWindowRangeFrameTemporalType])
	ErrWindowRangeFrameNumericType     = terror.ClassOptimizer.New(mysql.ErrWindowRangeFrameNumericType, mysql.MySQLErrName[mysql.ErrWindowRangeFrameNumericType])
	ErrWindowRangeBoundNotConstant     = terror.ClassOptimizer.New(mysql.ErrWindowRangeBoundNotConstant, mysql.MySQLErrName[mysql.ErrWindowRangeBoundNotConstant])
	ErrWindowRowsIntervalUse           = terror.ClassOptimizer.New(mysql.ErrWindowRowsIntervalUse, mysql.MySQLErrName[mysql.ErrWindowRowsIntervalUse])
	ErrWindowFunctionIgnoresFrame      = terror.ClassOptimizer.New(mysql.ErrWindowFunctionIgnoresFrame, mysql.MySQLErrName[mysql.ErrWindowFunctionIgnoresFrame])
	ErrUnsupportedOnGeneratedColumn    = terror.ClassOptimizer.New(mysql.ErrUnsupportedOnGeneratedColumn, mysql.MySQLErrName[mysql.ErrUnsupportedOnGeneratedColumn])
	ErrPrivilegeCheckFail              = terror.ClassOptimizer.New(mysql.ErrPrivilegeCheckFail, mysql.MySQLErrName[mysql.ErrPrivilegeCheckFail])
	ErrInvalidWildCard                 = terror.ClassOptimizer.New(mysql.ErrInvalidWildCard, mysql.MySQLErrName[mysql.ErrInvalidWildCard])
	ErrMixOfGroupFuncAndFields         = terror.ClassOptimizer.New(mysql.ErrMixOfGroupFuncAndFieldsIncompatible, mysql.MySQLErrName[mysql.ErrMixOfGroupFuncAndFieldsIncompatible])

	ErrDBaccessDenied              = terror.ClassOptimizer.New(mysql.ErrDBaccessDenied, mysql.MySQLErrName[mysql.ErrDBaccessDenied])
	ErrTableaccessDenied           = terror.ClassOptimizer.New(mysql.ErrTableaccessDenied, mysql.MySQLErrName[mysql.ErrTableaccessDenied])
	ErrSpecificAccessDenied        = terror.ClassOptimizer.New(mysql.ErrSpecificAccessDenied, mysql.MySQLErrName[mysql.ErrSpecificAccessDenied])
	ErrViewNoExplain               = terror.ClassOptimizer.New(mysql.ErrViewNoExplain, mysql.MySQLErrName[mysql.ErrViewNoExplain])
	ErrWrongValueCountOnRow        = terror.ClassOptimizer.New(mysql.ErrWrongValueCountOnRow, mysql.MySQLErrName[mysql.ErrWrongValueCountOnRow])
	ErrViewInvalid                 = terror.ClassOptimizer.New(mysql.ErrViewInvalid, mysql.MySQLErrName[mysql.ErrViewInvalid])
	ErrNoSuchThread                = terror.ClassOptimizer.New(mysql.ErrNoSuchThread, mysql.MySQLErrName[mysql.ErrNoSuchThread])
	ErrUnknownColumn               = terror.ClassOptimizer.New(mysql.ErrBadField, mysql.MySQLErrName[mysql.ErrBadField])
	ErrCartesianProductUnsupported = terror.ClassOptimizer.New(mysql.ErrCartesianProductUnsupported, mysql.MySQLErrName[mysql.ErrCartesianProductUnsupported])
	ErrStmtNotFound                = terror.ClassOptimizer.New(mysql.ErrPreparedStmtNotFound, mysql.MySQLErrName[mysql.ErrPreparedStmtNotFound])
	ErrAmbiguous                   = terror.ClassOptimizer.New(mysql.ErrNonUniq, mysql.MySQLErrName[mysql.ErrNonUniq])
	// Since we cannot know if user loggined with a password, use message of ErrAccessDeniedNoPassword instead
	ErrAccessDenied = terror.ClassOptimizer.New(mysql.ErrAccessDenied, mysql.MySQLErrName[mysql.ErrAccessDeniedNoPassword])
)

error definitions.

View Source
var AllowCartesianProduct = atomic.NewBool(true)

AllowCartesianProduct means whether tidb allows cartesian join without equal conditions.

View Source
var DefaultDisabledLogicalRulesList *atomic.Value

DefaultDisabledLogicalRulesList indicates the logical rules which should be banned.

EvalSubquery evaluates incorrelated subqueries once.

View Source
var ForceUseOuterBuild4Test = 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 = false

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

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 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) bool

Cacheable 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 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 CollectPlanStatsVersion

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

CollectPlanStatsVersion uses to collect the statistics version of the plan.

func DeriveOtherConditions

func DeriveOtherConditions(p *LogicalJoin, 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 EncodePlan

func EncodePlan(p Plan) string

EncodePlan is used to encodePlan the plan to the plan tree with compressing.

func EraseLastSemicolon

func EraseLastSemicolon(stmt ast.StmtNode)

EraseLastSemicolon removes last semicolon of 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) []*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 ExtractCorrelatedCols

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

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

func FindColumnInfoByID

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

FindColumnInfoByID finds ColumnInfo in cols by ID.

func GenHintsFromPhysicalPlan

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

GenHintsFromPhysicalPlan generates hints from physical plan.

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 GetPropByOrderByItems

func GetPropByOrderByItems(items []*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 []*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 GetStatsInfo

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

GetStatsInfo gets the statistics info from a physical plan tree.

func GetUpdateColumns

func GetUpdateColumns(ctx sessionctx.Context, orderedList []*expression.Assignment, schemaLen int) ([]bool, error)

GetUpdateColumns gets the columns of updated lists.

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 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 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 IsPointUpdateByAutoCommit

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

IsPointUpdateByAutoCommit checks if plan p is point update and is in autocommit context

func MatchItems

func MatchItems(p *property.PhysicalProperty, items []*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 MockPartitionInfoSchema

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

MockPartitionInfoSchema mocks an info schema for partition table.

func MockSignedTable

func MockSignedTable() *model.TableInfo

MockSignedTable 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 NewPSTMTPlanCacheKey

func NewPSTMTPlanCacheKey(sessionVars *variable.SessionVars, pstmtID uint32, schemaVersion int64) kvcache.Key

NewPSTMTPlanCacheKey creates a new pstmtPlanCacheKey object.

func NewProjInjector

func NewProjInjector() *projInjector

NewProjInjector builds a projInjector.

func NormalizePlan

func NormalizePlan(p Plan) (normalized, digest string)

NormalizePlan is used to normalize the plan and generate plan digest.

func PreparedPlanCacheEnabled

func PreparedPlanCacheEnabled() bool

PreparedPlanCacheEnabled returns whether the prepared plan cache is enabled.

func Preprocess

func Preprocess(ctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema, preprocessOpt ...PreprocessOpt) error

Preprocess resolves table names of the node, and checks some statements validation.

func RemoveUnnecessaryFirstRow

func RemoveUnnecessaryFirstRow(
	sctx sessionctx.Context,
	finalAggFuncs []*aggregation.AggFuncDesc,
	finalGbyItems []expression.Expression,
	partialAggFuncs []*aggregation.AggFuncDesc,
	partialGbyItems []expression.Expression,
	partialSchema *expression.Schema,
	funcMap 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 ResolveExprAndReplace

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

ResolveExprAndReplace replaces columns fields of expressions by children logical plans.

func SetPBColumnsDefaultValue

func SetPBColumnsDefaultValue(ctx sessionctx.Context, pbColumns []*tipb.ColumnInfo, columns []*model.ColumnInfo) error

SetPBColumnsDefaultValue sets the default values of tipb.ColumnInfos.

func SetPreparedPlanCache

func SetPreparedPlanCache(isEnabled bool)

SetPreparedPlanCache sets isEnabled to true, then prepared plan cache is enabled.

func SetPstmtIDSchemaVersion

func SetPstmtIDSchemaVersion(key kvcache.Key, pstmtID uint32, schemaVersion int64)

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) ([]expression.Expression, []expression.Expression)

SplitSelCondsWithVirtualColumn filter the select conditions which contain virtual column

func SupportStreaming

func SupportStreaming(p PhysicalPlan) bool

SupportStreaming returns true if a pushed down operation supports using coprocessor streaming API. Note that this function handle pushed down physical plan only! It's called in constructDAGReq. Some plans are difficult (if possible) to implement streaming, and some are pointless to do so. TODO: Support more kinds of physical plan.

func ToString

func ToString(p Plan) string

ToString explains a Plan, returns description string.

Types

type AdminPlugins

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

AdminPlugins administrates tidb plugins.

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 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) (partial, final *AggInfo, funcMap 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.

type AggregateFuncExtractor

type AggregateFuncExtractor struct {

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

AggregateFuncExtractor visits Expr tree. It converts ColunmNameExpr to AggregateFuncExpr and collects AggregateFuncExpr.

func (*AggregateFuncExtractor) Enter

func (a *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
	// contains filtered or unexported fields
}

Analyze represents an analyze plan

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 {
	PKInfo   *model.ColumnInfo
	ColsInfo []*model.ColumnInfo
	TblInfo  *model.TableInfo
	// contains filtered or unexported fields
}

AnalyzeColumnsTask is used for analyze columns.

type AnalyzeIndexTask

type AnalyzeIndexTask struct {
	IndexInfo *model.IndexInfo
	TblInfo   *model.TableInfo
	// contains filtered or unexported fields
}

AnalyzeIndexTask is used for analyze index.

type BatchPointGetPlan

type BatchPointGetPlan struct {
	TblInfo          *model.TableInfo
	IndexInfo        *model.IndexInfo
	Handles          []int64
	HandleParams     []*driver.ParamMarkerExpr
	IndexValues      [][]types.Datum
	IndexValueParams [][]*driver.ParamMarkerExpr
	PartitionColPos  int
	KeepOrder        bool
	Desc             bool
	Lock             bool
	LockWaitTime     int64
	Columns          []*model.ColumnInfo
	// 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() string

AccessObject implements physicalScan interface.

func (*BatchPointGetPlan) Children

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

Children gets all the children.

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) GetChildReqProps

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

GetChildReqProps gets the required property by child index.

func (*BatchPointGetPlan) GetCost

func (p *BatchPointGetPlan) GetCost(cols []*expression.Column) float64

GetCost returns cost of the PointGetPlan.

func (BatchPointGetPlan) Init

Init initializes 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 (p *BatchPointGetPlan) SetChild(i int, child PhysicalPlan)

SetChild sets a specific child for the plan.

func (*BatchPointGetPlan) SetChildren

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

SetChildren sets the children for the plan.

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 (p *BatchPointGetPlan) ToPB(ctx sessionctx.Context) (*tipb.Executor, error)

ToPB converts physical plan to tipb executor.

type ByItems

type ByItems struct {
	Expr expression.Expression
	Desc bool
}

ByItems wraps a "by" item.

func (*ByItems) Clone

func (by *ByItems) Clone() *ByItems

Clone makes a copy of ByItems.

func (*ByItems) Equal

func (by *ByItems) Equal(ctx sessionctx.Context, other *ByItems) bool

Equal checks whether two ByItems are equal.

func (*ByItems) String

func (by *ByItems) String() string

String implements fmt.Stringer interface.

type CachedPrepareStmt

type CachedPrepareStmt struct {
	PreparedAst    *ast.Prepared
	VisitInfos     []visitInfo
	ColumnInfos    interface{}
	Executor       interface{}
	NormalizedSQL  string
	NormalizedPlan string
	SQLDigest      string
	PlanDigest     string
}

CachedPrepareStmt store prepared ast from PrepareExec and other related fields

type CancelDDLJobs

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

CancelDDLJobs represents a cancel DDL jobs plan.

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) 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 CheckIndex

type CheckIndex struct {
	IndexLookUpReader *PhysicalIndexLookUpReader
	DBName            string
	IdxName           string
	// contains filtered or unexported fields
}

CheckIndex is used for checking index data, built from the 'admin check index' statement.

func (*CheckIndex) OutputNames

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

OutputNames returns the outputting names of each column.

func (*CheckIndex) ResolveIndices

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

func (*CheckIndex) Schema

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

Schema implements the Plan.Schema interface.

func (*CheckIndex) SetOutputNames

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

func (*CheckIndex) SetSchema

func (s *CheckIndex) 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) 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
	// contains filtered or unexported fields
}

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

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) 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) 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

func (*ClusterLogTableExtractor) GetTimeRange

func (e *ClusterLogTableExtractor) GetTimeRange(isFailpointTestModeSkipCheck bool) (int64, int64)

GetTimeRange extract startTime and endTime

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) String

func (cwc *ColWithCmpFuncManager) String() string

String implements Stringer interface.

type DDL

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

DDL represents a DDL statement plan.

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 {
	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
	// contains filtered or unexported fields
}

DataSource represents a tableScan without condition push down.

func (*DataSource) BuildKeyInfo

func (ds *DataSource) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*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(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*DataSource) ExplainInfo

func (p *DataSource) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*DataSource) ExtractCorrelatedCols

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

ExtractCorrelatedCols implements 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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*DataSource) PreparePossibleProperties

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

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*DataSource) PruneColumns

func (ds *DataSource) PruneColumns(parentUsedCols []*expression.Column) 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) 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
	// 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) 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 ErrExprLoc

type ErrExprLoc struct {
	Offset int
	Loc    string
}

ErrExprLoc is for generate the ErrFieldNotInGroupBy error info

type Execute

type Execute struct {
	Name          string
	UsingVars     []expression.Expression
	PrepareParams []types.Datum
	ExecID        uint32
	Stmt          ast.StmtNode
	StmtType      string
	Plan          Plan
	// contains filtered or unexported fields
}

Execute represents prepare plan.

func (*Execute) OptimizePreparedPlan

func (e *Execute) OptimizePreparedPlan(ctx context.Context, sctx sessionctx.Context, is infoschema.InfoSchema) error

OptimizePreparedPlan optimizes the prepared statement.

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

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

Explain represents a explain plan.

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 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 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.

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) 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
	// 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) 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.

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 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 a outer joiner

func (JoinType) String

func (tp JoinType) String() string

type LoadData

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

	GenCols InsertGeneratedColumns
	// contains filtered or unexported fields
}

LoadData represents a loaddata plan.

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) 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 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) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalAggregation) ExplainInfo

func (p *LogicalAggregation) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalAggregation) ExtractCorrelatedCols

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

ExtractCorrelatedCols implements LogicalPlan interface.

func (*LogicalAggregation) GetGroupByCols

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

GetGroupByCols returns the groupByCols. If the groupByCols haven't be collected, this method would collect them at first. If the GroupByItems have been changed, we should explicitly collect GroupByColumns before this method.

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) 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) (ret []expression.Expression, retPlan LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalAggregation) PreparePossibleProperties

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

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalAggregation) PruneColumns

func (la *LogicalAggregation) PruneColumns(parentUsedCols []*expression.Column) 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
}

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) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalApply) ExplainInfo

func (p *LogicalApply) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalApply) ExtractCorrelatedCols

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

ExtractCorrelatedCols implements 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) 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 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, childSchema []*expression.Schema)

BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.

func (*LogicalIndexScan) DeriveStats

func (is *LogicalIndexScan) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema) (*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(schema *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(schema *expression.Schema, childrenProperties ...[][]*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
	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) (*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 Cardinality 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 Cardinality 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) ExtractCorrelatedCols

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

ExtractCorrelatedCols implements LogicalPlan interface.

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)

GetJoinKeys extracts join keys(columns) from EqualConditions.

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) 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) (ret []expression.Expression, retPlan LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalJoin) PreparePossibleProperties

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

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalJoin) PruneColumns

func (p *LogicalJoin) PruneColumns(parentUsedCols []*expression.Column) 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) Children

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

Children implements LogicalPlan Children interface.

func (*LogicalLimit) DeriveStats

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

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalLimit) ExplainInfo

func (p *LogicalLimit) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalLimit) ExtractCorrelatedCols

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

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) MaxOneRow

func (p *LogicalLimit) MaxOneRow() bool

func (*LogicalLimit) OutputNames

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

func (*LogicalLimit) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalLimit) PreparePossibleProperties

func (p *LogicalLimit) PreparePossibleProperties(schema *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalLimit) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalLimit) Schema

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

Schema implements Plan Schema interface.

func (*LogicalLimit) SetChild

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

SetChild implements LogicalPlan SetChild interface.

func (*LogicalLimit) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

func (*LogicalLimit) SetOutputNames

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

type LogicalLock

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

LogicalLock represents a select lock plan.

func (*LogicalLock) BuildKeyInfo

func (p *LogicalLock) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*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, childSchema []*expression.Schema) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalLock) ExplainInfo

func (p *LogicalLock) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalLock) ExtractCorrelatedCols

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

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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan interface.

func (*LogicalLock) PreparePossibleProperties

func (p *LogicalLock) PreparePossibleProperties(schema *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalLock) PruneColumns

func (p *LogicalLock) PruneColumns(parentUsedCols []*expression.Column) 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(selfSchema *expression.Schema, childSchema []*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(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalMaxOneRow) ExplainInfo

func (p *LogicalMaxOneRow) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalMaxOneRow) ExtractCorrelatedCols

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

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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalMaxOneRow) PreparePossibleProperties

func (p *LogicalMaxOneRow) PreparePossibleProperties(schema *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalMaxOneRow) PruneColumns

func (p *LogicalMaxOneRow) PruneColumns(parentUsedCols []*expression.Column) 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
	// 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(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema) (*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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown 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 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) ([]expression.Expression, LogicalPlan)

	// PruneColumns prunes the unused columns.
	PruneColumns([]*expression.Column) 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) (*property.StatsInfo, error)

	// 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)
	// 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.

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/pingcap/tidb/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) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalProjection) ExplainInfo

func (p *LogicalProjection) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalProjection) ExtractCorrelatedCols

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

ExtractCorrelatedCols implements LogicalPlan interface.

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) (ret []expression.Expression, retPlan LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalProjection) PreparePossibleProperties

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

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalProjection) PruneColumns

func (p *LogicalProjection) PruneColumns(parentUsedCols []*expression.Column) 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, selfSchema *expression.Schema, childSchema []*expression.Schema) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalSelection) ExplainInfo

func (p *LogicalSelection) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalSelection) ExtractCorrelatedCols

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

ExtractCorrelatedCols implements LogicalPlan interface.

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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalSelection) PreparePossibleProperties

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

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalSelection) PruneColumns

func (p *LogicalSelection) PruneColumns(parentUsedCols []*expression.Column) 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
	// 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(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema) (*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(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema) (*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 []*ByItems
	// contains filtered or unexported fields
}

LogicalSort stands for the order by plan.

func (*LogicalSort) BuildKeyInfo

func (p *LogicalSort) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*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, childSchema []*expression.Schema) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalSort) ExplainInfo

func (p *LogicalSort) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalSort) ExtractCorrelatedCols

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

ExtractCorrelatedCols implements LogicalPlan interface.

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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan interface.

func (*LogicalSort) PreparePossibleProperties

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

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalSort) PruneColumns

func (ls *LogicalSort) PruneColumns(parentUsedCols []*expression.Column) 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(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema) (*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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalTableDual) PruneColumns

func (p *LogicalTableDual) PruneColumns(parentUsedCols []*expression.Column) 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
	Handle      *expression.Column
	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(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema) (_ *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(schema *expression.Schema, childrenProperties ...[][]*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 []*ByItems
	Offset  uint64
	Count   uint64
	// contains filtered or unexported fields
}

LogicalTopN represents a top-n plan.

func (*LogicalTopN) BuildKeyInfo

func (p *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, selfSchema *expression.Schema, childSchema []*expression.Schema) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalTopN) ExplainInfo

func (p *LogicalTopN) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalTopN) ExtractCorrelatedCols

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

ExtractCorrelatedCols implements LogicalPlan interface.

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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan interface.

func (*LogicalTopN) PreparePossibleProperties

func (p *LogicalTopN) PreparePossibleProperties(schema *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalTopN) PruneColumns

func (lt *LogicalTopN) PruneColumns(parentUsedCols []*expression.Column) 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, childSchema []*expression.Schema) (*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) (ret []expression.Expression, retPlan LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalUnionAll) PruneColumns

func (p *LogicalUnionAll) PruneColumns(parentUsedCols []*expression.Column) 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 only used in non read-only txn.

func (*LogicalUnionScan) BuildKeyInfo

func (p *LogicalUnionScan) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*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, childSchema []*expression.Schema) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats interface.

func (*LogicalUnionScan) ExplainInfo

func (p *LogicalUnionScan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*LogicalUnionScan) ExtractCorrelatedCols

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

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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalUnionScan) PreparePossibleProperties

func (p *LogicalUnionScan) PreparePossibleProperties(schema *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalUnionScan) PruneColumns

func (p *LogicalUnionScan) PruneColumns(parentUsedCols []*expression.Column) 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.Item
	OrderBy         []property.Item
	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, childSchema []*expression.Schema) (*property.StatsInfo, error)

DeriveStats implement LogicalPlan DeriveStats 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) 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) ([]expression.Expression, LogicalPlan)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalWindow) PreparePossibleProperties

func (p *LogicalWindow) PreparePossibleProperties(schema *expression.Schema, childrenProperties ...[][]*expression.Column) [][]*expression.Column

PreparePossibleProperties implements LogicalPlan PreparePossibleProperties interface.

func (*LogicalWindow) PruneColumns

func (p *LogicalWindow) PruneColumns(parentUsedCols []*expression.Column) 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 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    []*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) ExplainInfo

func (p *NominalSort) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*NominalSort) ExplainNormalizedInfo

func (p *NominalSort) ExplainNormalizedInfo() string

ExplainInfo implements Plan 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) 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) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

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) *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 PSTMTPlanCacheValue

type PSTMTPlanCacheValue struct {
	Plan              Plan
	OutPutNames       []*types.FieldName
	TblInfo2UnionScan map[*model.TableInfo]bool
}

PSTMTPlanCacheValue stores the cached Statement and StmtNode.

func NewPSTMTPlanCacheValue

func NewPSTMTPlanCacheValue(plan Plan, names []*types.FieldName, srcMap map[*model.TableInfo]bool) *PSTMTPlanCacheValue

NewPSTMTPlanCacheValue creates a SQLCacheValue.

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

	OuterSchema []*expression.CorrelatedColumn
}

PhysicalApply represents apply plan, only used for subquery.

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) ResolveIndices

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

ResolveIndices implements Plan interface.

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) ExplainInfo

func (p *PhysicalHashAgg) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalHashAgg) ExplainNormalizedInfo

func (p *PhysicalHashAgg) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalHashAgg) GetCost

func (p *PhysicalHashAgg) GetCost(inputRows float64, isRoot bool) 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) ResolveIndices

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

ResolveIndices implements Plan interface.

func (*PhysicalHashAgg) ToPB

func (p *PhysicalHashAgg) ToPB(ctx sessionctx.Context) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalHashJoin

type PhysicalHashJoin struct {
	Concurrency     uint
	EqualConditions []*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) ExplainInfo

func (p *PhysicalHashJoin) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalHashJoin) ExplainNormalizedInfo

func (p *PhysicalHashJoin) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalHashJoin) GetCost

func (p *PhysicalHashJoin) GetCost(lCnt, rCnt float64) float64

GetCost computes cost of hash join operator itself.

func (PhysicalHashJoin) Init

Init initializes PhysicalHashJoin.

func (*PhysicalHashJoin) ResolveIndices

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

ResolveIndices implements Plan 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) GetCost

func (p *PhysicalIndexHashJoin) GetCost(outerTask, innerTask task) float64

GetCost computes the cost of index merge join operator and its children.

func (PhysicalIndexHashJoin) Init

Init initializes PhysicalIndexHashJoin.

type PhysicalIndexJoin

type PhysicalIndexJoin struct {

	// Ranges stores the IndexRanges when the inner plan is index scan.
	Ranges []*ranger.Range
	// 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
	// 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) GetCost

func (p *PhysicalIndexJoin) GetCost(outerTask, innerTask task) float64

GetCost computes the cost of index join operator and its children.

func (PhysicalIndexJoin) Init

Init initializes 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

	ExtraHandleCol *expression.Column
	// PushedLimit is used to avoid unnecessary table scan tasks of IndexLookUpReader.
	PushedLimit *PushedDownLimit
	// contains filtered or unexported fields
}

PhysicalIndexLookUpReader is the index look up reader in tidb. It's used in case of double reading.

func (*PhysicalIndexLookUpReader) ExplainInfo

func (p *PhysicalIndexLookUpReader) ExplainInfo() string

ExplainInfo implements Plan interface.

func (PhysicalIndexLookUpReader) Init

Init initializes 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) GetCost

func (p *PhysicalIndexMergeJoin) GetCost(outerTask, innerTask task) float64

GetCost computes the cost of index merge join operator and its children.

func (PhysicalIndexMergeJoin) Init

Init initializes PhysicalIndexMergeJoin.

type PhysicalIndexMergeReader

type PhysicalIndexMergeReader struct {

	// PartialPlans flats the partialPlans to construct executor pb.
	PartialPlans [][]PhysicalPlan
	// TablePlans flats the tablePlan to construct executor pb.
	TablePlans []PhysicalPlan
	// 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) Init

Init initializes 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
	// contains filtered or unexported fields
}

PhysicalIndexReader is the index reader in tidb.

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) Init

Init initializes 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.TableColumnID]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
	// contains filtered or unexported fields
}

PhysicalIndexScan represents an index scan plan.

func (*PhysicalIndexScan) AccessObject

func (p *PhysicalIndexScan) AccessObject() string

AccessObject implements dataAccesser 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) 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(sc *stmtctx.StatementContext) bool

IsPointGetByUniqueKey checks whether is a point get by unique key.

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) ToPB

func (p *PhysicalIndexScan) ToPB(ctx sessionctx.Context) (*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) Children

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

Children implements PhysicalPlan Children interface.

func (*PhysicalLimit) ExplainInfo

func (p *PhysicalLimit) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalLimit) ExplainNormalizedInfo

func (p *PhysicalLimit) ExplainNormalizedInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalLimit) GetChildReqProps

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

func (PhysicalLimit) Init

Init initializes PhysicalLimit.

func (*PhysicalLimit) ResolveIndices

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

ResolveIndices implements Plan interface.

func (*PhysicalLimit) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalLimit) SetChild

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

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalLimit) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalLimit) StatsCount

func (p *PhysicalLimit) StatsCount() float64

func (*PhysicalLimit) ToPB

func (p *PhysicalLimit) ToPB(ctx sessionctx.Context) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalLock

type PhysicalLock struct {
	Lock ast.SelectLockType

	TblID2Handle     map[int64][]*expression.Column
	PartitionedTable []table.PartitionedTable
	// 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) ExplainInfo

func (p *PhysicalLock) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalLock) ExplainNormalizedInfo

func (p *PhysicalLock) ExplainNormalizedInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalLock) GetChildReqProps

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

func (PhysicalLock) Init

Init initializes 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) (*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) ExplainInfo

func (p *PhysicalMaxOneRow) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalMaxOneRow) ExplainNormalizedInfo

func (p *PhysicalMaxOneRow) ExplainNormalizedInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalMaxOneRow) GetChildReqProps

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

func (PhysicalMaxOneRow) Init

Init initializes 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) (*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() string

AccessObject implements dataAccesser interface.

func (*PhysicalMemTable) ExplainInfo

func (p *PhysicalMemTable) ExplainInfo() string

ExplainInfo implements Plan interface.

func (PhysicalMemTable) Init

Init initializes 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) ExplainInfo

func (p *PhysicalMergeJoin) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalMergeJoin) ExplainNormalizedInfo

func (p *PhysicalMergeJoin) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalMergeJoin) GetCost

func (p *PhysicalMergeJoin) GetCost(lCnt, rCnt float64) float64

GetCost computes cost of merge join operator itself.

func (PhysicalMergeJoin) Init

Init initializes 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) (*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

	// 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
	// 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 InjectProjBelowAgg

func InjectProjBelowAgg(aggPlan PhysicalPlan, aggFuncs []*aggregation.AggFuncDesc, groupByItems []expression.Expression) PhysicalPlan

InjectProjBelowAgg injects a ProjOperator below AggOperator. 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 []*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 TurnNominalSortIntoProj

func TurnNominalSortIntoProj(p PhysicalPlan, onlyColumn bool, orderByItems []*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) ExplainInfo

func (p *PhysicalProjection) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalProjection) ExplainNormalizedInfo

func (p *PhysicalProjection) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan 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) ResolveIndices

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

ResolveIndices implements Plan interface.

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.

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) ExplainInfo

func (p *PhysicalSelection) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalSelection) ExplainNormalizedInfo

func (p *PhysicalSelection) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalSelection) GetChildReqProps

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

func (PhysicalSelection) Init

Init initializes 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) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalShow

type PhysicalShow struct {
	ShowContents
	// contains filtered or unexported fields
}

PhysicalShow represents a show plan.

func (PhysicalShow) Init

Init initializes 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) 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
	Tail        PhysicalPlan
	DataSource  PhysicalPlan

	SplitterType PartitionSplitterType
	HashByItems  []expression.Expression
	// contains filtered or unexported fields
}

PhysicalShuffle represents a shuffle plan. `Tail` and `DataSource` 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) ExplainInfo

func (p *PhysicalShuffle) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalShuffle) ExplainNormalizedInfo

func (p *PhysicalShuffle) ExplainNormalizedInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalShuffle) GetChildReqProps

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

func (PhysicalShuffle) Init

Init initializes 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) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalShuffleDataSourceStub

type PhysicalShuffleDataSourceStub struct {

	// Worker points to `executor.shuffleWorker`.
	Worker unsafe.Pointer
	// contains filtered or unexported fields
}

PhysicalShuffleDataSourceStub represents a data source stub of `PhysicalShuffle`, and actually, is executed by `executor.shuffleWorker`.

func (PhysicalShuffleDataSourceStub) Init

Init initializes PhysicalShuffleDataSourceStub.

func (*PhysicalShuffleDataSourceStub) ResolveIndices

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

func (*PhysicalShuffleDataSourceStub) Schema

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

Schema implements the Plan.Schema interface.

func (*PhysicalShuffleDataSourceStub) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type PhysicalSort

type PhysicalSort struct {
	ByItems []*ByItems
	// 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) ExplainInfo

func (p *PhysicalSort) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalSort) ExplainNormalizedInfo

func (p *PhysicalSort) ExplainNormalizedInfo() string

ExplainInfo implements Plan 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) 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(_ sessionctx.Context) (*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) ExplainInfo

func (p *PhysicalStreamAgg) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalStreamAgg) ExplainNormalizedInfo

func (p *PhysicalStreamAgg) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (*PhysicalStreamAgg) GetCost

func (p *PhysicalStreamAgg) GetCost(inputRows float64, isRoot bool) 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) ResolveIndices

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

ResolveIndices implements Plan interface.

func (*PhysicalStreamAgg) ToPB

func (p *PhysicalStreamAgg) ToPB(ctx sessionctx.Context) (*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) 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
	// contains filtered or unexported fields
}

PhysicalTableReader is the table reader in tidb.

func (*PhysicalTableReader) ExplainInfo

func (p *PhysicalTableReader) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalTableReader) ExplainNormalizedInfo

func (p *PhysicalTableReader) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan interface.

func (PhysicalTableReader) Init

Init initializes PhysicalTableReader.

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 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

	StoreType kv.StoreType

	// KeepOrder is true, if sort data by scanning pkcol,
	KeepOrder bool
	Desc      bool
	// contains filtered or unexported fields
}

PhysicalTableScan represents a table scan plan.

func (*PhysicalTableScan) AccessObject

func (p *PhysicalTableScan) AccessObject() string

AccessObject implements dataAccesser 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) 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) OperatorInfo

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

OperatorInfo implements dataAccesser interface.

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) ToPB

func (p *PhysicalTableScan) ToPB(ctx sessionctx.Context) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalTopN

type PhysicalTopN struct {
	ByItems []*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) ExplainInfo

func (p *PhysicalTopN) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalTopN) ExplainNormalizedInfo

func (p *PhysicalTopN) ExplainNormalizedInfo() string

ExplainNormalizedInfo implements Plan 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) 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) (*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) Init

Init initializes 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

	HandleCol *expression.Column
	// 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) ExplainInfo

func (p *PhysicalUnionScan) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalUnionScan) ExplainNormalizedInfo

func (p *PhysicalUnionScan) ExplainNormalizedInfo() string

ExplainInfo implements Plan interface.

func (*PhysicalUnionScan) GetChildReqProps

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

func (PhysicalUnionScan) Init

Init initializes 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) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalWindow

type PhysicalWindow struct {
	WindowFuncDescs []*aggregation.WindowFuncDesc
	PartitionBy     []property.Item
	OrderBy         []property.Item
	Frame           *WindowFrame
	// contains filtered or unexported fields
}

PhysicalWindow is the physical operator of window function.

func (*PhysicalWindow) ExplainInfo

func (p *PhysicalWindow) ExplainInfo() string

ExplainInfo implements Plan interface.

func (PhysicalWindow) Init

Init initializes 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.

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 BuildLogicalPlan

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

BuildLogicalPlan used to build logical plan from ast.Node.

func TryFastPlan

func TryFastPlan(ctx sessionctx.Context, node ast.Node) 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(sctx sessionctx.Context, is infoschema.InfoSchema, processor *hint.BlockHintProcessor) *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) (LogicalPlan, error)

BuildDataSourceFromView is used to build LogicalPlan from view

func (*PlanBuilder) GetDBTableInfo

func (b *PlanBuilder) GetDBTableInfo() []stmtctx.TableEntry

GetDBTableInfo gets the accessed dbs and tables info.

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) TableHints

func (b *PlanBuilder) TableHints() *tableHintInfo

TableHints returns the *tableHintInfo of PlanBuilder.

type PointGetPlan

type PointGetPlan struct {
	TblInfo          *model.TableInfo
	IndexInfo        *model.IndexInfo
	PartitionInfo    *model.PartitionDefinition
	Handle           int64
	HandleParam      *driver.ParamMarkerExpr
	IndexValues      []types.Datum
	IndexValueParams []*driver.ParamMarkerExpr

	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() string

AccessObject implements dataAccesser interface.

func (*PointGetPlan) Children

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

Children gets all the children.

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) GetChildReqProps

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

GetChildReqProps gets the required property by child index.

func (*PointGetPlan) GetCost

func (p *PointGetPlan) GetCost(cols []*expression.Column) float64

GetCost returns cost of the PointGetPlan.

func (*PointGetPlan) ID

func (p *PointGetPlan) ID() int

ID implements Plan ID interface.

func (PointGetPlan) Init

func (p PointGetPlan) Init(ctx sessionctx.Context, stats *property.StatsInfo, offset int, props ...*property.PhysicalProperty) *PointGetPlan

Init initializes 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 (p *PointGetPlan) SetChild(i int, child PhysicalPlan)

SetChild sets a specific child for the plan.

func (*PointGetPlan) SetChildren

func (p *PointGetPlan) SetChildren(...PhysicalPlan)

SetChildren sets the children for the plan.

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 (p *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 (p *PointGetPlan) ToPB(ctx sessionctx.Context) (*tipb.Executor, error)

ToPB converts physical plan to tipb executor.

type Prepare

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

Prepare represents prepare plan.

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.

type PushedDownLimit

type PushedDownLimit struct {
	Offset uint64
	Count  uint64
}

PushedDownLimit is the limit operator pushed down into PhysicalIndexLookUpReader.

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

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) 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) 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) 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
)

type SQLBindPlan

type SQLBindPlan struct {
	SQLBindOp    SQLBindOpType
	NormdOrigSQL string
	BindSQL      string
	IsGlobal     bool
	BindStmt     ast.StmtNode
	Db           string
	Charset      string
	Collation    string
	// contains filtered or unexported fields
}

SQLBindPlan represents a plan for SQL bind.

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 SelectInto

type SelectInto struct {
	TargetPlan Plan
	IntoOpt    *ast.SelectIntoOption
	// contains filtered or unexported fields
}

SelectInto represents a select-into plan.

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) 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 ShowContents

type ShowContents struct {
	Tp        ast.ShowStmtType // Databases/Tables/Columns/....
	DBName    string
	Table     *ast.TableName  // Used for showing columns.
	Column    *ast.ColumnName // Used for `desc table column`.
	IndexName model.CIStr
	Flag      int                  // Some flag parsed from sql, such as FULL.
	User      *auth.UserIdentity   // Used for show grants.
	Roles     []*auth.RoleIdentity // Used for show grants.

	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 ...`
}

ShowContents stores the contents for the `SHOW` statement.

type ShowDDL

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

ShowDDL is for showing DDL information.

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) 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 ShowNextRowID

type ShowNextRowID struct {
	TableName *ast.TableName
	// contains filtered or unexported fields
}

ShowNextRowID is for showing the next global row ID.

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 ShowSlow

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

ShowSlow is for showing slow queries.

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
	// contains filtered or unexported fields
}

Simple represents a simple statement plan which doesn't need any optimization.

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
	StartTime   time.Time
	EndTime     time.Time
	// 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
	// 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) 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) 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 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.
	HandleOrdinal int
}

TblColPosInfo represents an mapper from column index to handle index.

type TblColPosInfoSlice

type TblColPosInfoSlice []TblColPosInfo

TblColPosInfoSlice attaches the methods of sort.Interface to []TblColPosInfos sorting in increasing order.

func (TblColPosInfoSlice) FindHandle

func (c TblColPosInfoSlice) FindHandle(colOrdinal int) (int, bool)

FindHandle finds the ordinal of the corresponding handle 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 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 (tg *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 (p *TiKVSingleGather) PreparePossibleProperties(schema *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 Trace

type Trace struct {
	StmtNode ast.StmtNode
	Format   string
	// contains filtered or unexported fields
}

Trace represents a trace plan.

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 Update

type Update struct {
	OrderedList []*expression.Assignment

	AllAssignmentsAreConstant bool

	SelectPlan PhysicalPlan

	TblColPosInfos TblColPosInfoSlice
	// 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) 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 WindowFrame

type WindowFrame struct {
	Type  ast.FrameType
	Start *FrameBound
	End   *FrameBound
}

WindowFrame represents a window function frame.

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 (a *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