Documentation
¶
Index ¶
- type BindVarExpr
- type ContextCTE
- type PlannerVersion
- type PlanningContext
- func (ctx *PlanningContext) ActiveCTE() *ContextCTE
- func (ctx *PlanningContext) CollectConditions(conditions []engine.Condition)
- func (ctx *PlanningContext) ContainsAggr(e sqlparser.SQLNode) (hasAggr bool)
- func (ctx *PlanningContext) GetReservedArgumentFor(expr sqlparser.Expr) string
- func (ctx *PlanningContext) IsAggr(e sqlparser.SQLNode) bool
- func (ctx *PlanningContext) IsConstantBool(expr sqlparser.Expr) *bool
- func (ctx *PlanningContext) IsMirrored() bool
- func (ctx *PlanningContext) NeedsWeightString(e sqlparser.Expr) bool
- func (ctx *PlanningContext) PopCTE() (*ContextCTE, error)
- func (ctx *PlanningContext) PushCTE(def *semantics.CTE, id semantics.TableSet)
- func (ctx *PlanningContext) SQLTypeForExpr(e sqlparser.Expr) sqltypes.Type
- func (ctx *PlanningContext) TypeForExpr(e sqlparser.Expr) (evalengine.Type, bool)
- func (ctx *PlanningContext) UseMirror() *PlanningContext
- type RecurseExpression
- type VSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindVarExpr ¶ added in v0.21.0
type ContextCTE ¶ added in v0.21.0
type ContextCTE struct { *semantics.CTE Id semantics.TableSet Predicates []*RecurseExpression }
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 PlannerVersion querypb.ExecuteOptions_PlannerVersion // 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 // VerifyAllFKs tells whether we need verification for all the fk constraints on VTGate. // This is required for queries we are running with /*+ SET_VAR(foreign_key_checks=OFF) */ VerifyAllFKs bool // Projected subqueries that have been merged MergedSubqueries []*sqlparser.Subquery // CurrentPhase keeps track of how far we've gone in the planning process // The type should be operators.Phase, but depending on that would lead to circular dependencies CurrentPhase int // Statement contains the originally parsed statement Statement sqlparser.Statement // OuterTables contains the tables that are outer to the current query // Used to set the nullable flag on the columns OuterTables semantics.TableSet // This is a stack of CTEs being built. It's used when we have CTEs inside CTEs, // to remember which is the CTE currently being assembled CurrentCTE []*ContextCTE PredTracker *predicates.Tracker Conditions []engine.Condition // contains filtered or unexported fields }
func CreatePlanningContext ¶ added in v0.18.0
func CreatePlanningContext(stmt sqlparser.Statement, reservedVars *sqlparser.ReservedVars, vschema VSchema, version querypb.ExecuteOptions_PlannerVersion, ) (*PlanningContext, error)
CreatePlanningContext initializes a new PlanningContext with the given parameters. It analyzes the SQL statement within the given virtual schema context, handling default keyspace settings and semantic analysis. Returns an error if semantic analysis fails.
func (*PlanningContext) ActiveCTE ¶ added in v0.21.0
func (ctx *PlanningContext) ActiveCTE() *ContextCTE
func (*PlanningContext) CollectConditions ¶ added in v0.22.0
func (ctx *PlanningContext) CollectConditions(conditions []engine.Condition)
func (*PlanningContext) ContainsAggr ¶ added in v0.21.0
func (ctx *PlanningContext) ContainsAggr(e sqlparser.SQLNode) (hasAggr bool)
func (*PlanningContext) GetReservedArgumentFor ¶ added in v0.18.0
func (ctx *PlanningContext) GetReservedArgumentFor(expr sqlparser.Expr) string
GetReservedArgumentFor retrieves a reserved argument name for a given expression. If the expression already has a reserved argument, it returns that name; otherwise, it reserves a new name based on the expression type.
func (*PlanningContext) IsAggr ¶ added in v0.21.0
func (ctx *PlanningContext) IsAggr(e sqlparser.SQLNode) bool
func (*PlanningContext) IsConstantBool ¶ added in v0.21.0
func (ctx *PlanningContext) IsConstantBool(expr sqlparser.Expr) *bool
IsConstantBool checks whether this predicate can be evaluated at plan-time. If it can, it returns the constant value.
func (*PlanningContext) IsMirrored ¶ added in v0.21.0
func (ctx *PlanningContext) IsMirrored() bool
func (*PlanningContext) NeedsWeightString ¶ added in v0.21.0
func (ctx *PlanningContext) NeedsWeightString(e sqlparser.Expr) bool
func (*PlanningContext) PopCTE ¶ added in v0.21.0
func (ctx *PlanningContext) PopCTE() (*ContextCTE, error)
func (*PlanningContext) PushCTE ¶ added in v0.21.0
func (ctx *PlanningContext) PushCTE(def *semantics.CTE, id semantics.TableSet)
func (*PlanningContext) SQLTypeForExpr ¶ added in v0.21.0
func (ctx *PlanningContext) SQLTypeForExpr(e sqlparser.Expr) sqltypes.Type
SQLTypeForExpr returns the sql type of the given expression, with nullable set if the expression is from an outer table.
func (*PlanningContext) TypeForExpr ¶ added in v0.19.5
func (ctx *PlanningContext) TypeForExpr(e sqlparser.Expr) (evalengine.Type, bool)
TypeForExpr returns the type of the given expression, with nullable set if the expression is from an outer table.
func (*PlanningContext) UseMirror ¶ added in v0.21.0
func (ctx *PlanningContext) UseMirror() *PlanningContext
type RecurseExpression ¶ added in v0.21.0
type RecurseExpression struct { JoinPredicateID *predicates.ID Original sqlparser.Expr RightExpr sqlparser.Expr LeftExprs []BindVarExpr }
type VSchema ¶
type VSchema interface { FindTable(tablename sqlparser.TableName) (*vindexes.BaseTable, string, topodatapb.TabletType, key.ShardDestination, error) FindView(name sqlparser.TableName) sqlparser.TableStatement // FindViewTarget finds the target keyspace for the view table provided. FindViewTarget(name sqlparser.TableName) (*vindexes.Keyspace, error) FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.BaseTable, vindexes.Vindex, string, topodatapb.TabletType, key.ShardDestination, error) // SelectedKeyspace returns the current keyspace if set, otherwise returns an error SelectedKeyspace() (*vindexes.Keyspace, error) TargetString() string ShardDestination() key.ShardDestination TabletType() topodatapb.TabletType TargetDestination(qualifier string) (key.ShardDestination, *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 Environment() *vtenv.Environment // 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(keyspace string) (vschemapb.Keyspace_ForeignKeyMode, error) // KeyspaceError returns any error in the keyspace vschema. KeyspaceError(keyspace string) error GetForeignKeyChecksState() *bool // 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, 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) // GetAggregateUDFs returns the list of aggregate UDFs. GetAggregateUDFs() []string // FindMirrorRule finds the mirror rule for the requested keyspace, table // name, and the tablet type in the VSchema. FindMirrorRule(tablename sqlparser.TableName) (*vindexes.MirrorRule, error) // GetBindVars returns the bindvars. If we are executing a prepared statement for the first time, // we re-plan with the bindvar values to see if we find any better plans now that we can see parameter values. // If we find a better plan, we store it, and use it when the bindvars line up GetBindVars() map[string]*querypb.BindVariable }
VSchema defines the interface for this package to fetch info about tables.