plancontext

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PlannerVersion

type PlannerVersion = querypb.ExecuteOptions_PlannerVersion

PlannerVersion is an alias here to make the code more readable

func PlannerNameToVersion

func PlannerNameToVersion(s string) (PlannerVersion, bool)

PlannerNameToVersion returns the numerical representation of the planner

type PlanningContext

type PlanningContext struct {
	ReservedVars *sqlparser.ReservedVars
	SemTable     *semantics.SemTable
	VSchema      VSchema

	// here we add all predicates that were created because of a join condition
	// e.g. [FROM tblA JOIN tblB ON a.colA = b.colB] will be rewritten to [FROM tblB WHERE :a_colA = b.colB],
	// if we assume that tblB is on the RHS of the join. This last predicate in the WHERE clause is added to the
	// map below
	JoinPredicates     map[sqlparser.Expr][]sqlparser.Expr
	SkipPredicates     map[sqlparser.Expr]any
	PlannerVersion     querypb.ExecuteOptions_PlannerVersion
	RewriteDerivedExpr bool

	// If we during planning have turned this expression into an argument name,
	// we can continue using the same argument name
	ReservedArguments map[sqlparser.Expr]string
}

func NewPlanningContext

func NewPlanningContext(reservedVars *sqlparser.ReservedVars, semTable *semantics.SemTable, vschema VSchema, version querypb.ExecuteOptions_PlannerVersion) *PlanningContext

func (*PlanningContext) GetArgumentFor added in v0.17.0

func (ctx *PlanningContext) GetArgumentFor(expr sqlparser.Expr, f func() string) string

func (*PlanningContext) IsSubQueryToReplace

func (c *PlanningContext) IsSubQueryToReplace(e sqlparser.Expr) bool

type VSchema

type VSchema interface {
	FindTable(tablename sqlparser.TableName) (*vindexes.Table, string, topodatapb.TabletType, key.Destination, error)
	FindView(name sqlparser.TableName) sqlparser.SelectStatement
	FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.Table, vindexes.Vindex, string, topodatapb.TabletType, key.Destination, error)
	DefaultKeyspace() (*vindexes.Keyspace, error)
	TargetString() string
	Destination() key.Destination
	TabletType() topodatapb.TabletType
	TargetDestination(qualifier string) (key.Destination, *vindexes.Keyspace, topodatapb.TabletType, error)
	AnyKeyspace() (*vindexes.Keyspace, error)
	FirstSortedKeyspace() (*vindexes.Keyspace, error)
	SysVarSetEnabled() bool
	KeyspaceExists(keyspace string) bool
	AllKeyspace() ([]*vindexes.Keyspace, error)
	FindKeyspace(keyspace string) (*vindexes.Keyspace, error)
	GetSemTable() *semantics.SemTable
	Planner() PlannerVersion
	SetPlannerVersion(pv PlannerVersion)
	ConnCollation() collations.ID

	// ErrorIfShardedF will return an error if the keyspace is sharded,
	// and produce a warning if the vtgate if configured to do so
	ErrorIfShardedF(keyspace *vindexes.Keyspace, warn, errFmt string, params ...any) error

	// WarnUnshardedOnly is used when a feature is only supported in unsharded mode.
	// This will let the user know that they are using something
	// that could become a problem if they move to a sharded keyspace
	WarnUnshardedOnly(format string, params ...any)

	// PlannerWarning records warning created during planning.
	PlannerWarning(message string)

	// ForeignKeyMode returns the foreign_key flag value
	ForeignKeyMode() string

	// GetVSchema returns the latest cached vindexes.VSchema
	GetVSchema() *vindexes.VSchema

	// GetSrvVschema returns the latest cached vschema.SrvVSchema
	GetSrvVschema() *vschemapb.SrvVSchema

	// FindRoutedShard looks up shard routing rules for a shard
	FindRoutedShard(keyspace, shard string) (string, error)

	// IsShardRoutingEnabled returns true if partial shard routing is enabled
	IsShardRoutingEnabled() bool

	// IsViewsEnabled returns true if Vitess manages the views.
	IsViewsEnabled() bool

	// GetUDV returns user defined value from the variable passed.
	GetUDV(name string) *querypb.BindVariable

	// PlanPrepareStatement plans the prepared statement.
	PlanPrepareStatement(ctx context.Context, query string) (*engine.Plan, sqlparser.Statement, error)

	// ClearPrepareData clears the prepared data from the session.
	ClearPrepareData(stmtName string)

	// GetPrepareData returns the prepared data for the statement from the session.
	GetPrepareData(stmtName string) *vtgatepb.PrepareData

	// StorePrepareData stores the prepared data in the session.
	StorePrepareData(name string, v *vtgatepb.PrepareData)
}

VSchema defines the interface for this package to fetch info about tables.

Jump to

Keyboard shortcuts

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