plan

package
v2.0.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeSel is the type of Selection.
	TypeSel = "Selection"
	// TypeSet is the type of Set.
	TypeSet = "Set"
	// TypeProj is the type of Projection.
	TypeProj = "Projection"
	// TypeAgg is the type of Aggregation.
	TypeAgg = "Aggregation"
	// TypeStreamAgg is the type of StreamAgg.
	TypeStreamAgg = "StreamAgg"
	// TypeHashAgg is the type of HashAgg.
	TypeHashAgg = "HashAgg"
	// TypeShow is the type of show.
	TypeShow = "Show"
	// TypeJoin is the type of Join.
	TypeJoin = "Join"
	// TypeUnion is the type of Union.
	TypeUnion = "Union"
	// TypeTableScan is the type of TableScan.
	TypeTableScan = "TableScan"
	// TypeMemTableScan is the type of TableScan.
	TypeMemTableScan = "MemTableScan"
	// TypeUnionScan is the type of UnionScan.
	TypeUnionScan = "UnionScan"
	// TypeIdxScan is the type of IndexScan.
	TypeIdxScan = "IndexScan"
	// TypeSort is the type of Sort.
	TypeSort = "Sort"
	// TypeTopN is the type of TopN.
	TypeTopN = "TopN"
	// TypeLimit is the type of Limit.
	TypeLimit = "Limit"
	// TypeHashLeftJoin is the type of left hash join.
	TypeHashLeftJoin = "HashLeftJoin"
	// TypeHashRightJoin is the type of right hash join.
	TypeHashRightJoin = "HashRightJoin"
	// TypeMergeJoin is the type of merge join.
	TypeMergeJoin = "MergeJoin"
	// TypeIndexJoin is the type of index look up join.
	TypeIndexJoin = "IndexJoin"
	// TypeApply is the type of Apply.
	TypeApply = "Apply"
	// TypeMaxOneRow is the type of MaxOneRow.
	TypeMaxOneRow = "MaxOneRow"
	// TypeExists is the type of Exists.
	TypeExists = "Exists"
	// TypeDual is the type of TableDual.
	TypeDual = "TableDual"
	// TypeLock is the type of SelectLock.
	TypeLock = "SelectLock"
	// TypeInsert is the type of Insert
	TypeInsert = "Insert"
	// TypeUpdate is the type of Update.
	TypeUpdate = "Update"
	// TypeDelete is the type of Delete.
	TypeDelete = "Delete"
	// TypeIndexLookUp is the type of IndexLookUp.
	TypeIndexLookUp = "IndexLookUp"
	// TypeTableReader is the type of TableReader.
	TypeTableReader = "TableReader"
	// TypeIndexReader is the type of IndexReader.
	TypeIndexReader = "IndexReader"
)
View Source
const (
	// TiDBMergeJoin is hint enforce merge join.
	TiDBMergeJoin = "tidb_smj"
	// TiDBIndexNestedLoopJoin is hint enforce index nested loop join.
	TiDBIndexNestedLoopJoin = "tidb_inlj"
	// TiDBHashJoin is hint enforce hash join.
	TiDBHashJoin = "tidb_hj"
)
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"
)

Variables

View Source
var (
	// GlobalPlanCache stores the global plan cache for every session in a tidb-server.
	GlobalPlanCache *kvcache.ShardedLRUCache

	// PreparedPlanCacheEnabled stores the global config "prepared-plan-cache-enabled".
	PreparedPlanCacheEnabled bool
	// PreparedPlanCacheCapacity stores the global config "prepared-plan-cache-capacity".
	PreparedPlanCacheCapacity uint
)
View Source
var (
	ErrUnsupportedType             = terror.ClassOptimizer.New(codeUnsupportedType, "Unsupported type %T")
	ErrAnalyzeMissIndex            = terror.ClassOptimizer.New(codeAnalyzeMissIndex, "Index '%s' in field list does not exist in table '%s'")
	ErrCartesianProductUnsupported = terror.ClassOptimizer.New(codeUnsupported, "Cartesian product is unsupported")
	ErrStmtNotFound                = terror.ClassOptimizer.New(codeStmtNotFound, "Prepared statement not found")
	ErrWrongParamCount             = terror.ClassOptimizer.New(codeWrongParamCount, "Wrong parameter count")
	ErrSchemaChanged               = terror.ClassOptimizer.New(codeSchemaChanged, "Schema has changed")
	ErrTablenameNotAllowedHere     = terror.ClassOptimizer.New(codeTablenameNotAllowedHere, "Table '%s' from one of the %ss cannot be used in %s")

	ErrWrongUsage                   = terror.ClassOptimizer.New(codeWrongUsage, mysql.MySQLErrName[mysql.ErrWrongUsage])
	ErrAmbiguous                    = terror.ClassOptimizer.New(codeAmbiguous, mysql.MySQLErrName[mysql.ErrNonUniq])
	ErrUnknownColumn                = terror.ClassOptimizer.New(codeUnknownColumn, mysql.MySQLErrName[mysql.ErrBadField])
	ErrUnknownTable                 = terror.ClassOptimizer.New(codeUnknownTable, mysql.MySQLErrName[mysql.ErrUnknownTable])
	ErrWrongArguments               = terror.ClassOptimizer.New(codeWrongArguments, mysql.MySQLErrName[mysql.ErrWrongArguments])
	ErrWrongNumberOfColumnsInSelect = terror.ClassOptimizer.New(codeWrongNumberOfColumnsInSelect, mysql.MySQLErrName[mysql.ErrWrongNumberOfColumnsInSelect])
	ErrBadGeneratedColumn           = terror.ClassOptimizer.New(codeBadGeneratedColumn, mysql.MySQLErrName[mysql.ErrBadGeneratedColumn])
	ErrFieldNotInGroupBy            = terror.ClassOptimizer.New(codeFieldNotInGroupBy, mysql.MySQLErrName[mysql.ErrFieldNotInGroupBy])
	ErrBadTable                     = terror.ClassOptimizer.New(codeBadTable, mysql.MySQLErrName[mysql.ErrBadTable])
	ErrKeyDoesNotExist              = terror.ClassOptimizer.New(codeKeyDoesNotExist, mysql.MySQLErrName[mysql.ErrKeyDoesNotExist])
	ErrOperandColumns               = terror.ClassOptimizer.New(codeOperandColumns, mysql.MySQLErrName[mysql.ErrOperandColumns])
	ErrInvalidWildCard              = terror.ClassOptimizer.New(codeInvalidWildCard, "Wildcard fields without any table name appears in wrong place")
	ErrInvalidGroupFuncUse          = terror.ClassOptimizer.New(codeInvalidGroupFuncUse, mysql.MySQLErrName[mysql.ErrInvalidGroupFuncUse])
	ErrIllegalReference             = terror.ClassOptimizer.New(codeIllegalReference, mysql.MySQLErrName[mysql.ErrIllegalReference])
	ErrNoDB                         = terror.ClassOptimizer.New(codeNoDB, mysql.MySQLErrName[mysql.ErrNoDB])
	ErrUnknownExplainFormat         = terror.ClassOptimizer.New(codeUnknownExplainFormat, mysql.MySQLErrName[mysql.ErrUnknownExplainFormat])
	ErrWrongGroupField              = terror.ClassOptimizer.New(codeWrongGroupField, mysql.MySQLErrName[mysql.ErrWrongGroupField])
	ErrDupFieldName                 = terror.ClassOptimizer.New(codeDupFieldName, mysql.MySQLErrName[mysql.ErrDupFieldName])
	ErrNonUpdatableTable            = terror.ClassOptimizer.New(codeNonUpdatableTable, mysql.MySQLErrName[mysql.ErrNonUpdatableTable])
	ErrInternal                     = terror.ClassOptimizer.New(codeInternal, mysql.MySQLErrName[mysql.ErrInternal])
)

error definitions.

View Source
var AllowCartesianProduct = true

AllowCartesianProduct means whether tidb allows cartesian join without equal conditions.

View Source
var EvalSubquery func(p PhysicalPlan, is infoschema.InfoSchema, ctx sessionctx.Context) ([][]types.Datum, error)

EvalSubquery evaluates incorrelated subqueries once.

View Source
var RatioOfPseudoEstimate = 0.7

RatioOfPseudoEstimate means if modifyCount / statsTblCount is greater than this ratio, we think the stats is invalid and use pseudo estimation.

Functions

func Cacheable

func Cacheable(node ast.Node) bool

Cacheable checks whether the input ast is cacheable.

func ColumnsToProto

func ColumnsToProto(columns []*model.ColumnInfo, pkIsHandle bool) []*tipb.ColumnInfo

ColumnsToProto converts a slice of model.ColumnInfo to a slice of tipb.ColumnInfo.

func IndexToProto

func IndexToProto(t *model.TableInfo, idx *model.IndexInfo) *tipb.IndexInfo

IndexToProto converts a model.IndexInfo to a tipb.IndexInfo.

func NewPSTMTPlanCacheKey

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

NewPSTMTPlanCacheKey creates a new pstmtPlanCacheKey object.

func NewSQLCacheKey

func NewSQLCacheKey(sessionVars *variable.SessionVars, sql string, schemaVersion int64, readOnly bool) kvcache.Key

NewSQLCacheKey creates a new sqlCacheKey object.

func Preprocess

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

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

func SetPBColumnsDefaultValue

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

SetPBColumnsDefaultValue sets the default values of tipb.ColumnInfos.

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

type AggregationType int

AggregationType stands for the mode of aggregation plan.

const (
	// StreamedAgg supposes its input is sorted by group by key.
	StreamedAgg AggregationType = iota
	// FinalAgg supposes its input is partial results.
	FinalAgg
	// CompleteAgg supposes its input is original results.
	CompleteAgg
)

func (AggregationType) String

func (at AggregationType) String() string

String implements fmt.Stringer interface.

type Analyze

type Analyze struct {
	ColTasks []AnalyzeColumnsTask
	IdxTasks []AnalyzeIndexTask
	// contains filtered or unexported fields
}

Analyze represents an analyze plan

func (*Analyze) Schema

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

Schema implements the Plan.Schema interface.

func (*Analyze) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type AnalyzeColumnsTask

type AnalyzeColumnsTask struct {
	TableInfo *model.TableInfo
	PKInfo    *model.ColumnInfo
	ColsInfo  []*model.ColumnInfo
}

AnalyzeColumnsTask is used for analyze columns.

type AnalyzeIndexTask

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

AnalyzeIndexTask is used for analyze index.

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

func (by *ByItems) String() string

String implements fmt.Stringer interface.

type CancelDDLJobs added in v1.0.1

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

CancelDDLJobs represents a cancel DDL jobs plan.

func (*CancelDDLJobs) Schema added in v1.0.1

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

Schema implements the Plan.Schema interface.

func (*CancelDDLJobs) SetSchema added in v1.0.1

func (s *CancelDDLJobs) 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) Schema

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

Schema implements the Plan.Schema interface.

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

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

Schema implements the Plan.Schema interface.

func (*CheckIndexRange) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type CheckTable

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

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

func (*CheckTable) Schema

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

Schema implements the Plan.Schema interface.

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

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

Schema implements the Plan.Schema interface.

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

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

Schema implements the Plan.Schema interface.

func (*CleanupIndex) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type DDL

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

DDL represents a DDL statement plan.

func (*DDL) Schema

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

Schema implements the Plan.Schema interface.

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

	LimitCount *int64
	// contains filtered or unexported fields
}

DataSource represents a tablescan without condition push down.

func (*DataSource) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*DataSource) PruneColumns

func (ds *DataSource) PruneColumns(parentUsedCols []*expression.Column)

PruneColumns implements LogicalPlan interface.

func (*DataSource) Schema

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

Schema implements the Plan.Schema interface.

func (*DataSource) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

func (*DataSource) StatsInfo

func (p *DataSource) StatsInfo() *StatsInfo

StatsInfo implements the Plan.StatsInfo 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) Schema

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

Schema implements the Plan.Schema interface.

func (*Deallocate) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type Delete

type Delete struct {
	Tables       []*ast.TableName
	IsMultiTable bool

	SelectPlan PhysicalPlan
	// contains filtered or unexported fields
}

Delete represents a delete plan.

func (*Delete) Schema

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

Schema implements the Plan.Schema interface.

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
	ExecID    uint32
	Stmt      ast.StmtNode
	Plan      Plan
	// contains filtered or unexported fields
}

Execute represents prepare plan.

func (*Execute) Schema

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

Schema implements the Plan.Schema interface.

func (*Execute) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type Explain

type Explain struct {
	StmtPlan Plan
	Rows     [][]string
	// contains filtered or unexported fields
}

Explain represents a explain plan.

func (*Explain) Schema

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

Schema implements the Plan.Schema interface.

func (*Explain) SetSchema

func (s *Explain) 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

	IsReplace bool
	Priority  mysql.PriorityEnum
	IgnoreErr bool

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

	GenCols InsertGeneratedColumns

	SelectPlan PhysicalPlan
	// contains filtered or unexported fields
}

Insert represents an insert plan.

func (*Insert) ResolveIndices

func (p *Insert) ResolveIndices()

ResolveIndices implements Plan interface.

func (*Insert) Schema

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

Schema implements the Plan.Schema interface.

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

func (tp JoinType) String() string

type LoadData

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

	GenCols InsertGeneratedColumns
	// contains filtered or unexported fields
}

LoadData represents a loaddata plan.

func (*LoadData) Schema

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

Schema implements the Plan.Schema interface.

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

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

Schema implements the Plan.Schema interface.

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

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalAggregation) PruneColumns

func (la *LogicalAggregation) PruneColumns(parentUsedCols []*expression.Column)

PruneColumns implements LogicalPlan interface.

func (*LogicalAggregation) Schema

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

Schema implements the Plan.Schema interface.

func (*LogicalAggregation) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type LogicalApply

type LogicalApply struct {
	LogicalJoin
	// contains filtered or unexported fields
}

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

func (*LogicalApply) PruneColumns

func (la *LogicalApply) PruneColumns(parentUsedCols []*expression.Column)

PruneColumns implements LogicalPlan interface.

func (*LogicalApply) Schema

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

Schema implements the Plan.Schema interface.

func (*LogicalApply) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type LogicalExists

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

LogicalExists checks if a query returns result.

func (*LogicalExists) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalExists) Schema

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

Schema implements the Plan.Schema interface.

func (*LogicalExists) SetSchema

func (s *LogicalExists) 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

	LeftJoinKeys  []*expression.Column
	RightJoinKeys []*expression.Column

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

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalJoin) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalJoin) Schema

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

Schema implements the Plan.Schema interface.

func (*LogicalJoin) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type LogicalLimit

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

LogicalLimit represents offset and limit plan.

func (*LogicalLimit) Children

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

Children implements LogicalPlan Children interface.

func (*LogicalLimit) MaxOneRow

func (p *LogicalLimit) MaxOneRow() bool

func (*LogicalLimit) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalLimit) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalLimit) Schema

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

Schema implements Plan Schema interface.

func (*LogicalLimit) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

type LogicalLock

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

LogicalLock represents a select lock plan.

func (*LogicalLock) Children

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

Children implements LogicalPlan Children interface.

func (*LogicalLock) MaxOneRow

func (p *LogicalLock) MaxOneRow() bool

func (*LogicalLock) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*LogicalLock) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalLock) Schema

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

Schema implements Plan Schema interface.

func (*LogicalLock) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

type LogicalMaxOneRow

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

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

func (*LogicalMaxOneRow) Children

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

Children implements LogicalPlan Children interface.

func (*LogicalMaxOneRow) MaxOneRow

func (p *LogicalMaxOneRow) MaxOneRow() bool

func (*LogicalMaxOneRow) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalMaxOneRow) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalMaxOneRow) Schema

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

Schema implements Plan Schema interface.

func (*LogicalMaxOneRow) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

type LogicalPlan

type LogicalPlan interface {
	Plan

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

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

type LogicalProjection

type LogicalProjection struct {
	Exprs []expression.Expression
	// contains filtered or unexported fields
}

LogicalProjection represents a select fields plan.

func (*LogicalProjection) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalProjection) PruneColumns

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

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

func (*LogicalProjection) Schema

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

Schema implements the Plan.Schema interface.

func (*LogicalProjection) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

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

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

Children implements LogicalPlan Children interface.

func (*LogicalSelection) MaxOneRow

func (p *LogicalSelection) MaxOneRow() bool

func (*LogicalSelection) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalSelection) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalSelection) Schema

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

Schema implements Plan Schema interface.

func (*LogicalSelection) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

type LogicalSort

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

LogicalSort stands for the order by plan.

func (*LogicalSort) Children

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

Children implements LogicalPlan Children interface.

func (*LogicalSort) MaxOneRow

func (p *LogicalSort) MaxOneRow() bool

func (*LogicalSort) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*LogicalSort) PruneColumns

func (ls *LogicalSort) PruneColumns(parentUsedCols []*expression.Column)

PruneColumns implements LogicalPlan interface.

func (*LogicalSort) Schema

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

Schema implements Plan Schema interface.

func (*LogicalSort) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

type LogicalTableDual

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

LogicalTableDual represents a dual table plan.

func (*LogicalTableDual) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalTableDual) Schema

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

Schema implements the Plan.Schema interface.

func (*LogicalTableDual) SetSchema

func (s *LogicalTableDual) 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) Children

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

Children implements LogicalPlan Children interface.

func (*LogicalTopN) MaxOneRow

func (p *LogicalTopN) MaxOneRow() bool

func (*LogicalTopN) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*LogicalTopN) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalTopN) Schema

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

Schema implements Plan Schema interface.

func (*LogicalTopN) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

type LogicalUnionAll

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

LogicalUnionAll represents LogicalUnionAll plan.

func (*LogicalUnionAll) Children

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

Children implements LogicalPlan Children interface.

func (*LogicalUnionAll) MaxOneRow

func (p *LogicalUnionAll) MaxOneRow() bool

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)

PruneColumns implements LogicalPlan interface.

func (*LogicalUnionAll) Schema

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

Schema implements Plan Schema interface.

func (*LogicalUnionAll) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

type LogicalUnionScan

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

LogicalUnionScan is only used in non read-only txn.

func (*LogicalUnionScan) Children

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

Children implements LogicalPlan Children interface.

func (*LogicalUnionScan) MaxOneRow

func (p *LogicalUnionScan) MaxOneRow() bool

func (*LogicalUnionScan) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*LogicalUnionScan) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*LogicalUnionScan) Schema

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

Schema implements Plan Schema interface.

func (*LogicalUnionScan) SetChildren

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

SetChildren implements LogicalPlan SetChildren interface.

type NominalSort

type NominalSort struct {
	// 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.

func (*NominalSort) Children

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

Children implements PhysicalPlan Children interface.

func (*NominalSort) ExplainInfo

func (p *NominalSort) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*NominalSort) ResolveIndices

func (p *NominalSort) ResolveIndices()

ResolveIndices implements Plan interface.

func (*NominalSort) Schema

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

Schema implements Plan Schema interface.

func (*NominalSort) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

func (*NominalSort) ToPB

func (p *NominalSort) ToPB(_ sessionctx.Context) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PSTMTPlanCacheValue

type PSTMTPlanCacheValue struct {
	Plan Plan
}

PSTMTPlanCacheValue stores the cached Statement and StmtNode.

func NewPSTMTPlanCacheValue

func NewPSTMTPlanCacheValue(plan Plan) *PSTMTPlanCacheValue

NewPSTMTPlanCacheValue creates a SQLCacheValue.

type PhysicalApply

type PhysicalApply struct {
	PhysicalJoin *PhysicalHashJoin
	OuterSchema  []*expression.CorrelatedColumn
	// contains filtered or unexported fields
}

PhysicalApply represents apply plan, only used for subquery.

func (*PhysicalApply) ExplainInfo

func (p *PhysicalApply) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalApply) ResolveIndices

func (p *PhysicalApply) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalApply) Schema

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

Schema implements the Plan.Schema interface.

func (*PhysicalApply) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type PhysicalExists

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

PhysicalExists is the physical operator of Exists.

func (*PhysicalExists) ResolveIndices

func (p *PhysicalExists) ResolveIndices()

func (*PhysicalExists) Schema

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

Schema implements the Plan.Schema interface.

func (*PhysicalExists) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type PhysicalHashAgg

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

PhysicalHashAgg is hash operator of aggregate.

func (*PhysicalHashAgg) ExplainInfo

func (p *PhysicalHashAgg) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalHashAgg) ResolveIndices

func (p *PhysicalHashAgg) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalHashAgg) ToPB

ToPB implements PhysicalPlan ToPB interface.

type PhysicalHashJoin

type PhysicalHashJoin struct {
	JoinType JoinType

	EqualConditions []*expression.ScalarFunction
	LeftConditions  []expression.Expression
	RightConditions []expression.Expression
	OtherConditions []expression.Expression
	// InnerChildIdx indicates which child is to build the hash table.
	// For inner join, the smaller one will be chosen.
	// For outer join or semi join, it's exactly the inner one.
	InnerChildIdx int
	Concurrency   uint

	DefaultValues []types.Datum
	// contains filtered or unexported fields
}

PhysicalHashJoin represents hash join for inner/ outer join.

func (*PhysicalHashJoin) ExplainInfo

func (p *PhysicalHashJoin) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalHashJoin) ResolveIndices

func (p *PhysicalHashJoin) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalHashJoin) Schema

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

Schema implements the Plan.Schema interface.

func (*PhysicalHashJoin) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type PhysicalIndexJoin

type PhysicalIndexJoin struct {
	JoinType        JoinType
	OuterJoinKeys   []*expression.Column
	InnerJoinKeys   []*expression.Column
	LeftConditions  expression.CNFExprs
	RightConditions expression.CNFExprs
	OtherConditions expression.CNFExprs
	OuterIndex      int

	DefaultValues []types.Datum

	// Ranges stores the IndexRanges when the inner plan is index scan.
	Ranges []*ranger.NewRange
	// KeyOff2IdxOff maps the offsets in join key to the offsets in the index.
	KeyOff2IdxOff []int
	// contains filtered or unexported fields
}

PhysicalIndexJoin represents the plan of index look up join.

func (*PhysicalIndexJoin) ExplainInfo

func (p *PhysicalIndexJoin) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalIndexJoin) ResolveIndices

func (p *PhysicalIndexJoin) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalIndexJoin) Schema

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

Schema implements the Plan.Schema interface.

func (*PhysicalIndexJoin) SetSchema

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

SetSchema implements the Plan.SetSchema 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
	// 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 PhysicalPlan interface.

func (*PhysicalIndexLookUpReader) ResolveIndices

func (p *PhysicalIndexLookUpReader) ResolveIndices()

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

func (*PhysicalIndexReader) ResolveIndices

func (p *PhysicalIndexReader) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalIndexReader) Schema

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

Schema implements the Plan.Schema interface.

func (*PhysicalIndexReader) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type PhysicalIndexScan

type PhysicalIndexScan struct {

	// AccessCondition is used to calculate range.
	AccessCondition []expression.Expression

	Table     *model.TableInfo
	Index     *model.IndexInfo
	Ranges    []*ranger.NewRange
	Columns   []*model.ColumnInfo
	DBName    model.CIStr
	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

	TableAsName *model.CIStr

	// Hist is the histogram when the query was issued.
	// It is used for query feedback.
	Hist *statistics.Histogram
	// contains filtered or unexported fields
}

PhysicalIndexScan represents an index scan plan.

func (*PhysicalIndexScan) ExplainInfo

func (p *PhysicalIndexScan) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalIndexScan) IsPointGetByUniqueKey

func (p *PhysicalIndexScan) IsPointGetByUniqueKey(sc *stmtctx.StatementContext) bool

IsPointGetByUniqueKey checks whether is a point get by unique key.

func (*PhysicalIndexScan) ResolveIndices

func (p *PhysicalIndexScan) ResolveIndices()

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

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

func (*PhysicalLimit) ResolveIndices

func (p *PhysicalLimit) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalLimit) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalLimit) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalLimit) ToPB

ToPB implements PhysicalPlan ToPB interface.

type PhysicalLock

type PhysicalLock struct {
	Lock ast.SelectLockType
	// 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 PhysicalPlan interface.

func (*PhysicalLock) ResolveIndices

func (p *PhysicalLock) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalLock) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalLock) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

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

func (*PhysicalMaxOneRow) ResolveIndices

func (p *PhysicalMaxOneRow) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalMaxOneRow) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalMaxOneRow) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

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
	Ranges      []ranger.IntColumnRange
	TableAsName *model.CIStr
	// contains filtered or unexported fields
}

PhysicalMemTable reads memory table.

func (*PhysicalMemTable) ResolveIndices

func (p *PhysicalMemTable) ResolveIndices()

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

	LeftConditions  []expression.Expression
	RightConditions []expression.Expression
	OtherConditions []expression.Expression

	DefaultValues []types.Datum

	LeftKeys  []*expression.Column
	RightKeys []*expression.Column
	// contains filtered or unexported fields
}

PhysicalMergeJoin represents merge join for inner/ outer join.

func (*PhysicalMergeJoin) ExplainInfo

func (p *PhysicalMergeJoin) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalMergeJoin) ResolveIndices

func (p *PhysicalMergeJoin) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalMergeJoin) Schema

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

Schema implements the Plan.Schema interface.

func (*PhysicalMergeJoin) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type PhysicalPlan

type PhysicalPlan interface {
	Plan

	// ToPB converts physical plan to tipb executor.
	ToPB(ctx sessionctx.Context) (*tipb.Executor, error)

	// ExplainInfo returns operator information to be explained.
	ExplainInfo() string

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

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

	// ResolveIndices resolves the indices for columns. After doing this, the columns can evaluate the rows by their indices.
	ResolveIndices()
	// contains filtered or unexported methods
}

PhysicalPlan is a tree of the physical operators.

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

func (*PhysicalProjection) ResolveIndices

func (p *PhysicalProjection) ResolveIndices()

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

func (*PhysicalSelection) ResolveIndices

func (p *PhysicalSelection) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalSelection) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalSelection) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalSelection) ToPB

ToPB implements PhysicalPlan ToPB 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 PhysicalPlan interface.

func (*PhysicalSort) ResolveIndices

func (p *PhysicalSort) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalSort) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalSort) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

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

func (*PhysicalStreamAgg) ResolveIndices

func (p *PhysicalStreamAgg) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalStreamAgg) ToPB

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

func (*PhysicalTableDual) ResolveIndices

func (p *PhysicalTableDual) ResolveIndices()

func (*PhysicalTableDual) Schema

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

Schema implements the Plan.Schema interface.

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

PhysicalTableReader is the table reader in tidb.

func (*PhysicalTableReader) ExplainInfo

func (p *PhysicalTableReader) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalTableReader) ResolveIndices

func (p *PhysicalTableReader) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalTableReader) Schema

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

Schema implements the Plan.Schema 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
	Desc    bool
	Ranges  []*ranger.NewRange

	TableAsName *model.CIStr

	// KeepOrder is true, if sort data by scanning pkcol,
	KeepOrder bool

	// Hist is the histogram when the query was issued.
	// It is used for query feedback.
	Hist *statistics.Histogram
	// contains filtered or unexported fields
}

PhysicalTableScan represents a table scan plan.

func (*PhysicalTableScan) ExplainInfo

func (p *PhysicalTableScan) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalTableScan) ResolveIndices

func (p *PhysicalTableScan) ResolveIndices()

func (*PhysicalTableScan) Schema

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

Schema implements the Plan.Schema interface.

func (*PhysicalTableScan) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

func (*PhysicalTableScan) ToPB

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

func (*PhysicalTopN) ResolveIndices

func (p *PhysicalTopN) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalTopN) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalTopN) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

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

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

Children implements PhysicalPlan Children interface.

func (*PhysicalUnionAll) ExplainInfo

func (p *PhysicalUnionAll) ExplainInfo() string

ExplainInfo implements PhysicalPlan interface.

func (*PhysicalUnionAll) ResolveIndices

func (p *PhysicalUnionAll) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalUnionAll) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalUnionAll) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalUnionAll) ToPB

func (p *PhysicalUnionAll) ToPB(_ sessionctx.Context) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type PhysicalUnionScan

type PhysicalUnionScan struct {
	Conditions []expression.Expression
	// 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 PhysicalPlan interface.

func (*PhysicalUnionScan) ResolveIndices

func (p *PhysicalUnionScan) ResolveIndices()

ResolveIndices implements Plan interface.

func (*PhysicalUnionScan) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalUnionScan) SetChildren

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

SetChildren implements PhysicalPlan SetChildren interface.

func (*PhysicalUnionScan) ToPB

func (p *PhysicalUnionScan) ToPB(_ sessionctx.Context) (*tipb.Executor, error)

ToPB implements PhysicalPlan ToPB interface.

type Plan

type Plan interface {
	// Get the schema.
	Schema() *expression.Schema
	// Get the ID.
	ID() int
	// Get the ID in explain statement
	ExplainID() string

	// StatsInfo will return the StatsInfo for this plan.
	StatsInfo() *StatsInfo
	// 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 sessionctx.Context, node ast.Node, is infoschema.InfoSchema) (Plan, error)

BuildLogicalPlan used to build logical plan from ast.Node.

func Optimize

func Optimize(ctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema) (Plan, error)

Optimize does optimization and creates a Plan. The node must be prepared first.

type Prepare

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

Prepare represents prepare plan.

func (*Prepare) Schema

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

Schema implements the Plan.Schema interface.

func (*Prepare) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type Prepared

type Prepared struct {
	Stmt          ast.StmtNode
	Params        []*ast.ParamMarkerExpr
	SchemaVersion int64
	UseCache      bool
}

Prepared represents a prepared statement.

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

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

Schema implements the Plan.Schema interface.

func (*RecoverIndex) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type SQLCacheValue

type SQLCacheValue struct {
	StmtNode  ast.StmtNode
	Plan      Plan
	Expensive bool
}

SQLCacheValue stores the cached Statement and StmtNode.

func NewSQLCacheValue

func NewSQLCacheValue(ast ast.StmtNode, plan Plan, expensive bool) *SQLCacheValue

NewSQLCacheValue creates a SQLCacheValue.

type Set

type Set struct {
	VarAssigns []*expression.VarAssignment
	// contains filtered or unexported fields
}

Set represents a plan for set stmt.

func (*Set) Schema

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

Schema implements the Plan.Schema interface.

func (*Set) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type Show

type Show struct {
	Tp     ast.ShowStmtType // Databases/Tables/Columns/....
	DBName string
	Table  *ast.TableName  // Used for showing columns.
	Column *ast.ColumnName // Used for `desc table column`.
	Flag   int             // Some flag parsed from sql, such as FULL.
	Full   bool
	User   *auth.UserIdentity // Used for show grants.

	Conditions []expression.Expression

	// Used by show variables
	GlobalScope bool
	// contains filtered or unexported fields
}

Show represents a show plan.

func (*Show) ResolveIndices

func (p *Show) ResolveIndices()

ResolveIndices implements Plan interface.

func (*Show) Schema

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

Schema implements the Plan.Schema interface.

func (*Show) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type ShowDDL

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

ShowDDL is for showing DDL information.

func (*ShowDDL) Schema

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

Schema implements the Plan.Schema interface.

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

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

Schema implements the Plan.Schema interface.

func (*ShowDDLJobQueries) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type ShowDDLJobs

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

ShowDDLJobs is for showing DDL job list.

func (*ShowDDLJobs) Schema

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

Schema implements the Plan.Schema interface.

func (*ShowDDLJobs) SetSchema

func (s *ShowDDLJobs) 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) Schema

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

Schema implements the Plan.Schema interface.

func (*ShowNextRowID) SetSchema

func (s *ShowNextRowID) 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) Schema

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

Schema implements the Plan.Schema interface.

func (*Simple) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

type StatsInfo

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

StatsInfo stores the basic information of statistics for the plan's output. It is used for cost estimation.

func (*StatsInfo) Count

func (s *StatsInfo) Count() int64

Count returns the count of the StatsInfo.

func (*StatsInfo) String

func (s *StatsInfo) String() string

String returns the string representation of the StatsInfo.

type Update

type Update struct {
	OrderedList []*expression.Assignment
	IgnoreErr   bool

	SelectPlan PhysicalPlan
	// contains filtered or unexported fields
}

Update represents Update plan.

func (*Update) ResolveIndices

func (p *Update) ResolveIndices()

ResolveIndices implements Plan interface.

func (*Update) Schema

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

Schema implements the Plan.Schema interface.

func (*Update) SetSchema

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

SetSchema implements the Plan.SetSchema interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL