planbuilder

package
v0.20.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

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 BuildSettingQuery added in v0.15.0

func BuildSettingQuery(settings []string, parser *sqlparser.Parser) (query string, resetQuery string, err error)

BuildSettingQuery builds a query for system settings.

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
	// When the query indicates a single table
	Table *schema.Table
	// SELECT, UPDATE, DELETE statements may list multiple tables
	AllTables []*schema.Table

	// Permissions stores the permissions for the tables accessed in the query.
	Permissions []Permission

	// FullQuery will be set for all plans.
	FullQuery *sqlparser.ParsedQuery

	// NextCount stores the count for "select next".
	NextCount evalengine.Expr

	// 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

	// NeedsReservedConn indicates at a reserved connection is needed to execute this plan
	NeedsReservedConn bool
}

Plan contains the parameters for executing a request.

func Build

func Build(env *vtenv.Environment, statement sqlparser.Statement, tables map[string]*schema.Table, dbName string, viewsEnabled bool) (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(statement sqlparser.Statement, tables map[string]*schema.Table) (*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.IdentifierCS

TableName returns the table name for the plan.

func (*Plan) TableNames added in v0.14.0

func (plan *Plan) TableNames() (names []string)

TableNames returns the table names for all tables in the plan.

type PlanType

type PlanType int

PlanType indicates a query plan type.

const (
	PlanSelect PlanType = iota
	PlanNextval
	PlanSelectImpossible
	PlanSelectLockFunc
	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
	PlanShowMigrations
	PlanShowMigrationLogs
	PlanShowThrottledApps
	PlanShowThrottlerStatus
	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) 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