Documentation ¶
Index ¶
- Variables
- func GenerateDeleteOuterQuery(del *sqlparser.Delete) *sqlparser.ParsedQuery
- func GenerateDeleteSubquery(del *sqlparser.Delete, table *schema.Table) *sqlparser.ParsedQuery
- func GenerateFieldQuery(statement sqlparser.Statement) *sqlparser.ParsedQuery
- func GenerateFullQuery(statement sqlparser.Statement) *sqlparser.ParsedQuery
- func GenerateInsertOuterQuery(ins *sqlparser.Insert) *sqlparser.ParsedQuery
- func GenerateLimitQuery(selStmt sqlparser.SelectStatement) *sqlparser.ParsedQuery
- func GenerateLoadMessagesQuery(ins *sqlparser.Insert) *sqlparser.ParsedQuery
- func GenerateSubquery(columns []sqlparser.ColIdent, table *sqlparser.AliasedTableExpr, ...) *sqlparser.ParsedQuery
- func GenerateUpdateOuterQuery(upd *sqlparser.Update) *sqlparser.ParsedQuery
- func GenerateUpdateSubquery(upd *sqlparser.Update, table *schema.Table) *sqlparser.ParsedQuery
- type DDLPlan
- type MessageRowValues
- type Plan
- type PlanType
- type ReasonType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTooComplex indicates given sql query is too complex. ErrTooComplex = errors.New("Complex") )
Functions ¶
func GenerateDeleteOuterQuery ¶
func GenerateDeleteOuterQuery(del *sqlparser.Delete) *sqlparser.ParsedQuery
GenerateDeleteOuterQuery generates the outer query for deletes.
func GenerateDeleteSubquery ¶
GenerateDeleteSubquery generates the subquery for deletes.
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 GenerateInsertOuterQuery ¶
func GenerateInsertOuterQuery(ins *sqlparser.Insert) *sqlparser.ParsedQuery
GenerateInsertOuterQuery generates the outer query for inserts.
func GenerateLimitQuery ¶
func GenerateLimitQuery(selStmt sqlparser.SelectStatement) *sqlparser.ParsedQuery
GenerateLimitQuery generates a select query with a limit clause.
func GenerateLoadMessagesQuery ¶
func GenerateLoadMessagesQuery(ins *sqlparser.Insert) *sqlparser.ParsedQuery
GenerateLoadMessagesQuery generates the query to load messages after insert.
func GenerateSubquery ¶
func GenerateSubquery(columns []sqlparser.ColIdent, table *sqlparser.AliasedTableExpr, where *sqlparser.Where, order sqlparser.OrderBy, limit *sqlparser.Limit, forUpdate bool) *sqlparser.ParsedQuery
GenerateSubquery generates a subquery based on the input parameters.
func GenerateUpdateOuterQuery ¶
func GenerateUpdateOuterQuery(upd *sqlparser.Update) *sqlparser.ParsedQuery
GenerateUpdateOuterQuery generates the outer query for updates.
func GenerateUpdateSubquery ¶
GenerateUpdateSubquery generates the subquery for updats.
Types ¶
type MessageRowValues ¶
type MessageRowValues struct { TimeNext interface{} ID interface{} Message interface{} }
MessageRowValues is used to store the values of a message row in a plan.
type Plan ¶
type Plan struct { PlanID PlanType Reason ReasonType Table *schema.Table // FieldQuery is used to fetch field info FieldQuery *sqlparser.ParsedQuery // FullQuery will be set for all plans. FullQuery *sqlparser.ParsedQuery // For PK plans, only OuterQuery is set. // For SUBQUERY plans, Subquery is also set. OuterQuery *sqlparser.ParsedQuery Subquery *sqlparser.ParsedQuery UpsertQuery *sqlparser.ParsedQuery // PlanInsertSubquery: columns to be inserted. ColumnNumbers []int // PKValues is an sqltypes.Value if it's sourced // from the query. If it's a bind var then it's // a string including the ':' prefix(es). // PlanDMLPK: where clause values. // PlanInsertPK: values clause. // PlanNextVal: increment. PKValues []interface{} // For update: set clause if pk is changing. SecondaryPKValues []interface{} // 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 // For PlanInsertSubquery: pk columns in the subquery result. SubqueryPKColumns []int // For PlanInsertMessage. Query used to reload inserted messages. MessageReloaderQuery *sqlparser.ParsedQuery }
Plan is built for selects and DMLs.
func BuildStreaming ¶
BuildStreaming builds a streaming plan based on the schema.
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 ( // PlanPassSelect is pass through select statements. This is the // default plan for select statements. PlanPassSelect PlanType = iota // PlanSelectLock is for a select that locks. PlanSelectLock // PlanNextval is for NEXTVAL PlanNextval // PlanPassDML is pass through update & delete statements. This is // the default plan for update and delete statements. PlanPassDML // PlanDMLPK is an update or delete with an equality where clause(s) // on primary key(s) PlanDMLPK // PlanDMLSubquery is an update or delete with a subselect statement PlanDMLSubquery // PlanInsertPK is insert statement where the PK value is // supplied with the query PlanInsertPK // PlanInsertSubquery is same as PlanDMLSubquery but for inserts PlanInsertSubquery // PlanUpsertPK is for insert ... on duplicate key constructs PlanUpsertPK // PlanInsertMessage is for inserting into message tables PlanInsertMessage // PlanSet is for SET statements PlanSet // PlanDDL is for DDL statements PlanDDL // PlanSelectStream is used for streaming queries PlanSelectStream // PlanOther is for SHOW, DESCRIBE & EXPLAIN statements PlanOther // NumPlans stores the total number of plans NumPlans )
func PlanByName ¶
PlanByName find a PlanType by its string name.
func (PlanType) MarshalJSON ¶
MarshalJSON returns a json string for PlanType.
type ReasonType ¶
type ReasonType int
ReasonType indicates why a query plan fails to build
const ( ReasonDefault ReasonType = iota ReasonTable ReasonTableNoIndex ReasonPKChange ReasonComplexExpr ReasonUpsert ReasonUpsertColMismatch )
Reason codes give a hint about why a certain plan was chosen.
func (ReasonType) MarshalJSON ¶
func (rt ReasonType) MarshalJSON() ([]byte, error)
MarshalJSON returns a json string for ReasonType.
func (ReasonType) String ¶
func (rt ReasonType) String() string
String returns a string representation of a ReasonType.