Documentation ¶
Index ¶
- Constants
- Variables
- func CompileExecutePreparedStmt(ctx context.Context, ID uint32, args ...interface{}) (ast.Statement, error)
- func GetFieldsFromLine(line []byte, fieldsInfo *ast.FieldsClause) ([]string, error)
- func GetInfoSchema(ctx context.Context) infoschema.InfoSchema
- func IsPointGetWithPKOrUniqueKeyByAutoCommit(ctx context.Context, p plan.Plan) bool
- func ResetStmtCtx(ctx context.Context, s ast.StmtNode)
- func StatementLabel(node ast.StmtNode, p plan.Plan, isExpensive *bool) string
- type AnalyzeColumnsExec
- type AnalyzeExec
- type AnalyzeIndexExec
- type ApplyJoinExec
- type CacheExec
- type CancelDDLJobsExec
- type CheckTableExec
- type Closeable
- type Compiler
- type DDLExec
- type DataReader
- type DeallocateExec
- type DeleteExec
- type ExecStmt
- type ExecuteExec
- type Executor
- type ExistsExec
- type ExplainExec
- type GrantExec
- type HashAggExec
- type HashJoinExec
- type HashSemiJoinExec
- type IndexLookUpExecutor
- type IndexLookUpJoin
- type IndexReaderExecutor
- type InsertExec
- type InsertValues
- type LimitExec
- type LoadData
- type LoadDataInfo
- type MaxOneRowExec
- type MergeJoinExec
- type NestedLoopJoinExec
- type PrepareExec
- type ProjectionExec
- type ReplaceExec
- type RevokeExec
- type Row
- type SelectLockExec
- type SelectionExec
- type SetExecutor
- type ShowDDLExec
- type ShowDDLJobsExec
- type ShowExec
- type SimpleExec
- type SortExec
- type StreamAggExec
- type TableDualExec
- type TableReaderExecutor
- type TableScanExec
- type TopNExec
- type UnionExec
- type UnionScanExec
- type UpdateExec
- type XSelectIndexExec
- type XSelectTableExec
Constants ¶
const ( CodePasswordNoMatch terror.ErrCode = 1133 // MySQL error code CodeCannotUser terror.ErrCode = 1396 // MySQL error code )
Error codes.
const ( // IGNORE is a special label to identify the situations we want to ignore. IGNORE = "Ignore" // Select represents select statements. Select = "Select" // AlterTable represents alter table statements. AlterTable = "AlterTable" // AnalyzeTable represents analyze table statements. AnalyzeTable = "AnalyzeTable" // Begin represents begin statements. Begin = "Begin" // Commit represents commit statements. Commit = "Commit" // CreateDatabase represents create database statements. CreateDatabase = "CreateDatabase" // CreateIndex represents create index statements. CreateIndex = "CreateIndex" // CreateTable represents create table statements. CreateTable = "CreateTable" // CreateUser represents create user statements. CreateUser = "CreateUser" // Delete represents delete statements. Delete = "Delete" // DropDatabase represents drop database statements. DropDatabase = "DropDatabase" // DropIndex represents drop index statements. DropIndex = "DropIndex" // DropTable represents drop table statements. DropTable = "DropTable" // Explain represents explain statements. Explain = "Explain" // Replace represents replace statements. Replace = "Replace" // Insert represents insert statements. Insert = "Insert" // LoadDataStmt represents load data statements. LoadDataStmt = "LoadData" // RollBack represents roll back statements. RollBack = "RollBack" // Set represents set statements. Set = "Set" // Show represents show statements. Show = "Show" // TruncateTable represents truncate table statements. TruncateTable = "TruncateTable" // Update represents update statements. Update = "Update" // Grant represents grant statements. Grant = "Grant" // Revoke represents revoke statements. Revoke = "Revoke" )
const LoadDataVarKey loadDataVarKeyType = 0
LoadDataVarKey is a variable key for load data.
Variables ¶
var ( ErrUnknownPlan = terror.ClassExecutor.New(codeUnknownPlan, "Unknown plan") ErrPrepareMulti = terror.ClassExecutor.New(codePrepareMulti, "Can not prepare multiple statements") ErrPrepareDDL = terror.ClassExecutor.New(codePrepareDDL, "Can not prepare DDL statements") ErrPasswordNoMatch = terror.ClassExecutor.New(CodePasswordNoMatch, "Can't find any matching row in the user table") ErrResultIsEmpty = terror.ClassExecutor.New(codeResultIsEmpty, "result is empty") ErrBuildExecutor = terror.ClassExecutor.New(codeErrBuildExec, "Failed to build executor") ErrBatchInsertFail = terror.ClassExecutor.New(codeBatchInsertFail, "Batch insert failed, please clean the table and try again.") ErrWrongValueCountOnRow = terror.ClassExecutor.New(codeWrongValueCountOnRow, "Column count doesn't match value count at row %d") )
Error instances.
var BatchDeleteSize = 20000
BatchDeleteSize is the batch size of auto-splitted delete data. This will be used when tidb_batch_delete is set to ON.
var BatchInsertSize = 20000
BatchInsertSize is the batch size of auto-splitted insert data. This will be used when tidb_batch_insert is set to ON.
var LookupTableTaskChannelSize int32 = 50
LookupTableTaskChannelSize represents the channel size of the index double read taskChan.
Functions ¶
func CompileExecutePreparedStmt ¶
func CompileExecutePreparedStmt(ctx context.Context, ID uint32, args ...interface{}) (ast.Statement, error)
CompileExecutePreparedStmt compiles a session Execute command to a stmt.Statement.
func GetFieldsFromLine ¶
func GetFieldsFromLine(line []byte, fieldsInfo *ast.FieldsClause) ([]string, error)
GetFieldsFromLine splits line according to fieldsInfo, this function is exported for testing.
func GetInfoSchema ¶
func GetInfoSchema(ctx context.Context) infoschema.InfoSchema
GetInfoSchema gets TxnCtx InfoSchema if snapshot schema is not set, Otherwise, snapshot schema is returned.
func IsPointGetWithPKOrUniqueKeyByAutoCommit ¶
IsPointGetWithPKOrUniqueKeyByAutoCommit returns true when meets following conditions:
- ctx is auto commit tagged
- txn is nil
- plan is point get by pk or unique key
func ResetStmtCtx ¶
ResetStmtCtx resets the StmtContext. Before every execution, we must clear statement context.
Types ¶
type AnalyzeColumnsExec ¶
type AnalyzeColumnsExec struct {
// contains filtered or unexported fields
}
AnalyzeColumnsExec represents Analyze columns push down executor.
type AnalyzeExec ¶
type AnalyzeExec struct {
// contains filtered or unexported fields
}
AnalyzeExec represents Analyze executor.
func (*AnalyzeExec) Close ¶
func (e *AnalyzeExec) Close() error
Close implements the Executor Close interface.
func (*AnalyzeExec) Next ¶
func (e *AnalyzeExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*AnalyzeExec) Open ¶
func (e *AnalyzeExec) Open() error
Open implements the Executor Open interface.
func (*AnalyzeExec) Schema ¶
func (e *AnalyzeExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type AnalyzeIndexExec ¶
type AnalyzeIndexExec struct {
// contains filtered or unexported fields
}
AnalyzeIndexExec represents analyze index push down executor.
type ApplyJoinExec ¶
type ApplyJoinExec struct {
// contains filtered or unexported fields
}
ApplyJoinExec is the new logic of apply.
func (*ApplyJoinExec) Close ¶
func (e *ApplyJoinExec) Close() error
Close implements the Executor interface.
func (*ApplyJoinExec) Next ¶
func (e *ApplyJoinExec) Next() (Row, error)
Next implements the Executor interface.
func (*ApplyJoinExec) Open ¶
func (e *ApplyJoinExec) Open() error
Open implements the Executor interface.
func (*ApplyJoinExec) Schema ¶
func (e *ApplyJoinExec) Schema() *expression.Schema
Schema implements the Executor interface.
type CacheExec ¶
type CacheExec struct {
// contains filtered or unexported fields
}
CacheExec represents Cache executor. it stores the return values of the executor of its child node.
func (*CacheExec) Close ¶
func (e *CacheExec) Close() error
Close implements the Executor Close interface.
func (*CacheExec) Schema ¶
func (e *CacheExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type CancelDDLJobsExec ¶ added in v1.0.1
type CancelDDLJobsExec struct { JobIDs []int64 // contains filtered or unexported fields }
CancelDDLJobsExec represents a cancel DDL jobs executor.
func (*CancelDDLJobsExec) Close ¶ added in v1.0.1
func (e *CancelDDLJobsExec) Close() error
Close implements the Executor Close interface.
func (*CancelDDLJobsExec) Next ¶ added in v1.0.1
func (e *CancelDDLJobsExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*CancelDDLJobsExec) Open ¶ added in v1.0.1
func (e *CancelDDLJobsExec) Open() error
Open implements the Executor Open interface.
func (*CancelDDLJobsExec) Schema ¶ added in v1.0.1
func (e *CancelDDLJobsExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type CheckTableExec ¶
type CheckTableExec struct {
// contains filtered or unexported fields
}
CheckTableExec represents a check table executor. It is built from the "admin check table" statement, and it checks if the index matches the records in the table.
func (*CheckTableExec) Close ¶
func (e *CheckTableExec) Close() error
Close implements plan.Plan Close interface.
func (*CheckTableExec) Next ¶
func (e *CheckTableExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*CheckTableExec) Open ¶
func (e *CheckTableExec) Open() error
Open implements the Executor Open interface.
func (*CheckTableExec) Schema ¶
func (e *CheckTableExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type Closeable ¶
type Closeable interface { // Close closes the object. Close() error }
Closeable is a interface for closeable structures.
type DDLExec ¶
DDLExec represents a DDL executor. It grabs a DDL instance from Domain, calling the DDL methods to do the work.
func (*DDLExec) Schema ¶
func (e *DDLExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type DataReader ¶
type DataReader interface { Executor // contains filtered or unexported methods }
DataReader can send requests which ranges are constructed by datums.
type DeallocateExec ¶
type DeallocateExec struct { Name string // contains filtered or unexported fields }
DeallocateExec represent a DEALLOCATE executor.
func (*DeallocateExec) Close ¶
func (e *DeallocateExec) Close() error
Close implements Executor Close interface.
func (*DeallocateExec) Next ¶
func (e *DeallocateExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*DeallocateExec) Open ¶
func (e *DeallocateExec) Open() error
Open implements Executor Open interface.
func (*DeallocateExec) Schema ¶
func (e *DeallocateExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type DeleteExec ¶
type DeleteExec struct { SelectExec Executor Tables []*ast.TableName IsMultiTable bool // contains filtered or unexported fields }
DeleteExec represents a delete executor. See https://dev.mysql.com/doc/refman/5.7/en/delete.html
func (*DeleteExec) Close ¶
func (e *DeleteExec) Close() error
Close implements the Executor Close interface.
func (*DeleteExec) Next ¶
func (e *DeleteExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*DeleteExec) Open ¶
func (e *DeleteExec) Open() error
Open implements the Executor Open interface.
func (*DeleteExec) Schema ¶
func (e *DeleteExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type ExecStmt ¶
type ExecStmt struct { // InfoSchema stores a reference to the schema information. InfoSchema infoschema.InfoSchema // Plan stores a reference to the final physical plan. Plan plan.Plan // Expensive represents whether this query is an expensive one. Expensive bool // Cacheable represents whether the physical plan can be cached. Cacheable bool // Text represents the origin query text. Text string // contains filtered or unexported fields }
ExecStmt implements the ast.Statement interface, it builds a plan.Plan to an ast.Statement.
func (*ExecStmt) Exec ¶
Exec implements the ast.Statement Exec interface. This function builds an Executor from a plan. If the Executor doesn't return result, like the INSERT, UPDATE statements, it executes in this function, if the Executor returns result, execution is done after this function returns, in the returned ast.RecordSet Next method.
func (*ExecStmt) IsPrepared ¶
IsPrepared implements ast.Statement interface.
func (*ExecStmt) OriginText ¶
OriginText implements ast.Statement interface.
type ExecuteExec ¶
type ExecuteExec struct { IS infoschema.InfoSchema Ctx context.Context Name string UsingVars []expression.Expression ID uint32 StmtExec Executor Stmt ast.StmtNode Plan plan.Plan }
ExecuteExec represents an EXECUTE executor. It cannot be executed by itself, all it needs to do is to build another Executor from a prepared statement.
func (*ExecuteExec) Build ¶
func (e *ExecuteExec) Build() error
Build builds a prepared statement into an executor. After Build, e.StmtExec will be used to do the real execution.
func (*ExecuteExec) Close ¶
func (e *ExecuteExec) Close() error
Close implements Executor Close interface.
func (*ExecuteExec) Next ¶
func (e *ExecuteExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*ExecuteExec) Open ¶
func (e *ExecuteExec) Open() error
Open implements the Executor Open interface.
func (*ExecuteExec) Schema ¶
func (e *ExecuteExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type Executor ¶
type Executor interface { Next() (Row, error) Close() error Open() error Schema() *expression.Schema }
Executor executes a query.
type ExistsExec ¶
type ExistsExec struct {
// contains filtered or unexported fields
}
ExistsExec represents exists executor.
func (*ExistsExec) Close ¶
func (e *ExistsExec) Close() error
Close implements the Executor Close interface.
func (*ExistsExec) Next ¶
func (e *ExistsExec) Next() (Row, error)
Next implements the Executor Next interface. We always return one row with one column which has true or false value.
func (*ExistsExec) Open ¶
func (e *ExistsExec) Open() error
Open implements the Executor Open interface.
func (*ExistsExec) Schema ¶
func (e *ExistsExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type ExplainExec ¶
type ExplainExec struct {
// contains filtered or unexported fields
}
ExplainExec represents an explain executor.
func (*ExplainExec) Close ¶
func (e *ExplainExec) Close() error
Close implements the Executor Close interface.
func (*ExplainExec) Next ¶
func (e *ExplainExec) Next() (Row, error)
Next implements Execution Next interface.
func (*ExplainExec) Open ¶
func (e *ExplainExec) Open() error
Open implements the Executor Open interface.
func (*ExplainExec) Schema ¶
func (e *ExplainExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type GrantExec ¶
type GrantExec struct { Privs []*ast.PrivElem ObjectType ast.ObjectTypeType Level *ast.GrantLevel Users []*ast.UserSpec WithGrant bool // contains filtered or unexported fields }
GrantExec executes GrantStmt.
func (*GrantExec) Schema ¶
func (e *GrantExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type HashAggExec ¶
type HashAggExec struct { AggFuncs []aggregation.Aggregation GroupByItems []expression.Expression // contains filtered or unexported fields }
HashAggExec deals with all the aggregate functions. It is built from the Aggregate Plan. When Next() is called, it reads all the data from Src and updates all the items in AggFuncs.
func (*HashAggExec) Close ¶
func (e *HashAggExec) Close() error
Close implements the Executor Close interface.
func (*HashAggExec) Next ¶
func (e *HashAggExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*HashAggExec) Open ¶
func (e *HashAggExec) Open() error
Open implements the Executor Open interface.
func (*HashAggExec) Schema ¶
func (e *HashAggExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type HashJoinExec ¶
type HashJoinExec struct {
// contains filtered or unexported fields
}
HashJoinExec implements the hash join algorithm.
func (*HashJoinExec) Close ¶
func (e *HashJoinExec) Close() error
Close implements the Executor Close interface.
func (*HashJoinExec) Next ¶
func (e *HashJoinExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*HashJoinExec) Open ¶
func (e *HashJoinExec) Open() error
Open implements the Executor Open interface.
func (*HashJoinExec) Schema ¶
func (e *HashJoinExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type HashSemiJoinExec ¶
type HashSemiJoinExec struct {
// contains filtered or unexported fields
}
HashSemiJoinExec implements the hash join algorithm for semi join.
func (*HashSemiJoinExec) Close ¶
func (e *HashSemiJoinExec) Close() error
Close implements the Executor Close interface.
func (*HashSemiJoinExec) Next ¶
func (e *HashSemiJoinExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*HashSemiJoinExec) Open ¶
func (e *HashSemiJoinExec) Open() error
Open implements the Executor Open interface.
func (*HashSemiJoinExec) Schema ¶
func (e *HashSemiJoinExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type IndexLookUpExecutor ¶
type IndexLookUpExecutor struct {
// contains filtered or unexported fields
}
IndexLookUpExecutor implements double read for index scan.
func (*IndexLookUpExecutor) Close ¶
func (e *IndexLookUpExecutor) Close() error
Close implements Exec Close interface.
func (*IndexLookUpExecutor) Next ¶
func (e *IndexLookUpExecutor) Next() (Row, error)
Next implements Exec Next interface.
func (*IndexLookUpExecutor) Open ¶
func (e *IndexLookUpExecutor) Open() error
Open implements the Executor Open interface.
func (*IndexLookUpExecutor) Schema ¶
func (e *IndexLookUpExecutor) Schema() *expression.Schema
Schema implements Exec Schema interface.
type IndexLookUpJoin ¶
type IndexLookUpJoin struct {
// contains filtered or unexported fields
}
IndexLookUpJoin fetches batches of data from outer executor and constructs ranges for inner executor.
func (*IndexLookUpJoin) Close ¶
func (e *IndexLookUpJoin) Close() error
Close implements the Executor Close interface.
func (*IndexLookUpJoin) Next ¶
func (e *IndexLookUpJoin) Next() (Row, error)
Next implements the Executor Next interface. We will fetch batches of row from outer executor, construct the inner datums and sort them. At the same time we will fetch the inner row by the inner datums and apply merge join.
func (*IndexLookUpJoin) Open ¶
func (e *IndexLookUpJoin) Open() error
Open implements the Executor Open interface.
func (*IndexLookUpJoin) Schema ¶
func (e *IndexLookUpJoin) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type IndexReaderExecutor ¶
type IndexReaderExecutor struct {
// contains filtered or unexported fields
}
IndexReaderExecutor sends dag request and reads index data from kv layer.
func (*IndexReaderExecutor) Close ¶
func (e *IndexReaderExecutor) Close() error
Close implements the Executor Close interface.
func (*IndexReaderExecutor) Next ¶
func (e *IndexReaderExecutor) Next() (Row, error)
Next implements the Executor Next interface.
func (*IndexReaderExecutor) Open ¶
func (e *IndexReaderExecutor) Open() error
Open implements the Executor Open interface.
func (*IndexReaderExecutor) Schema ¶
func (e *IndexReaderExecutor) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type InsertExec ¶
type InsertExec struct { *InsertValues OnDuplicate []*expression.Assignment Priority mysql.PriorityEnum IgnoreErr bool // contains filtered or unexported fields }
InsertExec represents an insert executor.
func (*InsertExec) Close ¶
func (e *InsertExec) Close() error
Close implements the Executor Close interface.
func (*InsertExec) Next ¶
func (e *InsertExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*InsertExec) Open ¶
func (e *InsertExec) Open() error
Open implements the Executor Close interface.
func (*InsertExec) Schema ¶
func (e *InsertExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type InsertValues ¶
type InsertValues struct { SelectExec Executor Table table.Table Columns []*ast.ColumnName Lists [][]expression.Expression Setlist []*expression.Assignment IsPrepare bool GenColumns []*ast.ColumnName GenExprs []expression.Expression // contains filtered or unexported fields }
InsertValues is the data to insert.
type LimitExec ¶
type LimitExec struct { Offset uint64 Count uint64 Idx uint64 // contains filtered or unexported fields }
LimitExec represents limit executor It ignores 'Offset' rows from src, then returns 'Count' rows at maximum.
func (*LimitExec) Close ¶
func (e *LimitExec) Close() error
Close implements the Executor Close interface.
func (*LimitExec) Schema ¶
func (e *LimitExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type LoadData ¶
type LoadData struct { IsLocal bool // contains filtered or unexported fields }
LoadData represents a load data executor.
func (*LoadData) Schema ¶
func (e *LoadData) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type LoadDataInfo ¶
type LoadDataInfo struct { Path string Table table.Table FieldsInfo *ast.FieldsClause LinesInfo *ast.LinesClause Ctx context.Context // contains filtered or unexported fields }
LoadDataInfo saves the information of loading data operation.
func NewLoadDataInfo ¶
func NewLoadDataInfo(row []types.Datum, ctx context.Context, tbl table.Table, cols []*table.Column) *LoadDataInfo
NewLoadDataInfo returns a LoadDataInfo structure, and it's only used for tests now.
func (*LoadDataInfo) InsertData ¶
func (e *LoadDataInfo) InsertData(prevData, curData []byte) ([]byte, bool, error)
InsertData inserts data into specified table according to the specified format. If it has the rest of data isn't completed the processing, then is returns without completed data. If the number of inserted rows reaches the batchRows, then the second return value is true. If prevData isn't nil and curData is nil, there are no other data to deal with and the isEOF is true.
func (*LoadDataInfo) SetBatchCount ¶
func (e *LoadDataInfo) SetBatchCount(limit int64)
SetBatchCount sets the number of rows to insert in a batch.
type MaxOneRowExec ¶
type MaxOneRowExec struct {
// contains filtered or unexported fields
}
MaxOneRowExec checks if the number of rows that a query returns is at maximum one. It's built from subquery expression.
func (*MaxOneRowExec) Close ¶
func (e *MaxOneRowExec) Close() error
Close implements the Executor Close interface.
func (*MaxOneRowExec) Next ¶
func (e *MaxOneRowExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*MaxOneRowExec) Open ¶
func (e *MaxOneRowExec) Open() error
Open implements the Executor Open interface.
func (*MaxOneRowExec) Schema ¶
func (e *MaxOneRowExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type MergeJoinExec ¶
type MergeJoinExec struct {
// contains filtered or unexported fields
}
MergeJoinExec implements the merge join algorithm. This operator assumes that two iterators of both sides will provide required order on join condition: 1. For equal-join, one of the join key from each side matches the order given. 2. For other cases its preferred not to use SMJ and operator will throw error.
func (*MergeJoinExec) Close ¶
func (e *MergeJoinExec) Close() error
Close implements the Executor Close interface.
func (*MergeJoinExec) Next ¶
func (e *MergeJoinExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*MergeJoinExec) Open ¶
func (e *MergeJoinExec) Open() error
Open implements the Executor Open interface.
func (*MergeJoinExec) Schema ¶
func (e *MergeJoinExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type NestedLoopJoinExec ¶
type NestedLoopJoinExec struct { SmallExec Executor BigExec Executor Ctx context.Context SmallFilter expression.CNFExprs BigFilter expression.CNFExprs OtherFilter expression.CNFExprs // contains filtered or unexported fields }
NestedLoopJoinExec implements nested-loop algorithm for join.
func (*NestedLoopJoinExec) Close ¶
func (e *NestedLoopJoinExec) Close() error
Close implements Executor interface.
func (*NestedLoopJoinExec) Next ¶
func (e *NestedLoopJoinExec) Next() (Row, error)
Next implements the Executor interface.
func (*NestedLoopJoinExec) Open ¶
func (e *NestedLoopJoinExec) Open() error
Open implements Executor Open interface.
func (*NestedLoopJoinExec) Schema ¶
func (e *NestedLoopJoinExec) Schema() *expression.Schema
Schema implements Executor interface.
type PrepareExec ¶
type PrepareExec struct { IS infoschema.InfoSchema Ctx context.Context Name string SQLText string ID uint32 ParamCount int Err error Fields []*ast.ResultField }
PrepareExec represents a PREPARE executor.
func (*PrepareExec) Close ¶
func (e *PrepareExec) Close() error
Close implements the Executor Close interface.
func (*PrepareExec) DoPrepare ¶
func (e *PrepareExec) DoPrepare()
DoPrepare prepares the statement, it can be called multiple times without side effect.
func (*PrepareExec) Next ¶
func (e *PrepareExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*PrepareExec) Open ¶
func (e *PrepareExec) Open() error
Open implements the Executor Open interface.
func (*PrepareExec) Schema ¶
func (e *PrepareExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type ProjectionExec ¶
type ProjectionExec struct {
// contains filtered or unexported fields
}
ProjectionExec represents a select fields executor.
func (*ProjectionExec) Close ¶
func (e *ProjectionExec) Close() error
Close implements the Executor Close interface.
func (*ProjectionExec) Next ¶
func (e *ProjectionExec) Next() (retRow Row, err error)
Next implements the Executor Next interface.
func (*ProjectionExec) Open ¶
func (e *ProjectionExec) Open() error
Open implements the Executor Open interface.
func (*ProjectionExec) Schema ¶
func (e *ProjectionExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type ReplaceExec ¶
type ReplaceExec struct { *InsertValues Priority int // contains filtered or unexported fields }
ReplaceExec represents a replace executor.
func (*ReplaceExec) Close ¶
func (e *ReplaceExec) Close() error
Close implements the Executor Close interface.
func (*ReplaceExec) Next ¶
func (e *ReplaceExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*ReplaceExec) Open ¶
func (e *ReplaceExec) Open() error
Open implements the Executor Open interface.
func (*ReplaceExec) Schema ¶
func (e *ReplaceExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type RevokeExec ¶
type RevokeExec struct { Privs []*ast.PrivElem ObjectType ast.ObjectTypeType Level *ast.GrantLevel Users []*ast.UserSpec // contains filtered or unexported fields }
RevokeExec executes RevokeStmt.
func (*RevokeExec) Close ¶
func (e *RevokeExec) Close() error
Close implements the Executor Close interface.
func (*RevokeExec) Next ¶
func (e *RevokeExec) Next() (Row, error)
Next implements Execution Next interface.
func (*RevokeExec) Open ¶
func (e *RevokeExec) Open() error
Open implements the Executor Open interface.
func (*RevokeExec) Schema ¶
func (e *RevokeExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type Row ¶
Row represents a result set row, it may be returned from a table, a join, or a projection.
The following cases will need store the handle information:
If the top plan is update or delete, then every executor will need the handle. If there is an union scan, then the below scan plan must store the handle. If there is sort need in the double read, then the table scan of the double read must store the handle. If there is a select for update. then we need to store the handle until the lock plan. But if there is aggregation, the handle info can be removed. Otherwise the executor's returned rows don't need to store the handle information.
type SelectLockExec ¶
type SelectLockExec struct { Lock ast.SelectLockType // contains filtered or unexported fields }
SelectLockExec represents a select lock executor. It is built from the "SELECT .. FOR UPDATE" or the "SELECT .. LOCK IN SHARE MODE" statement. For "SELECT .. FOR UPDATE" statement, it locks every row key from source Executor. After the execution, the keys are buffered in transaction, and will be sent to KV when doing commit. If there is any key already locked by another transaction, the transaction will rollback and retry.
func (*SelectLockExec) Close ¶
func (e *SelectLockExec) Close() error
Close implements the Executor Close interface.
func (*SelectLockExec) Next ¶
func (e *SelectLockExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*SelectLockExec) Open ¶
func (e *SelectLockExec) Open() error
Open implements the Executor Open interface.
func (*SelectLockExec) Schema ¶
func (e *SelectLockExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type SelectionExec ¶
type SelectionExec struct { Conditions []expression.Expression // contains filtered or unexported fields }
SelectionExec represents a filter executor.
func (*SelectionExec) Close ¶
func (e *SelectionExec) Close() error
Close implements the Executor Close interface.
func (*SelectionExec) Next ¶
func (e *SelectionExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*SelectionExec) Open ¶
func (e *SelectionExec) Open() error
Open implements the Executor Open interface.
func (*SelectionExec) Schema ¶
func (e *SelectionExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type SetExecutor ¶
type SetExecutor struct {
// contains filtered or unexported fields
}
SetExecutor executes set statement.
func (*SetExecutor) Close ¶
func (e *SetExecutor) Close() error
Close implements the Executor Close interface.
func (*SetExecutor) Next ¶
func (e *SetExecutor) Next() (Row, error)
Next implements the Executor Next interface.
func (*SetExecutor) Open ¶
func (e *SetExecutor) Open() error
Open implements the Executor Open interface.
func (*SetExecutor) Schema ¶
func (e *SetExecutor) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type ShowDDLExec ¶
type ShowDDLExec struct {
// contains filtered or unexported fields
}
ShowDDLExec represents a show DDL executor.
func (*ShowDDLExec) Close ¶
func (e *ShowDDLExec) Close() error
Close implements the Executor Close interface.
func (*ShowDDLExec) Next ¶
func (e *ShowDDLExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*ShowDDLExec) Open ¶
func (e *ShowDDLExec) Open() error
Open implements the Executor Open interface.
func (*ShowDDLExec) Schema ¶
func (e *ShowDDLExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type ShowDDLJobsExec ¶
type ShowDDLJobsExec struct {
// contains filtered or unexported fields
}
ShowDDLJobsExec represent a show DDL jobs executor.
func (*ShowDDLJobsExec) Close ¶
func (e *ShowDDLJobsExec) Close() error
Close implements the Executor Close interface.
func (*ShowDDLJobsExec) Next ¶
func (e *ShowDDLJobsExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*ShowDDLJobsExec) Open ¶
func (e *ShowDDLJobsExec) Open() error
Open implements the Executor Open interface.
func (*ShowDDLJobsExec) Schema ¶
func (e *ShowDDLJobsExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type ShowExec ¶
type ShowExec struct { Tp ast.ShowStmtType // Databases/Tables/Columns/.... DBName model.CIStr Table *ast.TableName // Used for showing columns. Column *ast.ColumnName // Used for `desc table column`. Flag int // Some flag parsed from sql, such as FULL. Full bool User *auth.UserIdentity // Used for show grants. // GlobalScope is used by show variables GlobalScope bool // contains filtered or unexported fields }
ShowExec represents a show executor.
func (*ShowExec) Close ¶
func (e *ShowExec) Close() error
Close implements the Executor Close interface.
func (*ShowExec) Open ¶
func (e *ShowExec) Open() error
Open implements the Executor Open interface.
func (*ShowExec) Schema ¶
func (e *ShowExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type SimpleExec ¶
SimpleExec represents simple statement executor. For statements do simple execution. includes `UseStmt`, 'SetStmt`, `DoStmt`, `BeginStmt`, `CommitStmt`, `RollbackStmt`. TODO: list all simple statements.
func (*SimpleExec) Close ¶
func (e *SimpleExec) Close() error
Close implements the Executor Close interface.
func (*SimpleExec) Next ¶
func (e *SimpleExec) Next() (Row, error)
Next implements Execution Next interface.
func (*SimpleExec) Open ¶
func (e *SimpleExec) Open() error
Open implements the Executor Open interface.
func (*SimpleExec) Schema ¶
func (e *SimpleExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type SortExec ¶
type SortExec struct { ByItems []*plan.ByItems Rows []*orderByRow Idx int // contains filtered or unexported fields }
SortExec represents sorting executor.
func (*SortExec) Schema ¶
func (e *SortExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type StreamAggExec ¶
type StreamAggExec struct { StmtCtx *variable.StatementContext AggFuncs []aggregation.Aggregation GroupByItems []expression.Expression // contains filtered or unexported fields }
StreamAggExec deals with all the aggregate functions. It assumes all the input data is sorted by group by key. When Next() is called, it will return a result for the same group.
func (*StreamAggExec) Close ¶
func (e *StreamAggExec) Close() error
Close implements the Executor Close interface.
func (*StreamAggExec) Next ¶
func (e *StreamAggExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*StreamAggExec) Open ¶
func (e *StreamAggExec) Open() error
Open implements the Executor Open interface.
func (*StreamAggExec) Schema ¶
func (e *StreamAggExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type TableDualExec ¶
type TableDualExec struct {
// contains filtered or unexported fields
}
TableDualExec represents a dual table executor.
func (*TableDualExec) Close ¶
func (e *TableDualExec) Close() error
Close implements the Executor Close interface.
func (*TableDualExec) Next ¶
func (e *TableDualExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*TableDualExec) Open ¶
func (e *TableDualExec) Open() error
Open implements the Executor Open interface.
func (*TableDualExec) Schema ¶
func (e *TableDualExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type TableReaderExecutor ¶
type TableReaderExecutor struct {
// contains filtered or unexported fields
}
TableReaderExecutor sends dag request and reads table data from kv layer.
func (*TableReaderExecutor) Close ¶
func (e *TableReaderExecutor) Close() error
Close implements the Executor Close interface.
func (*TableReaderExecutor) Next ¶
func (e *TableReaderExecutor) Next() (Row, error)
Next implements the Executor Next interface.
func (*TableReaderExecutor) Open ¶
func (e *TableReaderExecutor) Open() error
Open implements the Executor Open interface.
func (*TableReaderExecutor) Schema ¶
func (e *TableReaderExecutor) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type TableScanExec ¶
type TableScanExec struct {
// contains filtered or unexported fields
}
TableScanExec is a table scan executor without result fields.
func (*TableScanExec) Close ¶
func (e *TableScanExec) Close() error
Close implements the Executor Close interface.
func (*TableScanExec) Next ¶
func (e *TableScanExec) Next() (Row, error)
Next implements the Executor interface.
func (*TableScanExec) Open ¶
func (e *TableScanExec) Open() error
Open implements the Executor Open interface.
func (*TableScanExec) Schema ¶
func (e *TableScanExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type TopNExec ¶
type TopNExec struct { SortExec // contains filtered or unexported fields }
TopNExec implements a Top-N algorithm and it is built from a SELECT statement with ORDER BY and LIMIT. Instead of sorting all the rows fetched from the table, it keeps the Top-N elements only in a heap to reduce memory usage.
func (*TopNExec) Pop ¶
func (e *TopNExec) Pop() interface{}
Pop implements heap.Interface Pop interface.
func (*TopNExec) Push ¶
func (e *TopNExec) Push(x interface{})
Push implements heap.Interface Push interface.
func (*TopNExec) Schema ¶
func (e *TopNExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type UnionExec ¶
type UnionExec struct {
// contains filtered or unexported fields
}
UnionExec represents union executor. UnionExec has multiple source Executors, it executes them sequentially, and do conversion to the same type as source Executors may has different field type, we need to do conversion.
func (*UnionExec) Schema ¶
func (e *UnionExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type UnionScanExec ¶
type UnionScanExec struct {
// contains filtered or unexported fields
}
UnionScanExec merges the rows from dirty table and the rows from XAPI request.
func (*UnionScanExec) Close ¶
func (e *UnionScanExec) Close() error
Close implements the Executor Close interface.
func (*UnionScanExec) Len ¶
func (us *UnionScanExec) Len() int
Len implements sort.Interface interface.
func (*UnionScanExec) Less ¶
func (us *UnionScanExec) Less(i, j int) bool
Less implements sort.Interface interface.
func (*UnionScanExec) Next ¶
func (us *UnionScanExec) Next() (Row, error)
Next implements Execution Next interface.
func (*UnionScanExec) Open ¶
func (e *UnionScanExec) Open() error
Open implements the Executor Open interface.
func (*UnionScanExec) Schema ¶
func (e *UnionScanExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
func (*UnionScanExec) Swap ¶
func (us *UnionScanExec) Swap(i, j int)
Swap implements sort.Interface interface.
type UpdateExec ¶
type UpdateExec struct { SelectExec Executor OrderedList []*expression.Assignment IgnoreErr bool // contains filtered or unexported fields }
UpdateExec represents a new update executor.
func (*UpdateExec) Close ¶
func (e *UpdateExec) Close() error
Close implements the Executor Close interface.
func (*UpdateExec) Next ¶
func (e *UpdateExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*UpdateExec) Open ¶
func (e *UpdateExec) Open() error
Open implements the Executor Open interface.
func (*UpdateExec) Schema ¶
func (e *UpdateExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
type XSelectIndexExec ¶
type XSelectIndexExec struct {
// contains filtered or unexported fields
}
XSelectIndexExec represents the DistSQL select index executor. There are two execution modes. One is single-read, in which case we only need to read index keys. The other one is double-read, in which case we first do index request to get handles, we use each partial result to build a lookupTableTask.
Each lookupTableTask works like XSelectTableExec. It sorts the handles, sends an *tipb.SelectRequest, then gets distsql.SelectResult which returns multiple distsql.PartialResults, we fetch all the rows from each distsql.PartialResult, then sort the rows by the original index order.
So there might be many tasks built from index request, each task do its own table request. If we do it one by one, the execution might be very slow.
To speed up the execution, index request or table request is done concurrently. The concurrency is controlled by kv.Client, we only need to pass the concurrency parameter.
We also make a higher level of concurrency by doing index request in a background goroutine. The index goroutine starts multiple worker goroutines and fetches handles from each index partial request, builds lookup table tasks and sends the task to 'workerCh'.
Each worker goroutine receives tasks through the 'workerCh', then executes the task. After finishing the task, the workers send the task to a taskChan. At the outer most Executor.Next method, we receive the finished task through taskChan, and return each row in that task until no more tasks to receive.
func (*XSelectIndexExec) Close ¶
func (e *XSelectIndexExec) Close() error
Close implements Exec Close interface.
func (*XSelectIndexExec) Next ¶
func (e *XSelectIndexExec) Next() (Row, error)
Next implements the Executor Next interface.
func (*XSelectIndexExec) Open ¶
func (e *XSelectIndexExec) Open() error
Open implements the Executor Open interface.
func (*XSelectIndexExec) Schema ¶
func (e *XSelectIndexExec) Schema() *expression.Schema
Schema implements Exec Schema interface.
type XSelectTableExec ¶
type XSelectTableExec struct { Columns []*model.ColumnInfo // contains filtered or unexported fields }
XSelectTableExec represents the DistSQL select table executor. Its execution is pushed down to KV layer.
func (*XSelectTableExec) Close ¶
func (e *XSelectTableExec) Close() error
Close implements the Executor Close interface.
func (*XSelectTableExec) Next ¶
func (e *XSelectTableExec) Next() (Row, error)
Next implements the Executor interface.
func (*XSelectTableExec) Open ¶
func (e *XSelectTableExec) Open() error
Open implements the Executor interface.
func (*XSelectTableExec) Schema ¶
func (e *XSelectTableExec) Schema() *expression.Schema
Schema implements the Executor Schema interface.
Source Files ¶
- adapter.go
- aggregate.go
- analyze.go
- builder.go
- compiler.go
- ddl.go
- distsql.go
- executor.go
- explain.go
- grant.go
- index_join.go
- join.go
- join_builder.go
- join_result_generators.go
- merge_join.go
- metrics.go
- new_analyze.go
- new_distsql.go
- prepared.go
- revoke.go
- set.go
- show.go
- show_stats.go
- simple.go
- sort.go
- union_scan.go
- write.go