plan

package
v0.0.0-...-815d2fd Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2016 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FullRangeCount   = 10000
	HalfRangeCount   = 4000
	MiddleRangeCount = 100
	RowCost          = 1.0
	IndexCost        = 1.1
	SortCost         = 2.0
	FilterRate       = 0.5
)

Pre-defined cost factors.

View Source
const (
	CodeOneColumn           terror.ErrCode = 1
	CodeSameColumns         terror.ErrCode = 2
	CodeMultiWildCard       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"
	// 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"
	// Ts is the type of TableScan.
	Ts = "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"
	// Dis is the type of Distinct.
	Dis = "Distinct"
	// Trm is the type of Trim.
	Trm = "Trim"
	// MOR is the type of MaxOneRow.
	MOR = "MaxOneRow"
	// Ext is the type of Exists.
	Ext = "Exists"
	// Dual is the type of TableDual.
	Dual = "TableDual"
)
View Source
const (
	CodeUnsupportedType terror.ErrCode = 1
	SystemInternalError terror.ErrCode = 2
)

Error codes.

Variables

View Source
var (
	ErrOneColumn           = terror.ClassOptimizer.New(CodeOneColumn, "Operand should contain 1 column(s)")
	ErrSameColumns         = terror.ClassOptimizer.New(CodeSameColumns, "Operands should contain same columns")
	ErrMultiWildCard       = terror.ClassOptimizer.New(CodeMultiWildCard, "wildcard field exist more than once")
	ErrUnSupported         = terror.ClassOptimizer.New(CodeUnsupported, "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")
)

Error instances.

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

EvalSubquery evaluates incorrelated subqueries once.

View Source
var UseNewPlanner = false

UseNewPlanner means if use the new planner.

Functions

func EstimateCost

func EstimateCost(p Plan) float64

EstimateCost estimates the cost of the plan.

func InferType

func InferType(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 Refine

func Refine(p Plan) error

Refine tries to build index or table range.

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 Aggregate

type Aggregate struct {
	AggFuncs     []*ast.AggregateFuncExpr
	GroupByItems []*ast.ByItem
	// contains filtered or unexported fields
}

Aggregate represents a select fields plan.

func (*Aggregate) AddChild

func (p *Aggregate) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Aggregate) AddParent

func (p *Aggregate) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Aggregate) Fields

func (p *Aggregate) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Aggregate) GetChildByIndex

func (p *Aggregate) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Aggregate) GetChildren

func (p *Aggregate) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*Aggregate) GetID

func (p *Aggregate) GetID() string

GetID implements Plan GetID interface.

func (*Aggregate) GetParentByIndex

func (p *Aggregate) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Aggregate) GetParents

func (p *Aggregate) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*Aggregate) GetSchema

func (p *Aggregate) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*Aggregate) IsCorrelated

func (p *Aggregate) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*Aggregate) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*Aggregate) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*Aggregate) RowCount

func (p *Aggregate) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Aggregate) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Aggregate) SetFields

func (p *Aggregate) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Aggregate) SetLimit

func (p *Aggregate) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*Aggregate) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Aggregate) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*Aggregate) StartupCost

func (p *Aggregate) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Aggregate) TotalCost

func (p *Aggregate) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type AggregateFuncExtractor

type AggregateFuncExtractor struct {
	// 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) (node ast.Node, skipChildren bool)

Enter implements Visitor interface.

func (*AggregateFuncExtractor) Leave

func (a *AggregateFuncExtractor) Leave(n ast.Node) (node ast.Node, ok 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) Convert2PhysicalPlan

func (p *Aggregation) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Aggregation) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Aggregation) PruneColumnsAndResolveIndices

func (p *Aggregation) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type Apply

type Apply struct {
	InnerPlan   LogicalPlan
	OuterSchema expression.Schema
	Checker     *ApplyConditionChecker
	// 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) Convert2PhysicalPlan

func (p *Apply) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Apply) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Apply) PruneColumnsAndResolveIndices

func (p *Apply) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface. e.g. For query select b.c, (select count(*) from a where a.id = b.id) from b. Its plan is Projection->Apply->TableScan. The schema of b is (a,b,c,id). When Pruning Apply, the parentUsedCols is (c, extra), outerSchema is (a,b,c,id). Then after pruning inner plan, the childOuterUsedCols schema in apply becomes (id). Now there're two columns in parentUsedCols, c is the column from Apply's child ---- TableScan, but extra isn't. So only c in parentUsedCols and id in outerSchema can be passed to TableScan.

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.

type CheckTable

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

CheckTable is for checking table data.

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

func (p *CheckTable) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*CheckTable) GetChildByIndex

func (p *CheckTable) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*CheckTable) GetChildren

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

GetChildren implements Plan GetChildren interface.

func (*CheckTable) GetID

func (p *CheckTable) GetID() string

GetID implements Plan GetID interface.

func (*CheckTable) GetParentByIndex

func (p *CheckTable) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*CheckTable) GetParents

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

GetParents implements Plan GetParents interface.

func (*CheckTable) GetSchema

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

GetSchema implements Plan GetSchema interface.

func (*CheckTable) IsCorrelated

func (p *CheckTable) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated 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) RowCount

func (p *CheckTable) RowCount() float64

RowCount implements Plan RowCount interface.

func (*CheckTable) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*CheckTable) SetFields

func (p *CheckTable) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*CheckTable) SetLimit

func (p *CheckTable) SetLimit(limit float64)

SetLimit implements Plan SetLimit 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.

func (*CheckTable) StartupCost

func (p *CheckTable) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*CheckTable) TotalCost

func (p *CheckTable) TotalCost() float64

TotalCost implements Plan TotalCost 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) Fields

func (p *DDL) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*DDL) GetChildByIndex

func (p *DDL) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*DDL) GetChildren

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

GetChildren implements Plan GetChildren interface.

func (*DDL) GetID

func (p *DDL) GetID() string

GetID implements Plan GetID interface.

func (*DDL) GetParentByIndex

func (p *DDL) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*DDL) GetParents

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

GetParents implements Plan GetParents interface.

func (*DDL) GetSchema

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

GetSchema implements Plan GetSchema interface.

func (*DDL) IsCorrelated

func (p *DDL) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated 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) RowCount

func (p *DDL) RowCount() float64

RowCount implements Plan RowCount interface.

func (*DDL) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*DDL) SetFields

func (p *DDL) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*DDL) SetLimit

func (p *DDL) SetLimit(limit float64)

SetLimit implements Plan SetLimit 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.

func (*DDL) StartupCost

func (p *DDL) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*DDL) TotalCost

func (p *DDL) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type DataSource

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

	TableAsName *model.CIStr

	LimitCount *int64
	// contains filtered or unexported fields
}

DataSource represents a tablescan without condition push down.

func (*DataSource) Convert2PhysicalPlan

func (p *DataSource) Convert2PhysicalPlan() (np PhysicalPlan)

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*DataSource) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*DataSource) PruneColumnsAndResolveIndices

func (p *DataSource) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices 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) Fields

func (p *Deallocate) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Deallocate) GetChildByIndex

func (p *Deallocate) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Deallocate) GetChildren

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

GetChildren implements Plan GetChildren interface.

func (*Deallocate) GetID

func (p *Deallocate) GetID() string

GetID implements Plan GetID interface.

func (*Deallocate) GetParentByIndex

func (p *Deallocate) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Deallocate) GetParents

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

GetParents implements Plan GetParents interface.

func (*Deallocate) GetSchema

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

GetSchema implements Plan GetSchema interface.

func (*Deallocate) IsCorrelated

func (p *Deallocate) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated 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) RowCount

func (p *Deallocate) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Deallocate) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Deallocate) SetFields

func (p *Deallocate) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Deallocate) SetLimit

func (p *Deallocate) SetLimit(limit float64)

SetLimit implements Plan SetLimit 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.

func (*Deallocate) StartupCost

func (p *Deallocate) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Deallocate) TotalCost

func (p *Deallocate) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Delete

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

Delete represents a delete plan.

func (*Delete) AddChild

func (p *Delete) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Delete) AddParent

func (p *Delete) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Delete) Fields

func (p *Delete) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Delete) GetChildByIndex

func (p *Delete) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Delete) GetChildren

func (p *Delete) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*Delete) GetID

func (p *Delete) GetID() string

GetID implements Plan GetID interface.

func (*Delete) GetParentByIndex

func (p *Delete) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Delete) GetParents

func (p *Delete) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*Delete) GetSchema

func (p *Delete) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*Delete) IsCorrelated

func (p *Delete) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*Delete) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*Delete) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*Delete) RowCount

func (p *Delete) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Delete) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Delete) SetFields

func (p *Delete) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Delete) SetLimit

func (p *Delete) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*Delete) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Delete) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*Delete) StartupCost

func (p *Delete) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Delete) TotalCost

func (p *Delete) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Distinct

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

Distinct represents Distinct plan.

func (*Distinct) Convert2PhysicalPlan

func (p *Distinct) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Distinct) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Distinct) PruneColumnsAndResolveIndices

func (p *Distinct) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

func (*Distinct) SetLimit

func (p *Distinct) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

type Execute

type Execute struct {
	Name      string
	UsingVars []ast.ExprNode
	ID        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) Fields

func (p *Execute) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Execute) GetChildByIndex

func (p *Execute) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Execute) GetChildren

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

GetChildren implements Plan GetChildren interface.

func (*Execute) GetID

func (p *Execute) GetID() string

GetID implements Plan GetID interface.

func (*Execute) GetParentByIndex

func (p *Execute) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Execute) GetParents

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

GetParents implements Plan GetParents interface.

func (*Execute) GetSchema

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

GetSchema implements Plan GetSchema interface.

func (*Execute) IsCorrelated

func (p *Execute) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated 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) RowCount

func (p *Execute) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Execute) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Execute) SetFields

func (p *Execute) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Execute) SetLimit

func (p *Execute) SetLimit(limit float64)

SetLimit implements Plan SetLimit 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.

func (*Execute) StartupCost

func (p *Execute) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Execute) TotalCost

func (p *Execute) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Exists

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

Exists checks if a query returns result.

func (*Exists) Convert2PhysicalPlan

func (p *Exists) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Exists) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Exists) PruneColumnsAndResolveIndices

func (p *Exists) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices 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) Fields

func (p *Explain) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Explain) GetChildByIndex

func (p *Explain) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Explain) GetChildren

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

GetChildren implements Plan GetChildren interface.

func (*Explain) GetID

func (p *Explain) GetID() string

GetID implements Plan GetID interface.

func (*Explain) GetParentByIndex

func (p *Explain) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Explain) GetParents

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

GetParents implements Plan GetParents interface.

func (*Explain) GetSchema

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

GetSchema implements Plan GetSchema interface.

func (*Explain) IsCorrelated

func (p *Explain) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated 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) RowCount

func (p *Explain) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Explain) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Explain) SetFields

func (p *Explain) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Explain) SetLimit

func (p *Explain) SetLimit(limit float64)

SetLimit implements Plan SetLimit 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.

func (*Explain) StartupCost

func (p *Explain) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Explain) TotalCost

func (p *Explain) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Filter

type Filter 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 []ast.ExprNode
	// contains filtered or unexported fields
}

Filter represents a plan that filter GetChildByIndex(0)plan result.

func (*Filter) AddChild

func (p *Filter) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Filter) AddParent

func (p *Filter) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Filter) Fields

func (p *Filter) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Filter) GetChildByIndex

func (p *Filter) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Filter) GetChildren

func (p *Filter) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*Filter) GetID

func (p *Filter) GetID() string

GetID implements Plan GetID interface.

func (*Filter) GetParentByIndex

func (p *Filter) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Filter) GetParents

func (p *Filter) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*Filter) GetSchema

func (p *Filter) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*Filter) IsCorrelated

func (p *Filter) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*Filter) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*Filter) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*Filter) RowCount

func (p *Filter) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Filter) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Filter) SetFields

func (p *Filter) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Filter) SetLimit

func (p *Filter) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*Filter) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Filter) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*Filter) StartupCost

func (p *Filter) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Filter) TotalCost

func (p *Filter) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Having

type Having 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 []ast.ExprNode
	// contains filtered or unexported fields
}

Having represents a having plan. The having plan should after aggregate plan.

func (*Having) AddChild

func (p *Having) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Having) AddParent

func (p *Having) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Having) Fields

func (p *Having) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Having) GetChildByIndex

func (p *Having) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Having) GetChildren

func (p *Having) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*Having) GetID

func (p *Having) GetID() string

GetID implements Plan GetID interface.

func (*Having) GetParentByIndex

func (p *Having) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Having) GetParents

func (p *Having) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*Having) GetSchema

func (p *Having) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*Having) IsCorrelated

func (p *Having) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*Having) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*Having) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*Having) RowCount

func (p *Having) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Having) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Having) SetFields

func (p *Having) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Having) SetLimit

func (p *Having) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*Having) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Having) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*Having) StartupCost

func (p *Having) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Having) TotalCost

func (p *Having) TotalCost() float64

TotalCost implements Plan TotalCost 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() bool

IsPoint returns if the index range is a point.

func (*IndexRange) String

func (ir *IndexRange) String() string

type IndexScan

type IndexScan struct {

	// The index used.
	Index *model.IndexInfo

	// The table to lookup.
	Table *model.TableInfo

	// Ordered and non-overlapping ranges to be scanned.
	Ranges []*IndexRange

	// Desc indicates whether the index should be scanned in descending order.
	Desc bool

	// RefAccess indicates it references a previous joined table, used in explain.
	RefAccess bool

	// AccessConditions can be used to build index range.
	AccessConditions []ast.ExprNode

	// Number of leading equal access condition.
	// The offset of each equal condition correspond to the offset of index column.
	// For example, an index has column (a, b, c), condition is 'a = 0 and b = 0 and c > 0'
	// AccessEqualCount would be 2.
	AccessEqualCount int

	// FilterConditions can be used to filter result.
	FilterConditions []ast.ExprNode

	// OutOfOrder indicates if the index scan can return out of order.
	OutOfOrder bool

	// NoLimit indicates that this plan need fetch all the rows.
	NoLimit bool

	// TableName is used to distinguish the same table selected multiple times in different place,
	// like 'select * from t where exists(select 1 from t as x where t.c < x.c)'
	TableName *ast.TableName

	TableAsName *model.CIStr

	LimitCount *int64
	// contains filtered or unexported fields
}

IndexScan represents an index scan plan.

func (*IndexScan) AddChild

func (p *IndexScan) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*IndexScan) AddParent

func (p *IndexScan) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*IndexScan) Fields

func (p *IndexScan) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*IndexScan) GetChildByIndex

func (p *IndexScan) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*IndexScan) GetChildren

func (p *IndexScan) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*IndexScan) GetID

func (p *IndexScan) GetID() string

GetID implements Plan GetID interface.

func (*IndexScan) GetParentByIndex

func (p *IndexScan) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*IndexScan) GetParents

func (p *IndexScan) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*IndexScan) GetSchema

func (p *IndexScan) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*IndexScan) IsCorrelated

func (p *IndexScan) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*IndexScan) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*IndexScan) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*IndexScan) RowCount

func (p *IndexScan) RowCount() float64

RowCount implements Plan RowCount interface.

func (*IndexScan) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*IndexScan) SetFields

func (p *IndexScan) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*IndexScan) SetLimit

func (p *IndexScan) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*IndexScan) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*IndexScan) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*IndexScan) StartupCost

func (p *IndexScan) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*IndexScan) TotalCost

func (p *IndexScan) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Insert

type Insert struct {
	Table       *ast.TableRefsClause
	Columns     []*ast.ColumnName
	Lists       [][]ast.ExprNode
	Setlist     []*ast.Assignment
	OnDuplicate []*ast.Assignment
	SelectPlan  Plan

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

Insert represents an insert plan.

func (*Insert) Convert2PhysicalPlan

func (p *Insert) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Insert) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Insert) PruneColumnsAndResolveIndices

func (p *Insert) PruneColumnsAndResolveIndices(_ []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type Join

type Join struct {
	JoinType JoinType

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

Join is the logical join plan.

func (*Join) Convert2PhysicalPlan

func (p *Join) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Join) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Join) PruneColumnsAndResolveIndices

func (p *Join) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type JoinInner

type JoinInner struct {
	Inners     []Plan
	Conditions []ast.ExprNode
	// contains filtered or unexported fields
}

JoinInner represents inner join plan.

func (*JoinInner) AddChild

func (p *JoinInner) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*JoinInner) AddParent

func (p *JoinInner) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*JoinInner) Fields

func (p *JoinInner) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*JoinInner) GetChildByIndex

func (p *JoinInner) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*JoinInner) GetChildren

func (p *JoinInner) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*JoinInner) GetID

func (p *JoinInner) GetID() string

GetID implements Plan GetID interface.

func (*JoinInner) GetParentByIndex

func (p *JoinInner) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*JoinInner) GetParents

func (p *JoinInner) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*JoinInner) GetSchema

func (p *JoinInner) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*JoinInner) IsCorrelated

func (p *JoinInner) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*JoinInner) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*JoinInner) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*JoinInner) RowCount

func (p *JoinInner) RowCount() float64

RowCount implements Plan RowCount interface.

func (*JoinInner) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*JoinInner) SetFields

func (p *JoinInner) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*JoinInner) SetLimit

func (p *JoinInner) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*JoinInner) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*JoinInner) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*JoinInner) StartupCost

func (p *JoinInner) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*JoinInner) String

func (p *JoinInner) String() string

func (*JoinInner) TotalCost

func (p *JoinInner) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type JoinOuter

type JoinOuter struct {
	Outer Plan
	Inner Plan
	// contains filtered or unexported fields
}

JoinOuter represents outer join plan.

func (*JoinOuter) AddChild

func (p *JoinOuter) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*JoinOuter) AddParent

func (p *JoinOuter) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*JoinOuter) Fields

func (p *JoinOuter) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*JoinOuter) GetChildByIndex

func (p *JoinOuter) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*JoinOuter) GetChildren

func (p *JoinOuter) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*JoinOuter) GetID

func (p *JoinOuter) GetID() string

GetID implements Plan GetID interface.

func (*JoinOuter) GetParentByIndex

func (p *JoinOuter) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*JoinOuter) GetParents

func (p *JoinOuter) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*JoinOuter) GetSchema

func (p *JoinOuter) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*JoinOuter) IsCorrelated

func (p *JoinOuter) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*JoinOuter) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*JoinOuter) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*JoinOuter) RowCount

func (p *JoinOuter) RowCount() float64

RowCount implements Plan RowCount interface.

func (*JoinOuter) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*JoinOuter) SetFields

func (p *JoinOuter) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*JoinOuter) SetLimit

func (p *JoinOuter) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*JoinOuter) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*JoinOuter) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*JoinOuter) StartupCost

func (p *JoinOuter) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*JoinOuter) TotalCost

func (p *JoinOuter) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type JoinType

type JoinType int

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

const (
	// CrossJoin means Cartesian Product, but not used now.
	CrossJoin JoinType = iota
	// InnerJoin means inner join.
	InnerJoin
	// 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
	// SemiJoinWithAux means if row a in table A matches some rows in B, output (a, true), otherwise, output (a, false).
	SemiJoinWithAux
)

type Limit

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

Limit represents offset and limit plan.

func (*Limit) Convert2PhysicalPlan

func (p *Limit) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Limit) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Limit) PruneColumnsAndResolveIndices

func (p *Limit) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

func (*Limit) SetLimit

func (p *Limit) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface. As Limit itself determine the real limit, We just ignore the input, and set the real limit.

type LogicalPlan

type LogicalPlan interface {
	Plan

	// PredicatePushDown push down predicates in where/on/having clause as deeply as possible.
	// It will accept a predicate that is a expression slice, and return the expressions that can't be pushed.
	// Because it may change the root when exists having clause, we need return a plan that representing a new root.
	PredicatePushDown([]expression.Expression) ([]expression.Expression, LogicalPlan, error)

	// PruneColumnsAndResolveIndices prunes unused columns and resolves index for columns.
	// This function returns a column slice representing columns from outer env and an error.
	// We need return outer columns, because Apply plan will prune inner Planner and it will know
	// how many columns referenced by inner plan exactly.
	PruneColumnsAndResolveIndices([]*expression.Column) ([]*expression.Column, error)

	// Convert2PhysicalPlan converts logical plan to physical plan.
	Convert2PhysicalPlan() PhysicalPlan
}

LogicalPlan is a tree of logical operators. We can do a lot of logical optimization to it, like predicate push down 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) Convert2PhysicalPlan

func (p *MaxOneRow) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*MaxOneRow) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*MaxOneRow) PruneColumnsAndResolveIndices

func (p *MaxOneRow) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type NewSort

type NewSort struct {
	ByItems []*ByItems

	ExecLimit *Limit
	// contains filtered or unexported fields
}

NewSort stands for the order by plan.

func (*NewSort) Convert2PhysicalPlan

func (p *NewSort) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*NewSort) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*NewSort) PruneColumnsAndResolveIndices

func (p *NewSort) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type NewTableDual

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

NewTableDual represents a dual table plan.

func (*NewTableDual) Convert2PhysicalPlan

func (p *NewTableDual) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*NewTableDual) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*NewTableDual) PruneColumnsAndResolveIndices

func (p *NewTableDual) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type NewUnion

type NewUnion struct {
	Selects []LogicalPlan
	// contains filtered or unexported fields
}

NewUnion represents Union plan.

func (*NewUnion) Convert2PhysicalPlan

func (p *NewUnion) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*NewUnion) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*NewUnion) PruneColumnsAndResolveIndices

func (p *NewUnion) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type PhysicalApply

type PhysicalApply struct {
	InnerPlan   PhysicalPlan
	OuterSchema expression.Schema
	Checker     *ApplyConditionChecker
	// contains filtered or unexported fields
}

PhysicalApply represents apply plan, only used for subquery.

type PhysicalHashJoin

type PhysicalHashJoin struct {
	JoinType JoinType

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

PhysicalHashJoin represents hash join for inner/ outer join.

type PhysicalHashSemiJoin

type PhysicalHashSemiJoin struct {
	WithAux 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.

type PhysicalIndexScan

type PhysicalIndexScan struct {
	Table      *model.TableInfo
	Index      *model.IndexInfo
	Ranges     []*IndexRange
	Columns    []*model.ColumnInfo
	DBName     *model.CIStr
	Desc       bool
	OutOfOrder bool

	AccessCondition []expression.Expression

	TableAsName *model.CIStr

	LimitCount *int64
	// contains filtered or unexported fields
}

PhysicalIndexScan represents an index scan plan.

type PhysicalPlan

type PhysicalPlan interface {
	Plan
}

PhysicalPlan is a tree of physical operators.

type PhysicalTableScan

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

	AccessCondition []expression.Expression

	TableAsName *model.CIStr

	LimitCount *int64
	// contains filtered or unexported fields
}

PhysicalTableScan represents a table scan plan.

func (*PhysicalTableScan) Convert2PhysicalPlan

func (p *PhysicalTableScan) Convert2PhysicalPlan() PhysicalPlan

func (*PhysicalTableScan) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*PhysicalTableScan) PruneColumnsAndResolveIndices

func (p *PhysicalTableScan) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type Plan

type Plan interface {
	// Fields returns the result fields of the plan.
	Fields() []*ast.ResultField
	// SetFields sets the results fields of the plan.
	SetFields(fields []*ast.ResultField)
	// The cost before returning fhe first row.
	StartupCost() float64
	// The cost after returning all the rows.
	TotalCost() float64
	// The expected row count.
	RowCount() float64
	// SetLimit is used to push limit to upstream to estimate the cost.
	SetLimit(limit float64)
	// AddParent means append a parent for plan.
	AddParent(parent Plan)
	// AddChild means append a child for plan.
	AddChild(children Plan)
	// ReplaceParent means replace a parent with another one.
	ReplaceParent(parent, newPar Plan) error
	// ReplaceChild means replace a child with another one.
	ReplaceChild(children, newChild Plan) error
	// Retrieve parent by index.
	GetParentByIndex(index int) Plan
	// Retrieve child by index.
	GetChildByIndex(index int) Plan
	// Get all the parents.
	GetParents() []Plan
	// Get all the children.
	GetChildren() []Plan
	// Set the schema.
	SetSchema(schema expression.Schema)
	// Get the schema.
	GetSchema() expression.Schema
	// Get ID.
	GetID() string
	// Check weather this plan is correlated or not.
	IsCorrelated() bool
	// SetParents sets parents for plan.
	SetParents(...Plan)
	// SetParents sets children for plan.
	SetChildren(...Plan)
}

Plan is a description of an execution flow. It is created from ast.Node first, then optimized by optimizer, then used by executor to create a Cursor which executes the statement.

func BuildPlan

func BuildPlan(node ast.Node, sb SubQueryBuilder) (Plan, error)

BuildPlan builds a plan from a node. It returns ErrUnsupportedType if ast.Node type is not supported yet.

func Optimize

func Optimize(ctx context.Context, node ast.Node, sb SubQueryBuilder, 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) Fields

func (p *Prepare) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Prepare) GetChildByIndex

func (p *Prepare) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Prepare) GetChildren

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

GetChildren implements Plan GetChildren interface.

func (*Prepare) GetID

func (p *Prepare) GetID() string

GetID implements Plan GetID interface.

func (*Prepare) GetParentByIndex

func (p *Prepare) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Prepare) GetParents

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

GetParents implements Plan GetParents interface.

func (*Prepare) GetSchema

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

GetSchema implements Plan GetSchema interface.

func (*Prepare) IsCorrelated

func (p *Prepare) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated 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) RowCount

func (p *Prepare) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Prepare) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Prepare) SetFields

func (p *Prepare) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Prepare) SetLimit

func (p *Prepare) SetLimit(limit float64)

SetLimit implements Plan SetLimit 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.

func (*Prepare) StartupCost

func (p *Prepare) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Prepare) TotalCost

func (p *Prepare) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Projection

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

Projection represents a select fields plan.

func (*Projection) Convert2PhysicalPlan

func (p *Projection) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan 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) PruneColumnsAndResolveIndices

func (p *Projection) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type SelectFields

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

SelectFields represents a select fields plan.

func (*SelectFields) AddChild

func (p *SelectFields) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*SelectFields) AddParent

func (p *SelectFields) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*SelectFields) Fields

func (p *SelectFields) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*SelectFields) GetChildByIndex

func (p *SelectFields) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*SelectFields) GetChildren

func (p *SelectFields) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*SelectFields) GetID

func (p *SelectFields) GetID() string

GetID implements Plan GetID interface.

func (*SelectFields) GetParentByIndex

func (p *SelectFields) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*SelectFields) GetParents

func (p *SelectFields) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*SelectFields) GetSchema

func (p *SelectFields) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*SelectFields) IsCorrelated

func (p *SelectFields) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*SelectFields) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*SelectFields) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*SelectFields) RowCount

func (p *SelectFields) RowCount() float64

RowCount implements Plan RowCount interface.

func (*SelectFields) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*SelectFields) SetFields

func (p *SelectFields) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*SelectFields) SetLimit

func (p *SelectFields) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*SelectFields) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*SelectFields) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*SelectFields) StartupCost

func (p *SelectFields) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*SelectFields) TotalCost

func (p *SelectFields) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type SelectLock

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

SelectLock represents a select lock plan.

func (*SelectLock) AddChild

func (p *SelectLock) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*SelectLock) AddParent

func (p *SelectLock) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*SelectLock) Fields

func (p *SelectLock) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*SelectLock) GetChildByIndex

func (p *SelectLock) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*SelectLock) GetChildren

func (p *SelectLock) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*SelectLock) GetID

func (p *SelectLock) GetID() string

GetID implements Plan GetID interface.

func (*SelectLock) GetParentByIndex

func (p *SelectLock) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*SelectLock) GetParents

func (p *SelectLock) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*SelectLock) GetSchema

func (p *SelectLock) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*SelectLock) IsCorrelated

func (p *SelectLock) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*SelectLock) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*SelectLock) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*SelectLock) RowCount

func (p *SelectLock) RowCount() float64

RowCount implements Plan RowCount interface.

func (*SelectLock) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*SelectLock) SetFields

func (p *SelectLock) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*SelectLock) SetLimit

func (p *SelectLock) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*SelectLock) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*SelectLock) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*SelectLock) StartupCost

func (p *SelectLock) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*SelectLock) TotalCost

func (p *SelectLock) TotalCost() float64

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

Selection means a filter.

func (*Selection) Convert2PhysicalPlan

func (p *Selection) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Selection) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Selection) PruneColumnsAndResolveIndices

func (p *Selection) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices 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) AddChild

func (p *Show) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Show) AddParent

func (p *Show) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Show) Fields

func (p *Show) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Show) GetChildByIndex

func (p *Show) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Show) GetChildren

func (p *Show) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*Show) GetID

func (p *Show) GetID() string

GetID implements Plan GetID interface.

func (*Show) GetParentByIndex

func (p *Show) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Show) GetParents

func (p *Show) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*Show) GetSchema

func (p *Show) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*Show) IsCorrelated

func (p *Show) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*Show) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*Show) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*Show) RowCount

func (p *Show) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Show) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Show) SetFields

func (p *Show) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Show) SetLimit

func (p *Show) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*Show) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Show) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*Show) StartupCost

func (p *Show) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Show) TotalCost

func (p *Show) TotalCost() float64

TotalCost implements Plan TotalCost 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) Fields

func (p *ShowDDL) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*ShowDDL) GetChildByIndex

func (p *ShowDDL) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*ShowDDL) GetChildren

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

GetChildren implements Plan GetChildren interface.

func (*ShowDDL) GetID

func (p *ShowDDL) GetID() string

GetID implements Plan GetID interface.

func (*ShowDDL) GetParentByIndex

func (p *ShowDDL) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*ShowDDL) GetParents

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

GetParents implements Plan GetParents interface.

func (*ShowDDL) GetSchema

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

GetSchema implements Plan GetSchema interface.

func (*ShowDDL) IsCorrelated

func (p *ShowDDL) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated 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) RowCount

func (p *ShowDDL) RowCount() float64

RowCount implements Plan RowCount interface.

func (*ShowDDL) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*ShowDDL) SetFields

func (p *ShowDDL) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*ShowDDL) SetLimit

func (p *ShowDDL) SetLimit(limit float64)

SetLimit implements Plan SetLimit 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.

func (*ShowDDL) StartupCost

func (p *ShowDDL) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*ShowDDL) TotalCost

func (p *ShowDDL) TotalCost() float64

TotalCost implements Plan TotalCost 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) Fields

func (p *Simple) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Simple) GetChildByIndex

func (p *Simple) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Simple) GetChildren

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

GetChildren implements Plan GetChildren interface.

func (*Simple) GetID

func (p *Simple) GetID() string

GetID implements Plan GetID interface.

func (*Simple) GetParentByIndex

func (p *Simple) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Simple) GetParents

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

GetParents implements Plan GetParents interface.

func (*Simple) GetSchema

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

GetSchema implements Plan GetSchema interface.

func (*Simple) IsCorrelated

func (p *Simple) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated 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) RowCount

func (p *Simple) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Simple) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Simple) SetFields

func (p *Simple) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Simple) SetLimit

func (p *Simple) SetLimit(limit float64)

SetLimit implements Plan SetLimit 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.

func (*Simple) StartupCost

func (p *Simple) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Simple) TotalCost

func (p *Simple) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Sort

type Sort struct {
	ByItems []*ast.ByItem

	ExecLimit *Limit
	// contains filtered or unexported fields
}

Sort represents a sorting plan.

func (*Sort) AddChild

func (p *Sort) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Sort) AddParent

func (p *Sort) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Sort) Fields

func (p *Sort) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Sort) GetChildByIndex

func (p *Sort) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Sort) GetChildren

func (p *Sort) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*Sort) GetID

func (p *Sort) GetID() string

GetID implements Plan GetID interface.

func (*Sort) GetParentByIndex

func (p *Sort) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Sort) GetParents

func (p *Sort) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*Sort) GetSchema

func (p *Sort) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*Sort) IsCorrelated

func (p *Sort) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*Sort) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*Sort) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*Sort) RowCount

func (p *Sort) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Sort) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Sort) SetFields

func (p *Sort) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Sort) SetLimit

func (p *Sort) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface. It set the Src limit only if it is bypassed. Bypass has to be determined before this get called.

func (*Sort) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Sort) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*Sort) StartupCost

func (p *Sort) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Sort) TotalCost

func (p *Sort) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type SubQueryBuilder

type SubQueryBuilder interface {
	Build(p Plan) ast.SubqueryExec
}

SubQueryBuilder is the interface for building SubQuery executor.

type TableDual

type TableDual struct {
	HasAgg bool
	// FilterConditions can be used to filter result.
	FilterConditions []ast.ExprNode
	// contains filtered or unexported fields
}

TableDual represents a dual table plan.

func (*TableDual) AddChild

func (p *TableDual) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*TableDual) AddParent

func (p *TableDual) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*TableDual) Fields

func (p *TableDual) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*TableDual) GetChildByIndex

func (p *TableDual) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*TableDual) GetChildren

func (p *TableDual) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*TableDual) GetID

func (p *TableDual) GetID() string

GetID implements Plan GetID interface.

func (*TableDual) GetParentByIndex

func (p *TableDual) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*TableDual) GetParents

func (p *TableDual) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*TableDual) GetSchema

func (p *TableDual) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*TableDual) IsCorrelated

func (p *TableDual) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*TableDual) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*TableDual) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*TableDual) RowCount

func (p *TableDual) RowCount() float64

RowCount implements Plan RowCount interface.

func (*TableDual) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*TableDual) SetFields

func (p *TableDual) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*TableDual) SetLimit

func (p *TableDual) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*TableDual) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*TableDual) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*TableDual) StartupCost

func (p *TableDual) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*TableDual) TotalCost

func (p *TableDual) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type TableRange

type TableRange struct {
	LowVal  int64
	HighVal int64
}

TableRange represents a range of row handle.

type TableScan

type TableScan struct {
	Table  *model.TableInfo
	Desc   bool
	Ranges []TableRange

	// RefAccess indicates it references a previous joined table, used in explain.
	RefAccess bool

	// AccessConditions can be used to build index range.
	AccessConditions []ast.ExprNode

	// FilterConditions can be used to filter result.
	FilterConditions []ast.ExprNode

	// TableName is used to distinguish the same table selected multiple times in different place,
	// like 'select * from t where exists(select 1 from t as x where t.c < x.c)'
	TableName *ast.TableName

	TableAsName *model.CIStr

	LimitCount *int64
	// contains filtered or unexported fields
}

TableScan represents a table scan plan.

func (*TableScan) AddChild

func (p *TableScan) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*TableScan) AddParent

func (p *TableScan) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*TableScan) Fields

func (p *TableScan) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*TableScan) GetChildByIndex

func (p *TableScan) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*TableScan) GetChildren

func (p *TableScan) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*TableScan) GetID

func (p *TableScan) GetID() string

GetID implements Plan GetID interface.

func (*TableScan) GetParentByIndex

func (p *TableScan) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*TableScan) GetParents

func (p *TableScan) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*TableScan) GetSchema

func (p *TableScan) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*TableScan) IsCorrelated

func (p *TableScan) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*TableScan) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*TableScan) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*TableScan) RowCount

func (p *TableScan) RowCount() float64

RowCount implements Plan RowCount interface.

func (*TableScan) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*TableScan) SetFields

func (p *TableScan) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*TableScan) SetLimit

func (p *TableScan) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*TableScan) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*TableScan) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*TableScan) StartupCost

func (p *TableScan) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*TableScan) TotalCost

func (p *TableScan) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Trim

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

Trim trims child's rows.

func (*Trim) Convert2PhysicalPlan

func (p *Trim) Convert2PhysicalPlan() PhysicalPlan

Convert2PhysicalPlan implements LogicalPlan Convert2PhysicalPlan interface.

func (*Trim) PredicatePushDown

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

PredicatePushDown implements LogicalPlan PredicatePushDown interface.

func (*Trim) PruneColumnsAndResolveIndices

func (p *Trim) PruneColumnsAndResolveIndices(parentUsedCols []*expression.Column) ([]*expression.Column, error)

PruneColumnsAndResolveIndices implements LogicalPlan PruneColumnsAndResolveIndices interface.

type Union

type Union struct {
	Selects []Plan
	// contains filtered or unexported fields
}

Union represents Union plan.

func (*Union) AddChild

func (p *Union) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Union) AddParent

func (p *Union) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Union) Fields

func (p *Union) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Union) GetChildByIndex

func (p *Union) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Union) GetChildren

func (p *Union) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*Union) GetID

func (p *Union) GetID() string

GetID implements Plan GetID interface.

func (*Union) GetParentByIndex

func (p *Union) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Union) GetParents

func (p *Union) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*Union) GetSchema

func (p *Union) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*Union) IsCorrelated

func (p *Union) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*Union) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*Union) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*Union) RowCount

func (p *Union) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Union) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Union) SetFields

func (p *Union) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Union) SetLimit

func (p *Union) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*Union) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Union) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*Union) StartupCost

func (p *Union) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Union) TotalCost

func (p *Union) TotalCost() float64

TotalCost implements Plan TotalCost interface.

type Update

type Update struct {
	OrderedList []*ast.Assignment // OrderedList has the same offset as TablePlan's result fields.
	SelectPlan  Plan
	// contains filtered or unexported fields
}

Update represents an update plan.

func (*Update) AddChild

func (p *Update) AddChild(child Plan)

AddChild implements Plan AddChild interface.

func (*Update) AddParent

func (p *Update) AddParent(parent Plan)

AddParent implements Plan AddParent interface.

func (*Update) Fields

func (p *Update) Fields() []*ast.ResultField

Fields implements Plan Fields interface.

func (*Update) GetChildByIndex

func (p *Update) GetChildByIndex(index int) (parent Plan)

GetChildByIndex implements Plan GetChildByIndex interface.

func (*Update) GetChildren

func (p *Update) GetChildren() []Plan

GetChildren implements Plan GetChildren interface.

func (*Update) GetID

func (p *Update) GetID() string

GetID implements Plan GetID interface.

func (*Update) GetParentByIndex

func (p *Update) GetParentByIndex(index int) (parent Plan)

GetParentByIndex implements Plan GetParentByIndex interface.

func (*Update) GetParents

func (p *Update) GetParents() []Plan

GetParents implements Plan GetParents interface.

func (*Update) GetSchema

func (p *Update) GetSchema() expression.Schema

GetSchema implements Plan GetSchema interface.

func (*Update) IsCorrelated

func (p *Update) IsCorrelated() bool

IsCorrelated implements Plan IsCorrelated interface.

func (*Update) ReplaceChild

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

ReplaceChild means replace a child with another one.

func (*Update) ReplaceParent

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

ReplaceParent means replace a parent for another one.

func (*Update) RowCount

func (p *Update) RowCount() float64

RowCount implements Plan RowCount interface.

func (*Update) SetChildren

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Update) SetFields

func (p *Update) SetFields(fields []*ast.ResultField)

SetFields implements Plan SetFields interface.

func (*Update) SetLimit

func (p *Update) SetLimit(limit float64)

SetLimit implements Plan SetLimit interface.

func (*Update) SetParents

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

RemoveAllParents implements Plan RemoveAllParents interface.

func (*Update) SetSchema

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

SetSchema implements Plan SetSchema interface.

func (*Update) StartupCost

func (p *Update) StartupCost() float64

StartupCost implements Plan StartupCost interface.

func (*Update) TotalCost

func (p *Update) TotalCost() float64

TotalCost implements Plan TotalCost interface.

Directories

Path Synopsis
Package statistics is a generated protocol buffer package.
Package statistics is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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