planbuilder

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type Permission struct {
	TableName string
	Role      tableacl.Role
}

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

func BuildMessageStreaming(name string, tables map[string]*schema.Table) (*Plan, error)

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 (cached *Plan) CachedSize(alloc bool) int64

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

func PlanByName(s string) (pt PlanType, ok bool)

PlanByName find a PlanType by its string name.

func PlanByNameIC added in v0.10.0

func PlanByNameIC(s string) (pt PlanType, ok bool)

PlanByNameIC finds a plan type by its string name without case sensitivity

func (PlanType) IsSelect

func (pt PlanType) IsSelect() bool

IsSelect returns true if PlanType is about a select query.

func (PlanType) MarshalJSON

func (pt PlanType) MarshalJSON() ([]byte, error)

MarshalJSON returns a json string for PlanType.

func (PlanType) String

func (pt PlanType) String() string

Jump to

Keyboard shortcuts

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