Documentation ¶
Overview ¶
Package planbuilder allows you to build execution plans that describe how to fulfill a query that may span multiple keyspaces or shards. The main entry points for this package are Build and BuildFromStmt.
Index ¶
- Constants
- Variables
- func BuildColName(rcs []*resultColumn, index int) (*sqlparser.ColName, error)
- func BuildFromStmt(query string, stmt sqlparser.Statement, reservedVars *sqlparser.ReservedVars, ...) (*engine.Plan, error)
- func GetReturnType(input sqlparser.Expr) (querypb.Type, error)
- func ResultFromNumber(rcs []*resultColumn, val *sqlparser.Literal, caller string) (int, error)
- func TestBuilder(query string, vschema ContextVSchema, keyspace string) (*engine.Plan, error)
- type ContextVSchema
- type PlannerVersion
- type UnsupportedSupplyWeightString
Constants ¶
const ( // V3 is also the default planner V3 = querypb.ExecuteOptions_V3 // Gen4 uses the default Gen4 planner, which is the greedy planner Gen4 = querypb.ExecuteOptions_Gen4 // Gen4GreedyOnly uses only the faster greedy planner Gen4GreedyOnly = querypb.ExecuteOptions_Gen4Greedy // Gen4Left2Right tries to emulate the V3 planner by only joining plans in the order they are listed in the FROM-clause Gen4Left2Right = querypb.ExecuteOptions_Gen4Left2Right // Gen4WithFallback first attempts to use the Gen4 planner, and if that fails, uses the V3 planner instead Gen4WithFallback = querypb.ExecuteOptions_Gen4WithFallback // Gen4CompareV3 executes queries on both Gen4 and V3 to compare their results. Gen4CompareV3 = querypb.ExecuteOptions_Gen4CompareV3 )
const ( ViewDifferentKeyspace string = "Select query does not belong to the same keyspace as the view statement" ViewComplex string = "Complex select queries are not supported in create or alter view statements" DifferentDestinations string = "Tables or Views specified in the query do not belong to the same destination" )
Error messages for CreateView queries
Variables ¶
var ErrPlanNotSupported = errors.New("plan building not supported")
ErrPlanNotSupported is an error for plan building not supported
Functions ¶
func BuildColName ¶
BuildColName builds a *sqlparser.ColName for the resultColumn specified by the index. The built ColName will correctly reference the resultColumn it was built from.
func BuildFromStmt ¶
func BuildFromStmt(query string, stmt sqlparser.Statement, reservedVars *sqlparser.ReservedVars, vschema ContextVSchema, bindVarNeeds *sqlparser.BindVarNeeds, enableOnlineDDL, enableDirectDDL bool) (*engine.Plan, error)
BuildFromStmt builds a plan based on the AST provided.
func GetReturnType ¶ added in v0.10.0
GetReturnType returns the type of the select expression that MySQL will return
func ResultFromNumber ¶
ResultFromNumber returns the result column index based on the column order expression.
func TestBuilder ¶ added in v0.9.0
TestBuilder builds a plan for a query based on the specified vschema. This method is only used from tests
Types ¶
type ContextVSchema ¶
type ContextVSchema interface { FindTable(tablename sqlparser.TableName) (*vindexes.Table, string, topodatapb.TabletType, key.Destination, error) 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) GetSemTable() *semantics.SemTable Planner() PlannerVersion SetPlannerVersion(pv PlannerVersion) // 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 ...interface{}) 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 ...interface{}) // ForeignKeyMode returns the foreign_key flag value ForeignKeyMode() string }
ContextVSchema defines the interface for this package to fetch info about tables.
type PlannerVersion ¶ added in v0.10.0
type PlannerVersion = querypb.ExecuteOptions_PlannerVersion
PlannerVersion is an alias here to make the code more readable
type UnsupportedSupplyWeightString ¶ added in v0.10.0
type UnsupportedSupplyWeightString struct {
Type string
}
UnsupportedSupplyWeightString represents the error where the supplying a weight string is not supported
func (UnsupportedSupplyWeightString) Error ¶ added in v0.10.0
func (err UnsupportedSupplyWeightString) Error() string
Error function implements the error interface
Source Files ¶
- builder.go
- bypass.go
- call_proc.go
- concantenatetree.go
- concatenate.go
- concatenateGen4.go
- ddl.go
- delete.go
- derivedtree.go
- distinct.go
- dml.go
- doc.go
- explain.go
- expr.go
- expression_converter.go
- fallback_planner.go
- filtering.go
- from.go
- gen4_compare_v3_planner.go
- gen4_planner.go
- grouping.go
- horizon_planning.go
- insert.go
- join.go
- joinGen4.go
- jointab.go
- jointree.go
- limit.go
- locktables.go
- logical_plan.go
- memory_sort.go
- memory_sort_gen4.go
- merge_sort.go
- migration.go
- ordered_aggregate.go
- ordering.go
- other_read.go
- postprocess.go
- primitive_builder.go
- project.go
- pullout_subquery.go
- querytree.go
- querytree_transformers.go
- rewrite.go
- route.go
- route_planning.go
- routetree.go
- select.go
- set.go
- show.go
- simple_projection.go
- sql_calc_found_rows.go
- stream.go
- subquerytree.go
- symtab.go
- system_tables.go
- system_variables.go
- union.go
- update.go
- use.go
- vindex_func.go
- vindextree.go