Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // PassthroughDMLs will return plans that pass-through the DMLs without changing them. PassthroughDMLs = false )
Functions ¶
func GenerateFieldQuery ¶
func GenerateFieldQuery(statement sqlparser.Statement) *sqlparser.ParsedQuery
GenerateFieldQuery generates a query to just fetch the field info by adding impossible where clauses as needed.
func GenerateFullQuery ¶
func GenerateFullQuery(statement sqlparser.Statement) *sqlparser.ParsedQuery
GenerateFullQuery generates the full query from the ast.
func GenerateLimitQuery ¶
func GenerateLimitQuery(selStmt sqlparser.SelectStatement) *sqlparser.ParsedQuery
GenerateLimitQuery generates a select query with a limit clause.
Types ¶
type Permission ¶
Permission associates the required access permission for each table.
func BuildPermissions ¶
func BuildPermissions(stmt sqlparser.Statement) []Permission
BuildPermissions builds the list of required permissions for all the tables referenced in a query.
func (*Permission) CachedSize ¶ added in v0.10.0
func (cached *Permission) CachedSize(alloc bool) int64
type Plan ¶
type Plan struct { PlanID PlanType Table *schema.Table // Permissions stores the permissions for the tables accessed in the query. Permissions []Permission // FieldQuery is used to fetch field info FieldQuery *sqlparser.ParsedQuery // FullQuery will be set for all plans. FullQuery *sqlparser.ParsedQuery // NextCount stores the count for "select next". NextCount sqltypes.PlanValue // WhereClause is set for DMLs. It is used by the hot row protection // to serialize e.g. UPDATEs going to the same row. WhereClause *sqlparser.ParsedQuery // FullStmt can be used when the query does not operate on tables FullStmt sqlparser.Statement }
Plan contains the parameters for executing a request.
func Build ¶
func Build(statement sqlparser.Statement, tables map[string]*schema.Table, isReservedConn bool, dbName string) (plan *Plan, err error)
Build builds a plan based on the schema.
func BuildMessageStreaming ¶
BuildMessageStreaming builds a plan for message streaming.
func BuildStreaming ¶
func BuildStreaming(sql string, tables map[string]*schema.Table, isReservedConn bool) (*Plan, error)
BuildStreaming builds a streaming plan based on the schema.
func (*Plan) CachedSize ¶ added in v0.10.0
func (*Plan) TableName ¶
func (plan *Plan) TableName() sqlparser.TableIdent
TableName returns the table name for the plan.
type PlanType ¶
type PlanType int
PlanType indicates a query plan type.
const ( PlanSelect PlanType = iota PlanNextval PlanSelectImpossible PlanInsert PlanInsertMessage PlanUpdate PlanUpdateLimit PlanDelete PlanDeleteLimit PlanDDL PlanSet // PlanOtherRead is for statements like show, etc. PlanOtherRead // PlanOtherAdmin is for statements like repair, lock table, etc. PlanOtherAdmin PlanSelectStream // PlanMessageStream is for "stream" statements. PlanMessageStream PlanSavepoint PlanRelease PlanSRollback PlanShow // PlanLoad is for Load data statements PlanLoad // PlanFlush is for FLUSH statements PlanFlush PlanLockTables PlanUnlockTables PlanCallProc PlanAlterMigration PlanRevertMigration PlanShowMigrationLogs NumPlans )
The following are PlanType values.
func PlanByName ¶
PlanByName find a PlanType by its string name.
func PlanByNameIC ¶ added in v0.10.0
PlanByNameIC finds a plan type by its string name without case sensitivity
func (PlanType) MarshalJSON ¶
MarshalJSON returns a json string for PlanType.