plan

package
v0.0.0-...-ea486a4 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeOperandColumns      terror.ErrCode = 1
	CodeInvalidWildCard     terror.ErrCode = 3
	CodeUnsupported         terror.ErrCode = 4
	CodeInvalidGroupFuncUse terror.ErrCode = 5
	CodeIllegalReference    terror.ErrCode = 6
)

Optimizer error codes.

View Source
const (
	// Sel is the type of Selection.
	Sel = "Selection"
	// St is the type of Set.
	St = "Set"
	// Proj is the type of Projection.
	Proj = "Projection"
	// Agg is the type of Aggregation.
	Agg = "Aggregation"
	// Jn is the type of Join.
	Jn = "Join"
	// Un is the type of Union.
	Un = "Union"
	// Tbl is the type of TableScan.
	Tbl = "TableScan"
	// Idx is the type of IndexScan.
	Idx = "IndexScan"
	// Srt is the type of Sort.
	Srt = "Sort"
	// Lim is the type of Limit.
	Lim = "Limit"
	// App is the type of Apply.
	App = "Apply"
	// MOR is the type of MaxOneRow.
	MOR = "MaxOneRow"
	// Ext is the type of Exists.
	Ext = "Exists"
	// Dual is the type of TableDual.
	Dual = "TableDual"
	// Lock is the type of SelectLock.
	Lock = "SelectLock"
	// Load is the type of LoadData.
	Load = "LoadData"
	// Ins is the type of Insert
	Ins = "Insert"
	// Up is the type of Update.
	Up = "Update"
	// Del is the type of Delete.
	Del = "Delete"
	// Aly is the type of Analyze.
	Aly = "Analyze"
)
View Source
const (
	CodeUnsupportedType terror.ErrCode = 1
	SystemInternalError terror.ErrCode = 2
	CodeAmbiguous       terror.ErrCode = 1052
	CodeUnknownColumn   terror.ErrCode = 1054
	CodeWrongArguments  terror.ErrCode = 1210
)

Error codes.

View Source
const (
	// TiDBMergeJoin is hint enforce merge join
	TiDBMergeJoin = "tidb_smj"
)

Variables

View Source
var (
	ErrOperandColumns              = terror.ClassOptimizer.New(CodeOperandColumns, "Operand should contain %d column(s)")
	ErrInvalidWildCard             = terror.ClassOptimizer.New(CodeInvalidWildCard, "Wildcard fields without any table name appears in wrong place")
	ErrCartesianProductUnsupported = terror.ClassOptimizer.New(CodeUnsupported, "Cartesian product is unsupported")
	ErrInvalidGroupFuncUse         = terror.ClassOptimizer.New(CodeInvalidGroupFuncUse, "Invalid use of group function")
	ErrIllegalReference            = terror.ClassOptimizer.New(CodeIllegalReference, "Illegal reference")
)

Optimizer base errors.

View Source
var (
	ErrUnsupportedType      = terror.ClassOptimizerPlan.New(CodeUnsupportedType, "Unsupported type")
	SystemInternalErrorType = terror.ClassOptimizerPlan.New(SystemInternalError, "System internal error")
	ErrUnknownColumn        = terror.ClassOptimizerPlan.New(CodeUnknownColumn, "Unknown column '%s' in '%s'")
	ErrWrongArguments       = terror.ClassOptimizerPlan.New(CodeWrongArguments, "Incorrect arguments to EXECUTE")
	ErrAmbiguous            = terror.ClassOptimizerPlan.New(CodeAmbiguous, "Column '%s' in field list is ambiguous")
)

Error instances.

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 context.Context) ([][]types.Datum, error)

EvalSubquery evaluates incorrelated subqueries once.

View Source
var JoinConcurrency = 5

JoinConcurrency means the number of goroutines that participate in joining.

Functions

func BuildIndexRange

func BuildIndexRange(sc *variable.StatementContext, p *PhysicalIndexScan) error

BuildIndexRange will build range of index for PhysicalIndexScan

func DetachIndexFilterConditions

func DetachIndexFilterConditions(conditions []expression.Expression, indexColumns []*model.IndexColumn, table *model.TableInfo) ([]expression.Expression, []expression.Expression)

DetachIndexFilterConditions will detach the access conditions from other conditions.

func DetachIndexScanConditions

func DetachIndexScanConditions(conditions []expression.Expression, indexScan *PhysicalIndexScan) ([]expression.Expression, []expression.Expression)

DetachIndexScanConditions will detach the index filters from table filters.

func DetachTableScanConditions

func DetachTableScanConditions(conditions []expression.Expression, table *model.TableInfo) ([]expression.Expression, []expression.Expression)

DetachTableScanConditions distinguishes between access conditions and filter conditions from conditions.

func ExpressionsToPB

func ExpressionsToPB(sc *variable.StatementContext, exprs []expression.Expression, client kv.Client) (pbExpr *tipb.Expr, pushed []expression.Expression, remained []expression.Expression)

ExpressionsToPB converts expression to tipb.Expr.

func InferType

func InferType(sc *variable.StatementContext, node ast.Node) error

InferType infers result type for ast.ExprNode.

func InsertPlan

func InsertPlan(parent Plan, child Plan, insert Plan) error

InsertPlan means inserting plan between two plans.

func MockResolveName

func MockResolveName(node ast.Node, info infoschema.InfoSchema, defaultSchema string, ctx context.Context) error

MockResolveName only serves for test.

func PrepareStmt

func PrepareStmt(is infoschema.InfoSchema, ctx context.Context, node ast.Node) error

PrepareStmt prepares a raw statement parsed from parser. The statement must be prepared before it can be passed to optimize function. We pass InfoSchema instead of getting from Context in case it is changed after resolving name.

func Preprocess

func Preprocess(node ast.Node, info infoschema.InfoSchema, ctx context.Context) error

Preprocess does preprocess work for optimizer.

func RemovePlan

func RemovePlan(p Plan) error

RemovePlan means removing a plan.

func ResolveName

func ResolveName(node ast.Node, info infoschema.InfoSchema, ctx context.Context) error

ResolveName resolves table name and column name. It generates ResultFields for ResultSetNode and resolves ColumnNameExpr to a ResultField.

func ToString

func ToString(p Plan) string

ToString explains a Plan, returns description string.

func Validate

func Validate(node ast.Node, inPrepare bool) error

Validate checkes whether the node is valid.

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 Aggregation

type Aggregation struct {
	AggFuncs     []expression.AggregationFunction
	GroupByItems []expression.Expression
	// contains filtered or unexported fields
}

Aggregation represents an aggregate plan.

func (*Aggregation) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Aggregation) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Aggregation) ResolveIndicesAndCorCols

func (p *Aggregation) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan 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
)

type Analyze

type Analyze struct {
	Table      *ast.TableName
	IdxOffsets []int
	ColOffsets []int
	PkOffset   int // Used only when pk is handle.
	// contains filtered or unexported fields
}

Analyze represents an analyze plan

func (*Analyze) Copy

func (p *Analyze) Copy() PhysicalPlan

Copy implements the Analyze Copy interface.

func (*Analyze) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*Analyze) PruneColumns

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

PruneColumns implements LogicalPlan interface. We should not prune columns for Analyze.

func (*Analyze) ResolveIndicesAndCorCols

func (p *Analyze) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type Apply

type Apply struct {
	Join
	// contains filtered or unexported fields
}

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

func (*Apply) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Apply) ResolveIndicesAndCorCols

func (p *Apply) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type ApplyConditionChecker

type ApplyConditionChecker struct {
	Condition expression.Expression
	All       bool
}

ApplyConditionChecker checks whether all or any output of apply matches a condition.

type ByItems

type ByItems struct {
	Expr expression.Expression
	Desc bool
}

ByItems wraps a "by" item.

func (*ByItems) String

func (by *ByItems) String() string

String implements fmt.Stringer interface.

type Cache

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

Cache plan is a physical plan which stores the result of its child node.

func (*Cache) AddChild

func (p *Cache) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Cache) AddParent

func (p *Cache) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Cache) Allocator

func (p *Cache) Allocator() *idAllocator

func (*Cache) Children

func (p *Cache) Children() []Plan

Children implements Plan Children interface.

func (*Cache) Copy

func (p *Cache) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Cache) ID

func (p *Cache) ID() string

ID implements Plan ID interface.

func (*Cache) MarshalJSON

func (p *Cache) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Cache) Parents

func (p *Cache) Parents() []Plan

Parents implements Plan Parents interface.

func (*Cache) ReplaceChild

func (p *Cache) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*Cache) ReplaceParent

func (p *Cache) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*Cache) Schema

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

Schema implements Plan Schema interface.

func (*Cache) SetChildren

func (p *Cache) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Cache) SetParents

func (p *Cache) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Cache) SetSchema

func (p *Cache) SetSchema(schema *expression.Schema)

SetSchema implements 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) AddChild

func (p *CheckTable) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*CheckTable) AddParent

func (p *CheckTable) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*CheckTable) Allocator

func (p *CheckTable) Allocator() *idAllocator

func (*CheckTable) Children

func (p *CheckTable) Children() []Plan

Children implements Plan Children interface.

func (*CheckTable) ID

func (p *CheckTable) ID() string

ID implements Plan ID interface.

func (*CheckTable) MarshalJSON

func (p *CheckTable) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*CheckTable) Parents

func (p *CheckTable) Parents() []Plan

Parents implements Plan Parents interface.

func (*CheckTable) ReplaceChild

func (p *CheckTable) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*CheckTable) ReplaceParent

func (p *CheckTable) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*CheckTable) Schema

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

Schema implements Plan Schema interface.

func (*CheckTable) SetChildren

func (p *CheckTable) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*CheckTable) SetParents

func (p *CheckTable) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*CheckTable) SetSchema

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

SetSchema implements Plan SetSchema interface.

type DDL

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

DDL represents a DDL statement plan.

func (*DDL) AddChild

func (p *DDL) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*DDL) AddParent

func (p *DDL) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*DDL) Allocator

func (p *DDL) Allocator() *idAllocator

func (*DDL) Children

func (p *DDL) Children() []Plan

Children implements Plan Children interface.

func (*DDL) ID

func (p *DDL) ID() string

ID implements Plan ID interface.

func (*DDL) MarshalJSON

func (p *DDL) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*DDL) Parents

func (p *DDL) Parents() []Plan

Parents implements Plan Parents interface.

func (*DDL) ReplaceChild

func (p *DDL) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*DDL) ReplaceParent

func (p *DDL) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*DDL) Schema

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

Schema implements Plan Schema interface.

func (*DDL) SetChildren

func (p *DDL) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*DDL) SetParents

func (p *DDL) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*DDL) SetSchema

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

SetSchema implements 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 (p *DataSource) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan, error)

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*DataSource) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*DataSource) ResolveIndicesAndCorCols

func (p *DataSource) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type Deallocate

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

Deallocate represents deallocate plan.

func (*Deallocate) AddChild

func (p *Deallocate) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Deallocate) AddParent

func (p *Deallocate) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Deallocate) Allocator

func (p *Deallocate) Allocator() *idAllocator

func (*Deallocate) Children

func (p *Deallocate) Children() []Plan

Children implements Plan Children interface.

func (*Deallocate) ID

func (p *Deallocate) ID() string

ID implements Plan ID interface.

func (*Deallocate) MarshalJSON

func (p *Deallocate) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Deallocate) Parents

func (p *Deallocate) Parents() []Plan

Parents implements Plan Parents interface.

func (*Deallocate) ReplaceChild

func (p *Deallocate) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*Deallocate) ReplaceParent

func (p *Deallocate) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*Deallocate) Schema

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

Schema implements Plan Schema interface.

func (*Deallocate) SetChildren

func (p *Deallocate) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Deallocate) SetParents

func (p *Deallocate) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Deallocate) SetSchema

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

SetSchema implements Plan SetSchema interface.

type Delete

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

Delete represents a delete plan.

func (*Delete) Copy

func (p *Delete) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Delete) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*Delete) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Delete) ResolveIndicesAndCorCols

func (p *Delete) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type Execute

type Execute struct {
	Name      string
	UsingVars []expression.Expression
	ExecID    uint32
	// contains filtered or unexported fields
}

Execute represents prepare plan.

func (*Execute) AddChild

func (p *Execute) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Execute) AddParent

func (p *Execute) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Execute) Allocator

func (p *Execute) Allocator() *idAllocator

func (*Execute) Children

func (p *Execute) Children() []Plan

Children implements Plan Children interface.

func (*Execute) ID

func (p *Execute) ID() string

ID implements Plan ID interface.

func (*Execute) MarshalJSON

func (p *Execute) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Execute) Parents

func (p *Execute) Parents() []Plan

Parents implements Plan Parents interface.

func (*Execute) ReplaceChild

func (p *Execute) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*Execute) ReplaceParent

func (p *Execute) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*Execute) Schema

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

Schema implements Plan Schema interface.

func (*Execute) SetChildren

func (p *Execute) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Execute) SetParents

func (p *Execute) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Execute) SetSchema

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

SetSchema implements Plan SetSchema interface.

type Exists

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

Exists checks if a query returns result.

func (*Exists) Copy

func (p *Exists) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Exists) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*Exists) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Exists) ResolveIndicesAndCorCols

func (p *Exists) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type Explain

type Explain struct {
	StmtPlan Plan
	// contains filtered or unexported fields
}

Explain represents a explain plan.

func (*Explain) AddChild

func (p *Explain) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Explain) AddParent

func (p *Explain) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Explain) Allocator

func (p *Explain) Allocator() *idAllocator

func (*Explain) Children

func (p *Explain) Children() []Plan

Children implements Plan Children interface.

func (*Explain) ID

func (p *Explain) ID() string

ID implements Plan ID interface.

func (*Explain) MarshalJSON

func (p *Explain) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Explain) Parents

func (p *Explain) Parents() []Plan

Parents implements Plan Parents interface.

func (*Explain) ReplaceChild

func (p *Explain) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*Explain) ReplaceParent

func (p *Explain) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*Explain) Schema

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

Schema implements Plan Schema interface.

func (*Explain) SetChildren

func (p *Explain) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Explain) SetParents

func (p *Explain) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Explain) SetSchema

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

SetSchema implements Plan SetSchema interface.

type IndexRange

type IndexRange struct {
	LowVal      []types.Datum
	LowExclude  bool
	HighVal     []types.Datum
	HighExclude bool
}

IndexRange represents an index range to be scanned.

func (*IndexRange) IsPoint

func (ir *IndexRange) IsPoint(sc *variable.StatementContext) bool

IsPoint returns if the index range is a point.

func (*IndexRange) String

func (ir *IndexRange) String() string

type Insert

type Insert struct {
	Table table.Table

	Columns     []*ast.ColumnName
	Lists       [][]expression.Expression
	Setlist     []*expression.Assignment
	OnDuplicate []*expression.Assignment

	IsReplace bool
	Priority  int
	Ignore    bool
	// contains filtered or unexported fields
}

Insert represents an insert plan.

func (*Insert) Copy

func (p *Insert) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Insert) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*Insert) PruneColumns

func (p *Insert) PruneColumns(_ []*expression.Column)

PruneColumns implements LogicalPlan interface.

func (*Insert) ResolveIndicesAndCorCols

func (p *Insert) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type Join

type Join struct {
	JoinType JoinType

	EqualConditions []*expression.ScalarFunction
	LeftConditions  []expression.Expression
	RightConditions []expression.Expression
	OtherConditions []expression.Expression

	// DefaultValues is only used for outer join, which stands for the default values when the outer table cannot find join partner
	// instead of null padding.
	DefaultValues []types.Datum
	// contains filtered or unexported fields
}

Join is the logical join plan.

func (*Join) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Join) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Join) ResolveIndicesAndCorCols

func (p *Join) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan 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
	// LeftOuterSemiJoin means if row a in table A matches some rows in B, output (a, true), otherwise, output (a, false).
	LeftOuterSemiJoin
)

type Limit

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

Limit represents offset and limit plan.

func (*Limit) Copy

func (p *Limit) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Limit) MarshalJSON

func (p *Limit) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Limit) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Limit) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Limit) ResolveIndicesAndCorCols

func (p *Limit) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type LoadData

type LoadData struct {
	IsLocal    bool
	Path       string
	Table      *ast.TableName
	FieldsInfo *ast.FieldsClause
	LinesInfo  *ast.LinesClause
	// contains filtered or unexported fields
}

LoadData represents a loaddata plan.

func (*LoadData) AddChild

func (p *LoadData) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*LoadData) AddParent

func (p *LoadData) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*LoadData) Allocator

func (p *LoadData) Allocator() *idAllocator

func (*LoadData) Children

func (p *LoadData) Children() []Plan

Children implements Plan Children interface.

func (*LoadData) ID

func (p *LoadData) ID() string

ID implements Plan ID interface.

func (*LoadData) MarshalJSON

func (p *LoadData) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*LoadData) Parents

func (p *LoadData) Parents() []Plan

Parents implements Plan Parents interface.

func (*LoadData) ReplaceChild

func (p *LoadData) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*LoadData) ReplaceParent

func (p *LoadData) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*LoadData) Schema

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

Schema implements Plan Schema interface.

func (*LoadData) SetChildren

func (p *LoadData) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*LoadData) SetParents

func (p *LoadData) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*LoadData) SetSchema

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

SetSchema implements Plan SetSchema 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, error)

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

	// ResolveIndicesAndCorCols resolves the index for columns and initializes the correlated columns.
	ResolveIndicesAndCorCols()
	// 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 MaxOneRow

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

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

func (*MaxOneRow) Copy

func (p *MaxOneRow) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*MaxOneRow) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*MaxOneRow) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*MaxOneRow) ResolveIndicesAndCorCols

func (p *MaxOneRow) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type PhysicalAggregation

type PhysicalAggregation struct {
	HasGby       bool
	AggType      AggregationType
	AggFuncs     []expression.AggregationFunction
	GroupByItems []expression.Expression
	// contains filtered or unexported fields
}

PhysicalAggregation is Aggregation's physical plan.

func (*PhysicalAggregation) AddChild

func (p *PhysicalAggregation) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*PhysicalAggregation) AddParent

func (p *PhysicalAggregation) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*PhysicalAggregation) Allocator

func (p *PhysicalAggregation) Allocator() *idAllocator

func (*PhysicalAggregation) Children

func (p *PhysicalAggregation) Children() []Plan

Children implements Plan Children interface.

func (*PhysicalAggregation) Copy

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalAggregation) ID

func (p *PhysicalAggregation) ID() string

ID implements Plan ID interface.

func (*PhysicalAggregation) MarshalJSON

func (p *PhysicalAggregation) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PhysicalAggregation) Parents

func (p *PhysicalAggregation) Parents() []Plan

Parents implements Plan Parents interface.

func (*PhysicalAggregation) ReplaceChild

func (p *PhysicalAggregation) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*PhysicalAggregation) ReplaceParent

func (p *PhysicalAggregation) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*PhysicalAggregation) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalAggregation) SetChildren

func (p *PhysicalAggregation) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalAggregation) SetParents

func (p *PhysicalAggregation) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalAggregation) SetSchema

func (p *PhysicalAggregation) SetSchema(schema *expression.Schema)

SetSchema implements Plan SetSchema interface.

type PhysicalApply

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

PhysicalApply represents apply plan, only used for subquery.

func (*PhysicalApply) AddChild

func (p *PhysicalApply) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*PhysicalApply) AddParent

func (p *PhysicalApply) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*PhysicalApply) Allocator

func (p *PhysicalApply) Allocator() *idAllocator

func (*PhysicalApply) Children

func (p *PhysicalApply) Children() []Plan

Children implements Plan Children interface.

func (*PhysicalApply) Copy

func (p *PhysicalApply) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalApply) ID

func (p *PhysicalApply) ID() string

ID implements Plan ID interface.

func (*PhysicalApply) MarshalJSON

func (p *PhysicalApply) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PhysicalApply) Parents

func (p *PhysicalApply) Parents() []Plan

Parents implements Plan Parents interface.

func (*PhysicalApply) ReplaceChild

func (p *PhysicalApply) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*PhysicalApply) ReplaceParent

func (p *PhysicalApply) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*PhysicalApply) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalApply) SetChildren

func (p *PhysicalApply) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalApply) SetParents

func (p *PhysicalApply) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalApply) SetSchema

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

SetSchema implements Plan SetSchema interface.

type PhysicalDummyScan

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

PhysicalDummyScan is a dummy table that returns nothing.

func (*PhysicalDummyScan) AddChild

func (p *PhysicalDummyScan) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*PhysicalDummyScan) AddParent

func (p *PhysicalDummyScan) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*PhysicalDummyScan) Allocator

func (p *PhysicalDummyScan) Allocator() *idAllocator

func (*PhysicalDummyScan) Children

func (p *PhysicalDummyScan) Children() []Plan

Children implements Plan Children interface.

func (*PhysicalDummyScan) Copy

func (p *PhysicalDummyScan) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalDummyScan) ID

func (p *PhysicalDummyScan) ID() string

ID implements Plan ID interface.

func (*PhysicalDummyScan) MarshalJSON

func (p *PhysicalDummyScan) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PhysicalDummyScan) Parents

func (p *PhysicalDummyScan) Parents() []Plan

Parents implements Plan Parents interface.

func (*PhysicalDummyScan) ReplaceChild

func (p *PhysicalDummyScan) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*PhysicalDummyScan) ReplaceParent

func (p *PhysicalDummyScan) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*PhysicalDummyScan) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalDummyScan) SetChildren

func (p *PhysicalDummyScan) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalDummyScan) SetParents

func (p *PhysicalDummyScan) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalDummyScan) SetSchema

func (p *PhysicalDummyScan) SetSchema(schema *expression.Schema)

SetSchema implements Plan SetSchema interface.

type PhysicalHashJoin

type PhysicalHashJoin struct {
	JoinType JoinType

	EqualConditions []*expression.ScalarFunction
	LeftConditions  []expression.Expression
	RightConditions []expression.Expression
	OtherConditions []expression.Expression
	SmallTable      int
	Concurrency     int

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

PhysicalHashJoin represents hash join for inner/ outer join.

func (*PhysicalHashJoin) AddChild

func (p *PhysicalHashJoin) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*PhysicalHashJoin) AddParent

func (p *PhysicalHashJoin) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*PhysicalHashJoin) Allocator

func (p *PhysicalHashJoin) Allocator() *idAllocator

func (*PhysicalHashJoin) Children

func (p *PhysicalHashJoin) Children() []Plan

Children implements Plan Children interface.

func (*PhysicalHashJoin) Copy

func (p *PhysicalHashJoin) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalHashJoin) ID

func (p *PhysicalHashJoin) ID() string

ID implements Plan ID interface.

func (*PhysicalHashJoin) MarshalJSON

func (p *PhysicalHashJoin) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PhysicalHashJoin) Parents

func (p *PhysicalHashJoin) Parents() []Plan

Parents implements Plan Parents interface.

func (*PhysicalHashJoin) ReplaceChild

func (p *PhysicalHashJoin) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*PhysicalHashJoin) ReplaceParent

func (p *PhysicalHashJoin) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*PhysicalHashJoin) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalHashJoin) SetChildren

func (p *PhysicalHashJoin) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalHashJoin) SetParents

func (p *PhysicalHashJoin) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalHashJoin) SetSchema

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

SetSchema implements Plan SetSchema interface.

type PhysicalHashSemiJoin

type PhysicalHashSemiJoin struct {
	WithAux bool
	Anti    bool

	EqualConditions []*expression.ScalarFunction
	LeftConditions  []expression.Expression
	RightConditions []expression.Expression
	OtherConditions []expression.Expression
	// contains filtered or unexported fields
}

PhysicalHashSemiJoin represents hash join for semi join.

func (*PhysicalHashSemiJoin) AddChild

func (p *PhysicalHashSemiJoin) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*PhysicalHashSemiJoin) AddParent

func (p *PhysicalHashSemiJoin) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*PhysicalHashSemiJoin) Allocator

func (p *PhysicalHashSemiJoin) Allocator() *idAllocator

func (*PhysicalHashSemiJoin) Children

func (p *PhysicalHashSemiJoin) Children() []Plan

Children implements Plan Children interface.

func (*PhysicalHashSemiJoin) Copy

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalHashSemiJoin) ID

func (p *PhysicalHashSemiJoin) ID() string

ID implements Plan ID interface.

func (*PhysicalHashSemiJoin) MarshalJSON

func (p *PhysicalHashSemiJoin) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PhysicalHashSemiJoin) Parents

func (p *PhysicalHashSemiJoin) Parents() []Plan

Parents implements Plan Parents interface.

func (*PhysicalHashSemiJoin) ReplaceChild

func (p *PhysicalHashSemiJoin) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*PhysicalHashSemiJoin) ReplaceParent

func (p *PhysicalHashSemiJoin) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*PhysicalHashSemiJoin) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalHashSemiJoin) SetChildren

func (p *PhysicalHashSemiJoin) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalHashSemiJoin) SetParents

func (p *PhysicalHashSemiJoin) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalHashSemiJoin) SetSchema

func (p *PhysicalHashSemiJoin) SetSchema(schema *expression.Schema)

SetSchema implements Plan SetSchema interface.

type PhysicalIndexScan

type PhysicalIndexScan struct {
	Table      *model.TableInfo
	Index      *model.IndexInfo
	Ranges     []*IndexRange
	Columns    []*model.ColumnInfo
	DBName     model.CIStr
	Desc       bool
	OutOfOrder 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
	// contains filtered or unexported fields
}

PhysicalIndexScan represents an index scan plan.

func (*PhysicalIndexScan) Copy

func (p *PhysicalIndexScan) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalIndexScan) IsPointGetByUniqueKey

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

IsPointGetByUniqueKey checks whether is a point get by unique key.

func (*PhysicalIndexScan) MarshalJSON

func (p *PhysicalIndexScan) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

type PhysicalMemTable

type PhysicalMemTable struct {
	DBName      model.CIStr
	Table       *model.TableInfo
	Columns     []*model.ColumnInfo
	Ranges      []TableRange
	TableAsName *model.CIStr
	// contains filtered or unexported fields
}

PhysicalMemTable reads memory table.

func (*PhysicalMemTable) AddChild

func (p *PhysicalMemTable) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*PhysicalMemTable) AddParent

func (p *PhysicalMemTable) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*PhysicalMemTable) Allocator

func (p *PhysicalMemTable) Allocator() *idAllocator

func (*PhysicalMemTable) Children

func (p *PhysicalMemTable) Children() []Plan

Children implements Plan Children interface.

func (*PhysicalMemTable) Copy

func (p *PhysicalMemTable) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalMemTable) ID

func (p *PhysicalMemTable) ID() string

ID implements Plan ID interface.

func (*PhysicalMemTable) MarshalJSON

func (p *PhysicalMemTable) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PhysicalMemTable) Parents

func (p *PhysicalMemTable) Parents() []Plan

Parents implements Plan Parents interface.

func (*PhysicalMemTable) ReplaceChild

func (p *PhysicalMemTable) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*PhysicalMemTable) ReplaceParent

func (p *PhysicalMemTable) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*PhysicalMemTable) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalMemTable) SetChildren

func (p *PhysicalMemTable) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalMemTable) SetParents

func (p *PhysicalMemTable) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalMemTable) SetSchema

func (p *PhysicalMemTable) SetSchema(schema *expression.Schema)

SetSchema implements Plan SetSchema interface.

type PhysicalMergeJoin

type PhysicalMergeJoin struct {
	JoinType JoinType

	EqualConditions []*expression.ScalarFunction
	LeftConditions  []expression.Expression
	RightConditions []expression.Expression
	OtherConditions []expression.Expression

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

PhysicalMergeJoin represents merge join for inner/ outer join.

func (*PhysicalMergeJoin) AddChild

func (p *PhysicalMergeJoin) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*PhysicalMergeJoin) AddParent

func (p *PhysicalMergeJoin) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*PhysicalMergeJoin) Allocator

func (p *PhysicalMergeJoin) Allocator() *idAllocator

func (*PhysicalMergeJoin) Children

func (p *PhysicalMergeJoin) Children() []Plan

Children implements Plan Children interface.

func (*PhysicalMergeJoin) Copy

func (p *PhysicalMergeJoin) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalMergeJoin) ID

func (p *PhysicalMergeJoin) ID() string

ID implements Plan ID interface.

func (*PhysicalMergeJoin) MarshalJSON

func (p *PhysicalMergeJoin) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PhysicalMergeJoin) Parents

func (p *PhysicalMergeJoin) Parents() []Plan

Parents implements Plan Parents interface.

func (*PhysicalMergeJoin) ReplaceChild

func (p *PhysicalMergeJoin) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*PhysicalMergeJoin) ReplaceParent

func (p *PhysicalMergeJoin) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*PhysicalMergeJoin) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalMergeJoin) SetChildren

func (p *PhysicalMergeJoin) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalMergeJoin) SetParents

func (p *PhysicalMergeJoin) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalMergeJoin) SetSchema

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

SetSchema implements Plan SetSchema interface.

type PhysicalPlan

type PhysicalPlan interface {
	json.Marshaler
	Plan

	// Copy copies the current plan.
	Copy() PhysicalPlan
	// contains filtered or unexported methods
}

PhysicalPlan is a tree of the physical operators.

func EliminateProjection

func EliminateProjection(p PhysicalPlan) PhysicalPlan

EliminateProjection eliminates projection operator to avoid the cost of memory copy in the iterator of projection.

type PhysicalTableScan

type PhysicalTableScan struct {
	Table   *model.TableInfo
	Columns []*model.ColumnInfo
	DBName  model.CIStr
	Desc    bool
	Ranges  []TableRange

	TableAsName *model.CIStr

	// If sort data by scanning pkcol, KeepOrder should be true.
	KeepOrder bool
	// contains filtered or unexported fields
}

PhysicalTableScan represents a table scan plan.

func (*PhysicalTableScan) Copy

func (p *PhysicalTableScan) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalTableScan) MarshalJSON

func (p *PhysicalTableScan) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

type PhysicalUnionScan

type PhysicalUnionScan struct {
	Condition expression.Expression
	// contains filtered or unexported fields
}

PhysicalUnionScan represents a union scan operator.

func (*PhysicalUnionScan) AddChild

func (p *PhysicalUnionScan) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*PhysicalUnionScan) AddParent

func (p *PhysicalUnionScan) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*PhysicalUnionScan) Allocator

func (p *PhysicalUnionScan) Allocator() *idAllocator

func (*PhysicalUnionScan) Children

func (p *PhysicalUnionScan) Children() []Plan

Children implements Plan Children interface.

func (*PhysicalUnionScan) Copy

func (p *PhysicalUnionScan) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*PhysicalUnionScan) ID

func (p *PhysicalUnionScan) ID() string

ID implements Plan ID interface.

func (*PhysicalUnionScan) MarshalJSON

func (p *PhysicalUnionScan) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PhysicalUnionScan) Parents

func (p *PhysicalUnionScan) Parents() []Plan

Parents implements Plan Parents interface.

func (*PhysicalUnionScan) ReplaceChild

func (p *PhysicalUnionScan) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*PhysicalUnionScan) ReplaceParent

func (p *PhysicalUnionScan) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*PhysicalUnionScan) Schema

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

Schema implements Plan Schema interface.

func (*PhysicalUnionScan) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalUnionScan) SetParents

func (p *PhysicalUnionScan) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*PhysicalUnionScan) SetSchema

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

SetSchema implements Plan SetSchema interface.

type Plan

type Plan interface {
	// AddParent means appending a parent for plan.
	AddParent(parent Plan)
	// AddChild means appending a child for plan.
	AddChild(children Plan)
	// ReplaceParent means replacing a parent with another one.
	ReplaceParent(parent, newPar Plan) error
	// ReplaceChild means replacing a child with another one.
	ReplaceChild(children, newChild Plan) error
	// Get all the parents.
	Parents() []Plan
	// Get all the children.
	Children() []Plan
	// Set the schema.
	SetSchema(schema *expression.Schema)
	// Get the schema.
	Schema() *expression.Schema
	// Get the ID.
	ID() string
	// Get id allocator
	Allocator() *idAllocator
	// SetParents sets the parents for the plan.
	SetParents(...Plan)
	// SetParents sets the children for the plan.
	SetChildren(...Plan)
	// 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 Optimize

func Optimize(ctx context.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) AddChild

func (p *Prepare) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Prepare) AddParent

func (p *Prepare) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Prepare) Allocator

func (p *Prepare) Allocator() *idAllocator

func (*Prepare) Children

func (p *Prepare) Children() []Plan

Children implements Plan Children interface.

func (*Prepare) ID

func (p *Prepare) ID() string

ID implements Plan ID interface.

func (*Prepare) MarshalJSON

func (p *Prepare) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Prepare) Parents

func (p *Prepare) Parents() []Plan

Parents implements Plan Parents interface.

func (*Prepare) ReplaceChild

func (p *Prepare) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*Prepare) ReplaceParent

func (p *Prepare) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*Prepare) Schema

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

Schema implements Plan Schema interface.

func (*Prepare) SetChildren

func (p *Prepare) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Prepare) SetParents

func (p *Prepare) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Prepare) SetSchema

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

SetSchema implements Plan SetSchema interface.

type Projection

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

Projection represents a select fields plan.

func (*Projection) Copy

func (p *Projection) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Projection) MarshalJSON

func (p *Projection) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Projection) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Projection) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Projection) ResolveIndicesAndCorCols

func (p *Projection) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type SelectLock

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

SelectLock represents a select lock plan.

func (*SelectLock) Copy

func (p *SelectLock) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*SelectLock) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*SelectLock) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*SelectLock) ResolveIndicesAndCorCols

func (p *SelectLock) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type Selection

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

	// If ScanController is true, then the child of this selection is a scan,
	// which use pk or index. we will record the accessConditions, idxConditions,
	// and tblConditions to control the below plan.
	ScanController bool
	// contains filtered or unexported fields
}

Selection means a filter.

func (*Selection) Copy

func (p *Selection) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Selection) MarshalJSON

func (p *Selection) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Selection) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Selection) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Selection) ResolveIndicesAndCorCols

func (p *Selection) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type Set

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

Set represents a plan for set stmt.

func (*Set) AddChild

func (p *Set) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Set) AddParent

func (p *Set) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Set) Allocator

func (p *Set) Allocator() *idAllocator

func (*Set) Children

func (p *Set) Children() []Plan

Children implements Plan Children interface.

func (*Set) ID

func (p *Set) ID() string

ID implements Plan ID interface.

func (*Set) MarshalJSON

func (p *Set) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Set) Parents

func (p *Set) Parents() []Plan

Parents implements Plan Parents interface.

func (*Set) ReplaceChild

func (p *Set) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*Set) ReplaceParent

func (p *Set) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*Set) Schema

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

Schema implements Plan Schema interface.

func (*Set) SetChildren

func (p *Set) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Set) SetParents

func (p *Set) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Set) SetSchema

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

SetSchema implements 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   string // Used for show grants.

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

Show represents a show plan.

func (*Show) Copy

func (p *Show) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Show) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*Show) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Show) ResolveIndicesAndCorCols

func (p *Show) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type ShowDDL

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

ShowDDL is for showing DDL information.

func (*ShowDDL) AddChild

func (p *ShowDDL) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*ShowDDL) AddParent

func (p *ShowDDL) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*ShowDDL) Allocator

func (p *ShowDDL) Allocator() *idAllocator

func (*ShowDDL) Children

func (p *ShowDDL) Children() []Plan

Children implements Plan Children interface.

func (*ShowDDL) ID

func (p *ShowDDL) ID() string

ID implements Plan ID interface.

func (*ShowDDL) MarshalJSON

func (p *ShowDDL) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*ShowDDL) Parents

func (p *ShowDDL) Parents() []Plan

Parents implements Plan Parents interface.

func (*ShowDDL) ReplaceChild

func (p *ShowDDL) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*ShowDDL) ReplaceParent

func (p *ShowDDL) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*ShowDDL) Schema

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

Schema implements Plan Schema interface.

func (*ShowDDL) SetChildren

func (p *ShowDDL) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*ShowDDL) SetParents

func (p *ShowDDL) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*ShowDDL) SetSchema

func (p *ShowDDL) SetSchema(schema *expression.Schema)

SetSchema implements 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) AddChild

func (p *Simple) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Simple) AddParent

func (p *Simple) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Simple) Allocator

func (p *Simple) Allocator() *idAllocator

func (*Simple) Children

func (p *Simple) Children() []Plan

Children implements Plan Children interface.

func (*Simple) ID

func (p *Simple) ID() string

ID implements Plan ID interface.

func (*Simple) MarshalJSON

func (p *Simple) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Simple) Parents

func (p *Simple) Parents() []Plan

Parents implements Plan Parents interface.

func (*Simple) ReplaceChild

func (p *Simple) ReplaceChild(child, newChild Plan) error

ReplaceChild means replace a child with another one.

func (*Simple) ReplaceParent

func (p *Simple) ReplaceParent(parent, newPar Plan) error

ReplaceParent means replace a parent for another one.

func (*Simple) Schema

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

Schema implements Plan Schema interface.

func (*Simple) SetChildren

func (p *Simple) SetChildren(children ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Simple) SetParents

func (p *Simple) SetParents(pars ...Plan)

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Simple) SetSchema

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

SetSchema implements Plan SetSchema interface.

type Sort

type Sort struct {
	ByItems   []*ByItems
	ExecLimit *Limit
	// contains filtered or unexported fields
}

Sort stands for the order by plan.

func (*Sort) Copy

func (p *Sort) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Sort) MarshalJSON

func (p *Sort) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Sort) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*Sort) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Sort) ResolveIndicesAndCorCols

func (p *Sort) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type TableDual

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

TableDual represents a dual table plan.

func (*TableDual) Copy

func (p *TableDual) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*TableDual) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*TableDual) PruneColumns

func (p *TableDual) PruneColumns(_ []*expression.Column)

PruneColumns implements LogicalPlan interface.

func (*TableDual) ResolveIndicesAndCorCols

func (p *TableDual) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type TableRange

type TableRange struct {
	LowVal  int64
	HighVal int64
}

TableRange represents a range of row handle.

func BuildTableRange

func BuildTableRange(accessConditions []expression.Expression, sc *variable.StatementContext) ([]TableRange, error)

BuildTableRange will build range of pk for PhysicalTableScan

func (*TableRange) IsPoint

func (tr *TableRange) IsPoint() bool

IsPoint returns if the table range is a point.

type Union

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

Union represents Union plan.

func (*Union) Copy

func (p *Union) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Union) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Union) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Union) ResolveIndicesAndCorCols

func (p *Union) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

type Update

type Update struct {
	OrderedList []*expression.Assignment
	// contains filtered or unexported fields
}

Update represents Update plan.

func (*Update) Copy

func (p *Update) Copy() PhysicalPlan

Copy implements the PhysicalPlan Copy interface.

func (*Update) PredicatePushDown

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

PredicatePushDown implements LogicalPlan interface.

func (*Update) PruneColumns

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

PruneColumns implements LogicalPlan interface.

func (*Update) ResolveIndicesAndCorCols

func (p *Update) ResolveIndicesAndCorCols()

ResolveIndicesAndCorCols implements LogicalPlan interface.

Jump to

Keyboard shortcuts

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