engine

package
v0.17.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 37 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// InsertUnsharded is for routing an insert statement
	// to an unsharded keyspace.
	InsertUnsharded = InsertOpcode(iota)
	// InsertSharded is for routing an insert statement
	// to individual shards. Requires: A list of Values, one
	// for each ColVindex. If the table has an Autoinc column,
	// A Generate subplan must be created.
	InsertSharded
	// InsertSelect is for routing an insert statement
	// based on rows returned from the select statement.
	InsertSelect
)
View Source
const (
	InnerJoin = JoinOpcode(iota)
	LeftJoin
)

This is the list of JoinOpcode values.

View Source
const (
	// SeqVarName is a reserved bind var name for sequence values.
	SeqVarName = "__seq"
	// ListVarName is a reserved bind var name for list vars.
	// This is used for sending different IN clause values
	// to different shards.
	ListVarName = "__vals"
)
View Source
const (
	// Unsharded is for routing a statement
	// to an unsharded keyspace.
	Unsharded = Opcode(iota)
	// EqualUnique is for routing a query to a single shard.
	// Requires: A Unique Vindex, and a single Value.
	EqualUnique
	// Equal is for routing a query using a non-unique vindex.
	// Requires: A Vindex, and a single Value.
	Equal
	// IN is for routing a statement to a multi shard.
	// Requires: A Vindex, and a multi Values.
	IN
	// MultiEqual is used for routing queries with IN with tuple clause
	// Requires: A Vindex, and a multi Tuple Values.
	MultiEqual
	// SubShard is for when we are missing one or more columns from a composite vindex
	SubShard
	// Scatter is for routing a scattered statement.
	Scatter
	// Next is for fetching from a sequence.
	Next
	// DBA is used for routing DBA queries
	// e.g: Select * from information_schema.tables where schema_name = "a"
	DBA
	// Reference is for fetching from a reference table.
	Reference
	// None is used for queries which do not need routing
	None
	// ByDestination is to route explicitly to a given target destination.
	// Is used when the query explicitly sets a target destination:
	// in the clause e.g: UPDATE `keyspace[-]`.x1 SET foo=1
	ByDestination
)

This is the list of Opcode values.

View Source
const (
	VindexNone = VindexOpcode(iota)
	VindexMap
	NumVindexCodes
)

These are opcode values for VindexFunc.

View Source
const (
	RowChangeInsert string = "+"
	RowChangeDelete string = "-"
	RowChangeUpdate string = "*"
)

for demo purposes we prefix the row with a column with a single char +/*/- to indicate why the row changed + => insert, - => delete, * => update. This will be removed/improved as we iterate over this functionality

View Source
const (
	IgnoreReserveTxn cxtKey = iota
)
View Source
const ShardName = "__vt_shard"

ShardName as key for setting shard name in bind variables map

Variables

This section is empty.

Functions

func CompareErrors added in v0.16.0

func CompareErrors(leftErr, rightErr error, leftName, rightName string) error

CompareErrors compares the two errors, and if they don't match, produces an error

func DBDDLRegister added in v0.10.0

func DBDDLRegister(name string, plugin DBDDLPlugin)

DBDDLRegister registers a dbDDL plugin under the specified name. A duplicate plugin will generate a panic.

func Exists

func Exists(m Match, p Primitive) bool

Exists traverses recursively down the Primitive tree structure, and returns true when Match returns true

func GenericJoin

func GenericJoin(input any, f func(any) string) string

GenericJoin will iterate over arrays, slices or maps, and executes the f function to get a string representation of each element, and then uses strings.Join() join all the strings into a single one

func GraphViz added in v0.15.0

func GraphViz(p Primitive) (*graphviz.Graph, error)

func InsertVarName

func InsertVarName(col sqlparser.IdentifierCI, rowNum int) string

InsertVarName returns a name for the bind var for this column. This method is used by the planner and engine, to make sure they both produce the same names

Types

type AggregateParams

type AggregateParams struct {
	Opcode AggregateOpcode
	Col    int

	// These are used only for distinct opcodes.
	KeyCol      int
	WCol        int
	WAssigned   bool
	CollationID collations.ID

	Alias    string `json:",omitempty"`
	Expr     sqlparser.Expr
	Original *sqlparser.AliasedExpr

	// This is based on the function passed in the select expression and
	// not what we use to aggregate at the engine primitive level.
	OrigOpcode AggregateOpcode
}

AggregateParams specify the parameters for each aggregation. It contains the opcode and input column number.

func (*AggregateParams) CachedSize added in v0.10.0

func (cached *AggregateParams) CachedSize(alloc bool) int64

func (*AggregateParams) String

func (ap *AggregateParams) String() string

type AlterVSchema

type AlterVSchema struct {
	Keyspace *vindexes.Keyspace

	AlterVschemaDDL *sqlparser.AlterVschema
	// contains filtered or unexported fields
}

AlterVSchema operator applies changes to VSchema

func (*AlterVSchema) CachedSize added in v0.10.0

func (cached *AlterVSchema) CachedSize(alloc bool) int64

func (*AlterVSchema) GetFields

func (v *AlterVSchema) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*AlterVSchema) GetKeyspaceName

func (v *AlterVSchema) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*AlterVSchema) GetTableName

func (v *AlterVSchema) GetTableName() string

GetTableName implements the Primitive interface

func (AlterVSchema) Inputs

func (AlterVSchema) Inputs() []Primitive

Inputs implements no inputs

func (AlterVSchema) NeedsTransaction

func (AlterVSchema) NeedsTransaction() bool

func (*AlterVSchema) RouteType

func (v *AlterVSchema) RouteType() string

RouteType implements the Primitive interface

func (*AlterVSchema) TryExecute added in v0.12.0

func (v *AlterVSchema) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*AlterVSchema) TryStreamExecute added in v0.12.0

func (v *AlterVSchema) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type CheckCol added in v0.14.0

type CheckCol struct {
	Col       int
	WsCol     *int
	Collation collations.ID
}

func (*CheckCol) CachedSize added in v0.14.0

func (cached *CheckCol) CachedSize(alloc bool) int64

func (CheckCol) String added in v0.14.0

func (cc CheckCol) String() string

func (CheckCol) SwitchToWeightString added in v0.14.0

func (cc CheckCol) SwitchToWeightString() CheckCol

SwitchToWeightString returns a new CheckCol that works on the weight string column instead

type Concatenate

type Concatenate struct {
	Sources []Primitive

	// These column offsets do not need to be typed checked - they usually contain weight_string()
	// columns that are not going to be returned to the user
	NoNeedToTypeCheck map[int]any
}

Concatenate specified the parameter for concatenate primitive

func NewConcatenate added in v0.14.0

func NewConcatenate(Sources []Primitive, ignoreCols []int) *Concatenate

NewConcatenate creates a Concatenate primitive. The ignoreCols slice contains the offsets that don't need to have the same type between sources - weight_string() sometimes returns VARBINARY and sometimes VARCHAR

func (*Concatenate) CachedSize added in v0.10.0

func (cached *Concatenate) CachedSize(alloc bool) int64

func (*Concatenate) GetFields

func (c *Concatenate) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*Concatenate) GetKeyspaceName

func (c *Concatenate) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to

func (*Concatenate) GetTableName

func (c *Concatenate) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*Concatenate) Inputs

func (c *Concatenate) Inputs() []Primitive

Inputs returns the input primitives for this

func (*Concatenate) NeedsTransaction

func (c *Concatenate) NeedsTransaction() bool

NeedsTransaction returns whether a transaction is needed for this primitive

func (*Concatenate) RouteType

func (c *Concatenate) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*Concatenate) TryExecute added in v0.12.0

func (c *Concatenate) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*Concatenate) TryStreamExecute added in v0.12.0

func (c *Concatenate) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type DBDDL added in v0.10.0

type DBDDL struct {
	// contains filtered or unexported fields
}

DBDDL is just a container around custom database provisioning plugins The default behaviour is to just return an error

func NewDBDDL added in v0.10.0

func NewDBDDL(dbName string, create bool, timeout int) *DBDDL

NewDBDDL creates the engine primitive `create` will be true for CREATE, and false for DROP

func (*DBDDL) CachedSize added in v0.10.0

func (cached *DBDDL) CachedSize(alloc bool) int64

func (*DBDDL) GetFields added in v0.10.0

GetFields implements the Primitive interface

func (*DBDDL) GetKeyspaceName added in v0.10.0

func (c *DBDDL) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*DBDDL) GetTableName added in v0.10.0

func (c *DBDDL) GetTableName() string

GetTableName implements the Primitive interface

func (DBDDL) Inputs added in v0.10.0

func (DBDDL) Inputs() []Primitive

Inputs implements no inputs

func (DBDDL) NeedsTransaction added in v0.10.0

func (DBDDL) NeedsTransaction() bool

func (*DBDDL) RouteType added in v0.10.0

func (c *DBDDL) RouteType() string

RouteType implements the Primitive interface

func (*DBDDL) TryExecute added in v0.12.0

func (c *DBDDL) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*DBDDL) TryStreamExecute added in v0.12.0

func (c *DBDDL) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type DBDDLPlugin added in v0.10.0

type DBDDLPlugin interface {
	CreateDatabase(ctx context.Context, name string) error
	DropDatabase(ctx context.Context, name string) error
}

DBDDLPlugin is the interface that you need to implement to add a custom CREATE/DROP DATABASE handler

type DDL added in v0.9.0

type DDL struct {
	Keyspace *vindexes.Keyspace
	SQL      string
	DDL      sqlparser.DDLStatement

	NormalDDL *Send
	OnlineDDL *OnlineDDL

	DirectDDLEnabled bool
	OnlineDDLEnabled bool

	CreateTempTable bool
	// contains filtered or unexported fields
}

DDL represents a DDL statement, either normal or online DDL

func (*DDL) CachedSize added in v0.10.0

func (cached *DDL) CachedSize(alloc bool) int64

func (*DDL) GetFields added in v0.9.0

func (ddl *DDL) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*DDL) GetKeyspaceName added in v0.9.0

func (ddl *DDL) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*DDL) GetTableName added in v0.9.0

func (ddl *DDL) GetTableName() string

GetTableName implements the Primitive interface

func (DDL) Inputs added in v0.9.0

func (DDL) Inputs() []Primitive

Inputs implements no inputs

func (DDL) NeedsTransaction added in v0.9.0

func (DDL) NeedsTransaction() bool

func (*DDL) RouteType added in v0.9.0

func (ddl *DDL) RouteType() string

RouteType implements the Primitive interface

func (*DDL) TryExecute added in v0.12.0

func (ddl *DDL) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (result *sqltypes.Result, err error)

TryExecute implements the Primitive interface

func (*DDL) TryStreamExecute added in v0.12.0

func (ddl *DDL) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type DML

type DML struct {
	// Query specifies the query to be executed.
	Query string

	// KsidVindex is primary Vindex
	KsidVindex vindexes.Vindex

	// KsidLength is number of columns that represents KsidVindex
	KsidLength int

	// Table specifies the table for the update.
	Table []*vindexes.Table

	// OwnedVindexQuery is used for updating changes in lookup vindexes.
	OwnedVindexQuery string

	// Option to override the standard behavior and allow a multi-shard update
	// to use single round trip autocommit.
	MultiShardAutocommit bool

	// QueryTimeout contains the optional timeout (in milliseconds) to apply to this query
	QueryTimeout int

	// RoutingParameters parameters required for query routing.
	*RoutingParameters
	// contains filtered or unexported fields
}

DML contains the common elements between Update and Delete plans

func NewDML added in v0.13.0

func NewDML() *DML

NewDML returns and empty initialized DML struct.

func (*DML) CachedSize added in v0.10.0

func (cached *DML) CachedSize(alloc bool) int64

func (*DML) GetKeyspaceName added in v0.15.0

func (dml *DML) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*DML) GetSingleTable added in v0.15.0

func (dml *DML) GetSingleTable() (*vindexes.Table, error)

GetSingleTable returns single table used in dml.

func (*DML) GetTableName added in v0.15.0

func (dml *DML) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (DML) NeedsTransaction

func (DML) NeedsTransaction() bool

func (*DML) RouteType added in v0.15.0

func (dml *DML) RouteType() string

RouteType returns a description of the query routing type used by the primitive

type Delete

type Delete struct {
	*DML
	// contains filtered or unexported fields
}

Delete represents the instructions to perform a delete.

func (*Delete) CachedSize added in v0.10.0

func (cached *Delete) CachedSize(alloc bool) int64

func (*Delete) GetFields

GetFields fetches the field info.

func (Delete) Inputs

func (Delete) Inputs() []Primitive

Inputs implements no inputs

func (Delete) NeedsTransaction

func (Delete) NeedsTransaction() bool

func (*Delete) TryExecute added in v0.12.0

func (del *Delete) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, _ bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*Delete) TryStreamExecute added in v0.12.0

func (del *Delete) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type Distinct added in v0.9.0

type Distinct struct {
	Source    Primitive
	CheckCols []CheckCol
	Truncate  int
}

Distinct Primitive is used to uniqueify results

func (*Distinct) CachedSize added in v0.10.0

func (cached *Distinct) CachedSize(alloc bool) int64

func (*Distinct) GetFields added in v0.9.0

func (d *Distinct) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*Distinct) GetKeyspaceName added in v0.9.0

func (d *Distinct) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*Distinct) GetTableName added in v0.9.0

func (d *Distinct) GetTableName() string

GetTableName implements the Primitive interface

func (*Distinct) Inputs added in v0.9.0

func (d *Distinct) Inputs() []Primitive

Inputs implements the Primitive interface

func (*Distinct) NeedsTransaction added in v0.9.0

func (d *Distinct) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*Distinct) RouteType added in v0.9.0

func (d *Distinct) RouteType() string

RouteType implements the Primitive interface

func (*Distinct) TryExecute added in v0.12.0

func (d *Distinct) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*Distinct) TryStreamExecute added in v0.12.0

func (d *Distinct) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type DistinctV3 added in v0.14.0

type DistinctV3 struct {
	Source Primitive
}

Distinct Primitive is used to uniqueify results

func (*DistinctV3) CachedSize added in v0.14.0

func (cached *DistinctV3) CachedSize(alloc bool) int64

func (*DistinctV3) GetFields added in v0.14.0

func (d *DistinctV3) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*DistinctV3) GetKeyspaceName added in v0.14.0

func (d *DistinctV3) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*DistinctV3) GetTableName added in v0.14.0

func (d *DistinctV3) GetTableName() string

GetTableName implements the Primitive interface

func (*DistinctV3) Inputs added in v0.14.0

func (d *DistinctV3) Inputs() []Primitive

Inputs implements the Primitive interface

func (*DistinctV3) NeedsTransaction added in v0.14.0

func (d *DistinctV3) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*DistinctV3) RouteType added in v0.14.0

func (d *DistinctV3) RouteType() string

RouteType implements the Primitive interface

func (*DistinctV3) TryExecute added in v0.14.0

func (d *DistinctV3) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*DistinctV3) TryStreamExecute added in v0.14.0

func (d *DistinctV3) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type ExecStmt added in v0.17.0

type ExecStmt struct {
	Params []*sqlparser.Variable
	Input  Primitive
	// contains filtered or unexported fields
}

func (*ExecStmt) CachedSize added in v0.17.0

func (cached *ExecStmt) CachedSize(alloc bool) int64

func (*ExecStmt) GetFields added in v0.17.0

func (e *ExecStmt) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

func (*ExecStmt) GetKeyspaceName added in v0.17.0

func (e *ExecStmt) GetKeyspaceName() string

func (*ExecStmt) GetTableName added in v0.17.0

func (e *ExecStmt) GetTableName() string

func (*ExecStmt) Inputs added in v0.17.0

func (e *ExecStmt) Inputs() []Primitive

func (ExecStmt) NeedsTransaction added in v0.17.0

func (ExecStmt) NeedsTransaction() bool

func (*ExecStmt) RouteType added in v0.17.0

func (e *ExecStmt) RouteType() string

func (*ExecStmt) TryExecute added in v0.17.0

func (e *ExecStmt) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

func (*ExecStmt) TryStreamExecute added in v0.17.0

func (e *ExecStmt) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

type ExecuteEntry added in v0.15.0

type ExecuteEntry struct {
	ID        int
	Target    *querypb.Target
	Gateway   srvtopo.Gateway
	Query     string
	FiredFrom Primitive
}

type Filter added in v0.13.0

type Filter struct {
	Predicate    evalengine.Expr
	ASTPredicate sqlparser.Expr
	Input        Primitive
	// contains filtered or unexported fields
}

Filter is a primitive that performs the FILTER operation.

func (*Filter) CachedSize added in v0.13.0

func (cached *Filter) CachedSize(alloc bool) int64

func (*Filter) GetFields added in v0.13.0

func (f *Filter) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface.

func (*Filter) GetKeyspaceName added in v0.13.0

func (f *Filter) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*Filter) GetTableName added in v0.13.0

func (f *Filter) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*Filter) Inputs added in v0.13.0

func (f *Filter) Inputs() []Primitive

Inputs returns the input to limit

func (Filter) NeedsTransaction added in v0.13.0

func (Filter) NeedsTransaction() bool

func (*Filter) RouteType added in v0.13.0

func (f *Filter) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*Filter) TryExecute added in v0.13.0

func (f *Filter) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute satisfies the Primitive interface.

func (*Filter) TryStreamExecute added in v0.13.0

func (f *Filter) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute satisfies the Primitive interface.

type Gen4CompareV3 added in v0.12.0

type Gen4CompareV3 struct {
	V3, Gen4   Primitive
	HasOrderBy bool
}

Gen4CompareV3 is a Primitive used to compare V3 and Gen4's plans.

func (*Gen4CompareV3) CachedSize added in v0.12.0

func (cached *Gen4CompareV3) CachedSize(alloc bool) int64

func (*Gen4CompareV3) GetFields added in v0.12.0

func (gc *Gen4CompareV3) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*Gen4CompareV3) GetGen4Primitive added in v0.12.0

func (gc *Gen4CompareV3) GetGen4Primitive() Primitive

GetGen4Primitive implements the Gen4Comparer interface

func (*Gen4CompareV3) GetKeyspaceName added in v0.12.0

func (gc *Gen4CompareV3) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*Gen4CompareV3) GetTableName added in v0.12.0

func (gc *Gen4CompareV3) GetTableName() string

GetTableName implements the Primitive interface

func (*Gen4CompareV3) Inputs added in v0.12.0

func (gc *Gen4CompareV3) Inputs() []Primitive

Inputs implements the Primitive interface

func (*Gen4CompareV3) NeedsTransaction added in v0.12.0

func (gc *Gen4CompareV3) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*Gen4CompareV3) RouteType added in v0.12.0

func (gc *Gen4CompareV3) RouteType() string

RouteType implements the Primitive interface

func (*Gen4CompareV3) TryExecute added in v0.12.0

func (gc *Gen4CompareV3) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*Gen4CompareV3) TryStreamExecute added in v0.12.0

func (gc *Gen4CompareV3) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type Gen4Comparer added in v0.12.0

type Gen4Comparer interface {
	Primitive
	GetGen4Primitive() Primitive
}

Gen4Comparer interfaces all Primitive used to compare Gen4 with other planners (V3, MySQL, ...).

type Generate

type Generate struct {
	Keyspace *vindexes.Keyspace
	Query    string
	// Values are the supplied values for the column, which
	// will be stored as a list within the expression. New
	// values will be generated based on how many were not
	// supplied (NULL).
	Values evalengine.Expr
	// Insert using Select, offset for auto increment column
	Offset int
}

Generate represents the instruction to generate a value from a sequence.

func (*Generate) CachedSize added in v0.10.0

func (cached *Generate) CachedSize(alloc bool) int64

type GroupByParams added in v0.12.0

type GroupByParams struct {
	KeyCol          int
	WeightStringCol int
	Expr            sqlparser.Expr
	FromGroupBy     bool
	CollationID     collations.ID
}

GroupByParams specify the grouping key to be used.

func (*GroupByParams) CachedSize added in v0.12.0

func (cached *GroupByParams) CachedSize(alloc bool) int64

func (GroupByParams) String added in v0.12.0

func (gbp GroupByParams) String() string

String returns a string. Used for plan descriptions

type HashJoin added in v0.13.0

type HashJoin struct {
	Opcode JoinOpcode

	// Left and Right are the LHS and RHS primitives
	// of the Join. They can be any primitive.
	Left, Right Primitive `json:",omitempty"`

	// Cols defines which columns from the left
	// or right results should be used to build the
	// return result. For results coming from the
	// left query, the index values go as -1, -2, etc.
	// For the right query, they're 1, 2, etc.
	// If Cols is {-1, -2, 1, 2}, it means that
	// the returned result will be {Left0, Left1, Right0, Right1}.
	Cols []int `json:",omitempty"`

	// The keys correspond to the column offset in the inputs where
	// the join columns can be found
	LHSKey, RHSKey int

	// The join condition. Used for plan descriptions
	ASTPred sqlparser.Expr

	// collation and type are used to hash the incoming values correctly
	Collation      collations.ID
	ComparisonType querypb.Type
}

HashJoin specifies the parameters for a join primitive Hash joins work by fetch all the input from the LHS, and building a hash map, known as the probe table, for this input. The key to the map is the hashcode of the value for column that we are joining by. Then the RHS is fetched, and we can check if the rows from the RHS matches any from the LHS. When they match by hash code, we double-check that we are not working with a false positive by comparing the values.

func (*HashJoin) CachedSize added in v0.13.0

func (cached *HashJoin) CachedSize(alloc bool) int64

func (*HashJoin) GetFields added in v0.13.0

func (hj *HashJoin) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*HashJoin) GetKeyspaceName added in v0.13.0

func (hj *HashJoin) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*HashJoin) GetTableName added in v0.13.0

func (hj *HashJoin) GetTableName() string

GetTableName implements the Primitive interface

func (*HashJoin) Inputs added in v0.13.0

func (hj *HashJoin) Inputs() []Primitive

Inputs implements the Primitive interface

func (*HashJoin) NeedsTransaction added in v0.13.0

func (hj *HashJoin) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*HashJoin) RouteType added in v0.13.0

func (hj *HashJoin) RouteType() string

RouteType implements the Primitive interface

func (*HashJoin) TryExecute added in v0.13.0

func (hj *HashJoin) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*HashJoin) TryStreamExecute added in v0.13.0

func (hj *HashJoin) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type Insert

type Insert struct {
	// Opcode is the execution opcode.
	Opcode InsertOpcode

	// Ignore is for INSERT IGNORE and INSERT...ON DUPLICATE KEY constructs
	// for sharded cases.
	Ignore bool

	// Keyspace specifies the keyspace to send the query to.
	Keyspace *vindexes.Keyspace

	// Query specifies the query to be executed.
	// For InsertSharded plans, this value is unused,
	// and Prefix, Mid and Suffix are used instead.
	Query string

	// VindexValues specifies values for all the vindex columns.
	// This is a three-dimensional data structure:
	// Insert.Values[i] represents the values to be inserted for the i'th colvindex (i < len(Insert.Table.ColumnVindexes))
	// Insert.Values[i].Values[j] represents values for the j'th column of the given colVindex (j < len(colVindex[i].Columns)
	// Insert.Values[i].Values[j].Values[k] represents the value pulled from row k for that column: (k < len(ins.rows))
	VindexValues [][][]evalengine.Expr

	// ColVindexes are the vindexes that will use the VindexValues
	ColVindexes []*vindexes.ColumnVindex

	// Table specifies the table for the insert.
	Table *vindexes.Table

	// Generate is only set for inserts where a sequence must be generated.
	Generate *Generate

	// Prefix, Mid and Suffix are for sharded insert plans.
	Prefix string
	Mid    []string
	Suffix string

	// Option to override the standard behavior and allow a multi-shard insert
	// to use single round trip autocommit.
	//
	// This is a clear violation of the SQL semantics since it means the statement
	// is not atomic in the presence of PK conflicts on one shard and not another.
	// However some application use cases would prefer that the statement partially
	// succeed in order to get the performance benefits of autocommit.
	MultiShardAutocommit bool

	// QueryTimeout contains the optional timeout (in milliseconds) to apply to this query
	QueryTimeout int

	// VindexValueOffset stores the offset for each column in the ColumnVindex
	// that will appear in the result set of the select query.
	VindexValueOffset [][]int

	// Input is a select query plan to retrieve results for inserting data.
	Input Primitive `json:",omitempty"`

	// ForceNonStreaming is true when the insert table and select table are same.
	// This will avoid locking by the select table.
	ForceNonStreaming bool
	// contains filtered or unexported fields
}

Insert represents the instructions to perform an insert operation.

func NewInsert

func NewInsert(
	opcode InsertOpcode,
	ignore bool,
	keyspace *vindexes.Keyspace,
	vindexValues [][][]evalengine.Expr,
	table *vindexes.Table,
	prefix string,
	mid []string,
	suffix string,
) *Insert

NewInsert creates a new Insert.

func NewQueryInsert

func NewQueryInsert(opcode InsertOpcode, keyspace *vindexes.Keyspace, query string) *Insert

NewQueryInsert creates an Insert with a query string.

func NewSimpleInsert

func NewSimpleInsert(opcode InsertOpcode, table *vindexes.Table, keyspace *vindexes.Keyspace) *Insert

NewSimpleInsert creates an Insert for a Table.

func (*Insert) CachedSize added in v0.10.0

func (cached *Insert) CachedSize(alloc bool) int64

func (*Insert) GetFields

GetFields fetches the field info.

func (*Insert) GetKeyspaceName

func (ins *Insert) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*Insert) GetTableName

func (ins *Insert) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*Insert) Inputs

func (ins *Insert) Inputs() []Primitive

func (Insert) NeedsTransaction

func (Insert) NeedsTransaction() bool

func (*Insert) RouteType

func (ins *Insert) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*Insert) TryExecute added in v0.12.0

func (ins *Insert) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*Insert) TryStreamExecute added in v0.12.0

func (ins *Insert) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type InsertOpcode

type InsertOpcode int

InsertOpcode is a number representing the opcode for the Insert primitive.

func (InsertOpcode) MarshalJSON

func (code InsertOpcode) MarshalJSON() ([]byte, error)

MarshalJSON serializes the InsertOpcode as a JSON string. It's used for testing and diagnostics.

func (InsertOpcode) String

func (code InsertOpcode) String() string

String returns the opcode

type Join

type Join struct {
	Opcode JoinOpcode
	// Left and Right are the LHS and RHS primitives
	// of the Join. They can be any primitive.
	Left, Right Primitive `json:",omitempty"`

	// Cols defines which columns from the left
	// or right results should be used to build the
	// return result. For results coming from the
	// left query, the index values go as -1, -2, etc.
	// For the right query, they're 1, 2, etc.
	// If Cols is {-1, -2, 1, 2}, it means that
	// the returned result will be {Left0, Left1, Right0, Right1}.
	Cols []int `json:",omitempty"`

	// Vars defines the list of joinVars that need to
	// be built from the LHS result before invoking
	// the RHS subqquery.
	Vars map[string]int `json:",omitempty"`
}

Join specifies the parameters for a join primitive.

func (*Join) CachedSize added in v0.10.0

func (cached *Join) CachedSize(alloc bool) int64

func (*Join) GetFields

func (jn *Join) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*Join) GetKeyspaceName

func (jn *Join) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*Join) GetTableName

func (jn *Join) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*Join) Inputs

func (jn *Join) Inputs() []Primitive

Inputs returns the input primitives for this join

func (*Join) NeedsTransaction

func (jn *Join) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*Join) RouteType

func (jn *Join) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*Join) TryExecute added in v0.12.0

func (jn *Join) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*Join) TryStreamExecute added in v0.12.0

func (jn *Join) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type JoinOpcode

type JoinOpcode int

JoinOpcode is a number representing the opcode for the Join primitive.

func (JoinOpcode) MarshalJSON

func (code JoinOpcode) MarshalJSON() ([]byte, error)

MarshalJSON serializes the JoinOpcode as a JSON string. It's used for testing and diagnostics.

func (JoinOpcode) String

func (code JoinOpcode) String() string

type Limit

type Limit struct {
	Count  evalengine.Expr
	Offset evalengine.Expr
	Input  Primitive
}

Limit is a primitive that performs the LIMIT operation.

func (*Limit) CachedSize added in v0.10.0

func (cached *Limit) CachedSize(alloc bool) int64

func (*Limit) GetFields

func (l *Limit) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface.

func (*Limit) GetKeyspaceName

func (l *Limit) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*Limit) GetTableName

func (l *Limit) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*Limit) Inputs

func (l *Limit) Inputs() []Primitive

Inputs returns the input to limit

func (*Limit) NeedsTransaction

func (l *Limit) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface.

func (*Limit) RouteType

func (l *Limit) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*Limit) TryExecute added in v0.12.0

func (l *Limit) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute satisfies the Primitive interface.

func (*Limit) TryStreamExecute added in v0.12.0

func (l *Limit) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute satisfies the Primitive interface.

type Lock added in v0.8.0

type Lock struct {
	// Keyspace specifies the keyspace to send the query to.
	Keyspace *vindexes.Keyspace

	// TargetDestination specifies an explicit target destination to send the query to.
	TargetDestination key.Destination

	FieldQuery string

	LockFunctions []*LockFunc
	// contains filtered or unexported fields
}

Lock primitive will execute sql containing lock functions

func (*Lock) CachedSize added in v0.10.0

func (cached *Lock) CachedSize(alloc bool) int64

func (*Lock) GetFields added in v0.8.0

func (l *Lock) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields is part of the Primitive interface

func (*Lock) GetKeyspaceName added in v0.8.0

func (l *Lock) GetKeyspaceName() string

GetKeyspaceName is part of the Primitive interface

func (*Lock) GetTableName added in v0.8.0

func (l *Lock) GetTableName() string

GetTableName is part of the Primitive interface

func (Lock) Inputs added in v0.8.0

func (Lock) Inputs() []Primitive

Inputs implements no inputs

func (Lock) NeedsTransaction added in v0.8.0

func (Lock) NeedsTransaction() bool

func (*Lock) RouteType added in v0.8.0

func (l *Lock) RouteType() string

RouteType is part of the Primitive interface

func (*Lock) TryExecute added in v0.12.0

func (l *Lock) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute is part of the Primitive interface

func (*Lock) TryStreamExecute added in v0.12.0

func (l *Lock) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute is part of the Primitive interface

type LockFunc added in v0.14.0

type LockFunc struct {
	Typ  *sqlparser.LockingFunc
	Name evalengine.Expr
}

func (*LockFunc) CachedSize added in v0.14.0

func (cached *LockFunc) CachedSize(alloc bool) int64

type MStream added in v0.11.0

type MStream struct {
	// Keyspace specifies the keyspace to stream messages from
	Keyspace *vindexes.Keyspace

	// TargetDestination specifies an explicit target destination to stream messages from
	TargetDestination key.Destination

	// TableName specifies the table on which stream will be executed.
	TableName string
	// contains filtered or unexported fields
}

MStream is an operator for message streaming from specific keyspace, destination

func (*MStream) CachedSize added in v0.11.0

func (cached *MStream) CachedSize(alloc bool) int64

func (*MStream) GetFields added in v0.11.0

func (m *MStream) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*MStream) GetKeyspaceName added in v0.11.0

func (m *MStream) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*MStream) GetTableName added in v0.11.0

func (m *MStream) GetTableName() string

GetTableName implements the Primitive interface

func (MStream) Inputs added in v0.11.0

func (MStream) Inputs() []Primitive

Inputs implements no inputs

func (MStream) NeedsTransaction added in v0.11.0

func (MStream) NeedsTransaction() bool

func (*MStream) RouteType added in v0.11.0

func (m *MStream) RouteType() string

RouteType implements the Primitive interface

func (*MStream) TryExecute added in v0.12.0

func (m *MStream) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*MStream) TryStreamExecute added in v0.12.0

func (m *MStream) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type Match

type Match func(node Primitive) bool

Match is used to check if a Primitive matches

type MemorySort

type MemorySort struct {
	UpperLimit evalengine.Expr
	OrderBy    []OrderByParams
	Input      Primitive

	// TruncateColumnCount specifies the number of columns to return
	// in the final result. Rest of the columns are truncated
	// from the result received. If 0, no truncation happens.
	TruncateColumnCount int `json:",omitempty"`
}

MemorySort is a primitive that performs in-memory sorting.

func (*MemorySort) CachedSize added in v0.10.0

func (cached *MemorySort) CachedSize(alloc bool) int64

func (*MemorySort) GetFields

func (ms *MemorySort) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields satisfies the Primitive interface.

func (*MemorySort) GetKeyspaceName

func (ms *MemorySort) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*MemorySort) GetTableName

func (ms *MemorySort) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*MemorySort) Inputs

func (ms *MemorySort) Inputs() []Primitive

Inputs returns the input to memory sort

func (*MemorySort) NeedsTransaction

func (ms *MemorySort) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*MemorySort) RouteType

func (ms *MemorySort) RouteType() string

RouteType returns a description of the query routing type used by the primitive.

func (*MemorySort) SetTruncateColumnCount

func (ms *MemorySort) SetTruncateColumnCount(count int)

SetTruncateColumnCount sets the truncate column count.

func (*MemorySort) TryExecute added in v0.12.0

func (ms *MemorySort) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute satisfies the Primitive interface.

func (*MemorySort) TryStreamExecute added in v0.12.0

func (ms *MemorySort) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute satisfies the Primitive interface.

type MergeSort

type MergeSort struct {
	Primitives              []StreamExecutor
	OrderBy                 []OrderByParams
	ScatterErrorsAsWarnings bool
	// contains filtered or unexported fields
}

MergeSort performs a merge-sort of rows returned by each Input. This should only be used for StreamExecute. One row from each stream is added to the merge-sorter heap. Every time a value is pulled out of the heap, a new value is added to it from the stream that was the source of the value that was pulled out. Since the input streams are sorted the same way that the heap is sorted, this guarantees that the merged stream will also be sorted the same way. MergeSort only supports the StreamExecute function of a Primitive. So, it cannot be used like other Primitives in VTGate. However, it satisfies the Primitive API so that vdiff can use it. In that situation, only StreamExecute is used.

func (*MergeSort) CachedSize added in v0.10.0

func (cached *MergeSort) CachedSize(alloc bool) int64

func (*MergeSort) GetFields

func (ms *MergeSort) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields is not supported.

func (*MergeSort) GetKeyspaceName

func (ms *MergeSort) GetKeyspaceName() string

GetKeyspaceName satisfies Primitive.

func (*MergeSort) GetTableName

func (ms *MergeSort) GetTableName() string

GetTableName satisfies Primitive.

func (MergeSort) Inputs

func (MergeSort) Inputs() []Primitive

Inputs implements no inputs

func (MergeSort) NeedsTransaction

func (MergeSort) NeedsTransaction() bool

func (*MergeSort) RouteType

func (ms *MergeSort) RouteType() string

RouteType satisfies Primitive.

func (*MergeSort) TryExecute added in v0.12.0

func (ms *MergeSort) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute is not supported.

func (*MergeSort) TryStreamExecute added in v0.12.0

func (ms *MergeSort) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type OnlineDDL added in v0.8.0

type OnlineDDL struct {
	Keyspace           *vindexes.Keyspace
	DDL                sqlparser.DDLStatement
	SQL                string
	DDLStrategySetting *schema.DDLStrategySetting
	// TargetDestination specifies an explicit target destination to send the query to.
	TargetDestination key.Destination
	// contains filtered or unexported fields
}

OnlineDDL represents the instructions to perform an online schema change via vtctld

func (*OnlineDDL) CachedSize added in v0.10.0

func (cached *OnlineDDL) CachedSize(alloc bool) int64

func (*OnlineDDL) GetFields added in v0.8.0

func (v *OnlineDDL) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*OnlineDDL) GetKeyspaceName added in v0.8.0

func (v *OnlineDDL) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*OnlineDDL) GetTableName added in v0.8.0

func (v *OnlineDDL) GetTableName() string

GetTableName implements the Primitive interface

func (OnlineDDL) Inputs added in v0.8.0

func (OnlineDDL) Inputs() []Primitive

Inputs implements no inputs

func (OnlineDDL) NeedsTransaction added in v0.8.0

func (OnlineDDL) NeedsTransaction() bool

func (*OnlineDDL) RouteType added in v0.8.0

func (v *OnlineDDL) RouteType() string

RouteType implements the Primitive interface

func (*OnlineDDL) TryExecute added in v0.12.0

func (v *OnlineDDL) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (result *sqltypes.Result, err error)

TryExecute implements the Primitive interface

func (*OnlineDDL) TryStreamExecute added in v0.12.0

func (v *OnlineDDL) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type Opcode added in v0.13.0

type Opcode int

Opcode is a number representing the opcode for any engine primitve.

func (Opcode) IsSingleShard added in v0.13.2

func (code Opcode) IsSingleShard() bool

func (Opcode) MarshalJSON added in v0.13.0

func (code Opcode) MarshalJSON() ([]byte, error)

MarshalJSON serializes the Opcode as a JSON string. It's used for testing and diagnostics.

func (Opcode) String added in v0.13.0

func (code Opcode) String() string

String returns a string presentation of this opcode

type OrderByParams added in v0.12.0

type OrderByParams struct {
	Col int
	// WeightStringCol is the weight_string column that will be used for sorting.
	// It is set to -1 if such a column is not added to the query
	WeightStringCol   int
	Desc              bool
	StarColFixedIndex int
	// v3 specific boolean. Used to also add weight strings originating from GroupBys to the Group by clause
	FromGroupBy bool
	// Collation ID for comparison using collation
	CollationID collations.ID
}

OrderByParams specifies the parameters for ordering. This is used for merge-sorting scatter queries.

func (OrderByParams) String added in v0.12.0

func (obp OrderByParams) String() string

String returns a string. Used for plan descriptions

type OrderedAggregate

type OrderedAggregate struct {
	// PreProcess is true if one of the aggregates needs preprocessing.
	PreProcess bool `json:",omitempty"`

	// Aggregates specifies the aggregation parameters for each
	// aggregation function: function opcode and input column number.
	Aggregates []*AggregateParams

	AggrOnEngine bool

	// GroupByKeys specifies the input values that must be used for
	// the aggregation key.
	GroupByKeys []*GroupByParams

	// TruncateColumnCount specifies the number of columns to return
	// in the final result. Rest of the columns are truncated
	// from the result received. If 0, no truncation happens.
	TruncateColumnCount int `json:",omitempty"`

	// Input is the primitive that will feed into this Primitive.
	Input Primitive
}

OrderedAggregate is a primitive that expects the underlying primitive to feed results in an order sorted by the Keys. Rows with duplicate keys are aggregated using the Aggregate functions. The assumption is that the underlying primitive is a scatter select with pre-sorted rows.

func (*OrderedAggregate) CachedSize added in v0.10.0

func (cached *OrderedAggregate) CachedSize(alloc bool) int64

func (*OrderedAggregate) GetFields

func (oa *OrderedAggregate) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields is a Primitive function.

func (*OrderedAggregate) GetKeyspaceName

func (oa *OrderedAggregate) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*OrderedAggregate) GetTableName

func (oa *OrderedAggregate) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*OrderedAggregate) Inputs

func (oa *OrderedAggregate) Inputs() []Primitive

Inputs returns the Primitive input for this aggregation

func (*OrderedAggregate) NeedsTransaction

func (oa *OrderedAggregate) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*OrderedAggregate) RouteType

func (oa *OrderedAggregate) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*OrderedAggregate) SetTruncateColumnCount

func (oa *OrderedAggregate) SetTruncateColumnCount(count int)

SetTruncateColumnCount sets the truncate column count.

func (*OrderedAggregate) TryExecute added in v0.12.0

func (oa *OrderedAggregate) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute is a Primitive function.

func (*OrderedAggregate) TryStreamExecute added in v0.12.0

func (oa *OrderedAggregate) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute is a Primitive function.

type Plan

type Plan struct {
	Type         sqlparser.StatementType // The type of query we have
	Original     string                  // Original is the original query.
	Instructions Primitive               // Instructions contains the instructions needed to fulfil the query.
	BindVarNeeds *sqlparser.BindVarNeeds // Stores BindVars needed to be provided as part of expression rewriting
	Warnings     []*query.QueryWarning   // Warnings that need to be yielded every time this query runs
	TablesUsed   []string                // TablesUsed is the list of tables that this plan will query

	ExecCount    uint64 // Count of times this plan was executed
	ExecTime     uint64 // Total execution time
	ShardQueries uint64 // Total number of shard queries
	RowsReturned uint64 // Total number of rows
	RowsAffected uint64 // Total number of rows
	Errors       uint64 // Total number of errors
}

Plan represents the execution strategy for a given query. For now it's a simple wrapper around the real instructions. An instruction (aka Primitive) is typically a tree where each node does its part by combining the results of the sub-nodes.

func (*Plan) AddStats

func (p *Plan) AddStats(execCount uint64, execTime time.Duration, shardQueries, rowsAffected, rowsReturned, errors uint64)

AddStats updates the plan execution statistics

func (*Plan) CachedSize added in v0.10.0

func (cached *Plan) CachedSize(alloc bool) int64

func (*Plan) MarshalJSON

func (p *Plan) MarshalJSON() ([]byte, error)

MarshalJSON serializes the plan into a JSON representation.

func (*Plan) Stats

func (p *Plan) Stats() (execCount uint64, execTime time.Duration, shardQueries, rowsAffected, rowsReturned, errors uint64)

Stats returns a copy of the plan execution statistics

type Primitive

type Primitive interface {
	RouteType() string
	GetKeyspaceName() string
	GetTableName() string
	GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
	NeedsTransaction() bool

	TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)
	TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

	// Inputs is a slice containing the inputs to this Primitive
	Inputs() []Primitive
	// contains filtered or unexported methods
}

Primitive is the building block of the engine execution plan. They form a tree structure, where the leaves typically issue queries to one or more vttablet. During execution, the Primitive's pass Result objects up the tree structure, until reaching the root, and its result is passed to the client.

func Find

func Find(isMatch Match, start Primitive) Primitive

Find will return the first Primitive that matches the evaluate function. If no match is found, nil will be returned

func NewRowsPrimitive

func NewRowsPrimitive(rows [][]sqltypes.Value, fields []*querypb.Field) Primitive

NewRowsPrimitive returns a new Rows primitie

type PrimitiveDescription

type PrimitiveDescription struct {
	OperatorType string
	Variant      string
	// Keyspace specifies the keyspace to send the query to.
	Keyspace *vindexes.Keyspace
	// TargetDestination specifies an explicit target destination to send the query to.
	TargetDestination key.Destination
	// TargetTabletType specifies an explicit target destination tablet type
	// this is only used in conjunction with TargetDestination
	TargetTabletType topodatapb.TabletType
	Other            map[string]any
	Inputs           []PrimitiveDescription
}

PrimitiveDescription is used to create a serializable representation of the Primitive tree Using this structure, all primitives can share json marshalling code, which gives us an uniform output

func PrimitiveToPlanDescription

func PrimitiveToPlanDescription(in Primitive) PrimitiveDescription

PrimitiveToPlanDescription transforms a primitive tree into a corresponding PlanDescription tree

func (PrimitiveDescription) MarshalJSON

func (pd PrimitiveDescription) MarshalJSON() ([]byte, error)

MarshalJSON serializes the PlanDescription into a JSON representation. We do this rather manual thing here so the `other` map looks like fields belonging to pd and not a map in a field.

type Projection

type Projection struct {
	Cols  []string
	Exprs []evalengine.Expr
	Input Primitive
	// contains filtered or unexported fields
}

Projection can evaluate expressions and project the results

func (*Projection) CachedSize added in v0.10.0

func (cached *Projection) CachedSize(alloc bool) int64

func (*Projection) GetFields

func (p *Projection) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*Projection) GetKeyspaceName

func (p *Projection) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*Projection) GetTableName

func (p *Projection) GetTableName() string

GetTableName implements the Primitive interface

func (*Projection) Inputs

func (p *Projection) Inputs() []Primitive

Inputs implements the Primitive interface

func (Projection) NeedsTransaction

func (Projection) NeedsTransaction() bool

func (*Projection) RouteType

func (p *Projection) RouteType() string

RouteType implements the Primitive interface

func (*Projection) TryExecute added in v0.12.0

func (p *Projection) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*Projection) TryStreamExecute added in v0.12.0

func (p *Projection) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type PulloutSubquery

type PulloutSubquery struct {
	Opcode PulloutOpcode

	// SubqueryResult and HasValues are used to send in the bindvar used in the query to the underlying primitive
	SubqueryResult string
	HasValues      string

	Subquery   Primitive
	Underlying Primitive
}

PulloutSubquery executes a "pulled out" subquery and stores the results in a bind variable.

func (*PulloutSubquery) CachedSize added in v0.10.0

func (cached *PulloutSubquery) CachedSize(alloc bool) int64

func (*PulloutSubquery) GetFields

func (ps *PulloutSubquery) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*PulloutSubquery) GetKeyspaceName

func (ps *PulloutSubquery) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*PulloutSubquery) GetTableName

func (ps *PulloutSubquery) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*PulloutSubquery) Inputs

func (ps *PulloutSubquery) Inputs() []Primitive

Inputs returns the input primitives for this join

func (*PulloutSubquery) NeedsTransaction

func (ps *PulloutSubquery) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*PulloutSubquery) RouteType

func (ps *PulloutSubquery) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*PulloutSubquery) TryExecute added in v0.12.0

func (ps *PulloutSubquery) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute satisfies the Primitive interface.

func (*PulloutSubquery) TryStreamExecute added in v0.12.0

func (ps *PulloutSubquery) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type RenameFields added in v0.10.0

type RenameFields struct {
	Cols    []string
	Indices []int
	Input   Primitive
	// contains filtered or unexported fields
}

RenameFields is a primitive that renames the fields

func NewRenameField added in v0.10.0

func NewRenameField(cols []string, indices []int, input Primitive) (*RenameFields, error)

NewRenameField creates a new rename field

func (*RenameFields) CachedSize added in v0.10.0

func (cached *RenameFields) CachedSize(alloc bool) int64

func (*RenameFields) GetFields added in v0.10.0

func (r *RenameFields) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the primitive interface

func (*RenameFields) GetKeyspaceName added in v0.10.0

func (r *RenameFields) GetKeyspaceName() string

GetKeyspaceName implements the primitive interface

func (*RenameFields) GetTableName added in v0.10.0

func (r *RenameFields) GetTableName() string

GetTableName implements the primitive interface

func (*RenameFields) Inputs added in v0.10.0

func (r *RenameFields) Inputs() []Primitive

Inputs implements the primitive interface

func (RenameFields) NeedsTransaction added in v0.10.0

func (RenameFields) NeedsTransaction() bool

func (*RenameFields) RouteType added in v0.10.0

func (r *RenameFields) RouteType() string

RouteType implements the primitive interface

func (*RenameFields) TryExecute added in v0.12.0

func (r *RenameFields) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*RenameFields) TryStreamExecute added in v0.12.0

func (r *RenameFields) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type ReplaceVariables added in v0.10.0

type ReplaceVariables struct {
	Input Primitive
	// contains filtered or unexported fields
}

ReplaceVariables is used in SHOW VARIABLES statements so that it replaces the values for vitess-aware variables

func NewReplaceVariables added in v0.10.0

func NewReplaceVariables(input Primitive) *ReplaceVariables

NewReplaceVariables is used to create a new ReplaceVariables primitive

func (*ReplaceVariables) CachedSize added in v0.10.0

func (cached *ReplaceVariables) CachedSize(alloc bool) int64

func (*ReplaceVariables) GetFields added in v0.10.0

func (r *ReplaceVariables) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*ReplaceVariables) GetKeyspaceName added in v0.10.0

func (r *ReplaceVariables) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*ReplaceVariables) GetTableName added in v0.10.0

func (r *ReplaceVariables) GetTableName() string

GetTableName implements the Primitive interface

func (*ReplaceVariables) Inputs added in v0.10.0

func (r *ReplaceVariables) Inputs() []Primitive

Inputs implements the Primitive interface

func (ReplaceVariables) NeedsTransaction added in v0.10.0

func (ReplaceVariables) NeedsTransaction() bool

func (*ReplaceVariables) RouteType added in v0.10.0

func (r *ReplaceVariables) RouteType() string

RouteType implements the Primitive interface

func (*ReplaceVariables) TryExecute added in v0.12.0

func (r *ReplaceVariables) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*ReplaceVariables) TryStreamExecute added in v0.12.0

func (r *ReplaceVariables) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type RevertMigration added in v0.10.0

type RevertMigration struct {
	Keyspace          *vindexes.Keyspace
	Stmt              *sqlparser.RevertMigration
	Query             string
	TargetDestination key.Destination
	// contains filtered or unexported fields
}

RevertMigration represents the instructions to perform an online schema change via vtctld

func (*RevertMigration) CachedSize added in v0.10.0

func (cached *RevertMigration) CachedSize(alloc bool) int64

func (*RevertMigration) GetFields added in v0.10.0

func (v *RevertMigration) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*RevertMigration) GetKeyspaceName added in v0.10.0

func (v *RevertMigration) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*RevertMigration) GetTableName added in v0.10.0

func (v *RevertMigration) GetTableName() string

GetTableName implements the Primitive interface

func (RevertMigration) Inputs added in v0.10.0

func (RevertMigration) Inputs() []Primitive

Inputs implements no inputs

func (RevertMigration) NeedsTransaction added in v0.10.0

func (RevertMigration) NeedsTransaction() bool

func (*RevertMigration) RouteType added in v0.10.0

func (v *RevertMigration) RouteType() string

RouteType implements the Primitive interface

func (*RevertMigration) TryExecute added in v0.12.0

func (v *RevertMigration) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (result *sqltypes.Result, err error)

TryExecute implements the Primitive interface

func (*RevertMigration) TryStreamExecute added in v0.12.0

func (v *RevertMigration) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type Route

type Route struct {
	// TargetTabletType specifies an explicit target destination tablet type
	// this is only used in conjunction with TargetDestination
	TargetTabletType topodatapb.TabletType

	// Query specifies the query to be executed.
	Query string

	// TableName specifies the tables to send the query to.
	TableName string

	// FieldQuery specifies the query to be executed for a GetFieldInfo request.
	FieldQuery string

	// OrderBy specifies the key order for merge sorting. This will be
	// set only for scatter queries that need the results to be
	// merge-sorted.
	OrderBy []OrderByParams

	// TruncateColumnCount specifies the number of columns to return
	// in the final result. Rest of the columns are truncated
	// from the result received. If 0, no truncation happens.
	TruncateColumnCount int

	// QueryTimeout contains the optional timeout (in milliseconds) to apply to this query
	QueryTimeout int

	// ScatterErrorsAsWarnings is true if results should be returned even if some shards have an error
	ScatterErrorsAsWarnings bool

	// RoutingParameters parameters required for query routing.
	*RoutingParameters

	// NoRoutesSpecialHandling will make the route send a query to arbitrary shard if the routing logic can't find
	// the correct shard. This is important for queries where no matches does not mean empty result - examples would be:
	// select count(*) from tbl where lookupColumn = 'not there'
	// select exists(<subq>)
	NoRoutesSpecialHandling bool
	// contains filtered or unexported fields
}

Route represents the instructions to route a read query to one or many vttablets.

func NewRoute

func NewRoute(opcode Opcode, keyspace *vindexes.Keyspace, query, fieldQuery string) *Route

NewRoute creates a Route.

func NewSimpleRoute

func NewSimpleRoute(opcode Opcode, keyspace *vindexes.Keyspace) *Route

NewSimpleRoute creates a Route with the bare minimum of parameters.

func (*Route) CachedSize added in v0.10.0

func (cached *Route) CachedSize(alloc bool) int64

func (*Route) GetFields

func (route *Route) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*Route) GetKeyspaceName

func (route *Route) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*Route) GetTableName

func (route *Route) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (Route) Inputs

func (Route) Inputs() []Primitive

Inputs implements no inputs

func (Route) NeedsTransaction

func (Route) NeedsTransaction() bool

func (*Route) RouteType

func (route *Route) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*Route) SetTruncateColumnCount

func (route *Route) SetTruncateColumnCount(count int)

SetTruncateColumnCount sets the truncate column count.

func (*Route) TryExecute added in v0.12.0

func (route *Route) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*Route) TryStreamExecute added in v0.12.0

func (route *Route) TryStreamExecute(
	ctx context.Context,
	vcursor VCursor,
	bindVars map[string]*querypb.BindVariable,
	wantfields bool,
	callback func(*sqltypes.Result) error,
) error

TryStreamExecute performs a streaming exec.

type RoutingParameters added in v0.13.0

type RoutingParameters struct {
	// Opcode is the execution opcode.
	Opcode Opcode

	// Keyspace specifies the keyspace to send the query to.
	Keyspace *vindexes.Keyspace

	// The following two fields are used when routing information_schema queries
	SysTableTableSchema []evalengine.Expr
	SysTableTableName   map[string]evalengine.Expr

	// TargetDestination specifies an explicit target destination to send the query to.
	// This will bypass the routing logic.
	TargetDestination key.Destination // update `user[-]@replica`.user set ....

	// Vindex specifies the vindex to be used.
	Vindex vindexes.Vindex

	// Values specifies the vindex values to use for routing.
	Values []evalengine.Expr
}

func (*RoutingParameters) CachedSize added in v0.13.0

func (cached *RoutingParameters) CachedSize(alloc bool) int64

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

Rows simply returns a number or rows

func (*Rows) CachedSize added in v0.10.0

func (cached *Rows) CachedSize(alloc bool) int64

func (*Rows) GetFields

GetFields implements the Primitive interface

func (*Rows) GetKeyspaceName

func (r *Rows) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*Rows) GetTableName

func (r *Rows) GetTableName() string

GetTableName implements the Primitive interface

func (Rows) Inputs

func (Rows) Inputs() []Primitive

Inputs implements no inputs

func (Rows) NeedsTransaction

func (Rows) NeedsTransaction() bool

func (*Rows) RouteType

func (r *Rows) RouteType() string

RouteType implements the Primitive interface

func (*Rows) TryExecute added in v0.12.0

TryExecute implements the Primitive interface

func (*Rows) TryStreamExecute added in v0.12.0

func (r *Rows) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type SQLCalcFoundRows added in v0.8.0

type SQLCalcFoundRows struct {
	LimitPrimitive Primitive
	CountPrimitive Primitive
}

SQLCalcFoundRows is a primitive to execute limit and count query as per their individual plan.

func (*SQLCalcFoundRows) CachedSize added in v0.10.0

func (cached *SQLCalcFoundRows) CachedSize(alloc bool) int64

func (SQLCalcFoundRows) GetFields added in v0.8.0

func (s SQLCalcFoundRows) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (SQLCalcFoundRows) GetKeyspaceName added in v0.8.0

func (s SQLCalcFoundRows) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (SQLCalcFoundRows) GetTableName added in v0.8.0

func (s SQLCalcFoundRows) GetTableName() string

GetTableName implements the Primitive interface

func (SQLCalcFoundRows) Inputs added in v0.8.0

func (s SQLCalcFoundRows) Inputs() []Primitive

Inputs implements the Primitive interface

func (SQLCalcFoundRows) NeedsTransaction added in v0.8.0

func (s SQLCalcFoundRows) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (SQLCalcFoundRows) RouteType added in v0.8.0

func (s SQLCalcFoundRows) RouteType() string

RouteType implements the Primitive interface

func (SQLCalcFoundRows) TryExecute added in v0.12.0

func (s SQLCalcFoundRows) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (SQLCalcFoundRows) TryStreamExecute added in v0.12.0

func (s SQLCalcFoundRows) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type ScalarAggregate added in v0.14.0

type ScalarAggregate struct {
	// PreProcess is true if one of the aggregates needs preprocessing.
	PreProcess bool `json:",omitempty"`

	AggrOnEngine bool

	// Aggregates specifies the aggregation parameters for each
	// aggregation function: function opcode and input column number.
	Aggregates []*AggregateParams

	// TruncateColumnCount specifies the number of columns to return
	// in the final result. Rest of the columns are truncated
	// from the result received. If 0, no truncation happens.
	TruncateColumnCount int `json:",omitempty"`

	// Input is the primitive that will feed into this Primitive.
	Input Primitive
}

ScalarAggregate is a primitive used to do aggregations without grouping keys

func (*ScalarAggregate) CachedSize added in v0.14.0

func (cached *ScalarAggregate) CachedSize(alloc bool) int64

func (*ScalarAggregate) GetFields added in v0.14.0

func (sa *ScalarAggregate) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*ScalarAggregate) GetKeyspaceName added in v0.14.0

func (sa *ScalarAggregate) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*ScalarAggregate) GetTableName added in v0.14.0

func (sa *ScalarAggregate) GetTableName() string

GetTableName implements the Primitive interface

func (*ScalarAggregate) Inputs added in v0.14.0

func (sa *ScalarAggregate) Inputs() []Primitive

Inputs implements the Primitive interface

func (*ScalarAggregate) NeedsTransaction added in v0.14.0

func (sa *ScalarAggregate) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*ScalarAggregate) RouteType added in v0.14.0

func (sa *ScalarAggregate) RouteType() string

RouteType implements the Primitive interface

func (*ScalarAggregate) TryExecute added in v0.14.0

func (sa *ScalarAggregate) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*ScalarAggregate) TryStreamExecute added in v0.14.0

func (sa *ScalarAggregate) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type SemiJoin added in v0.13.0

type SemiJoin struct {
	// Left and Right are the LHS and RHS primitives
	// of the SemiJoin. They can be any primitive.
	Left, Right Primitive `json:",omitempty"`

	// Cols defines which columns from the left
	// results should be used to build the
	// return result. For results coming from the
	// left query, the index values go as -1, -2, etc.
	// If Cols is {-1, -2}, it means that
	// the returned result will be {Left0, Left1}.
	Cols []int `json:",omitempty"`

	// Vars defines the list of SemiJoinVars that need to
	// be built from the LHS result before invoking
	// the RHS subqquery.
	Vars map[string]int `json:",omitempty"`
}

SemiJoin specifies the parameters for a SemiJoin primitive.

func (*SemiJoin) CachedSize added in v0.13.0

func (cached *SemiJoin) CachedSize(alloc bool) int64

func (*SemiJoin) GetFields added in v0.13.0

func (jn *SemiJoin) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*SemiJoin) GetKeyspaceName added in v0.13.0

func (jn *SemiJoin) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*SemiJoin) GetTableName added in v0.13.0

func (jn *SemiJoin) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*SemiJoin) Inputs added in v0.13.0

func (jn *SemiJoin) Inputs() []Primitive

Inputs returns the input primitives for this SemiJoin

func (*SemiJoin) NeedsTransaction added in v0.13.0

func (jn *SemiJoin) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*SemiJoin) RouteType added in v0.13.0

func (jn *SemiJoin) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*SemiJoin) TryExecute added in v0.13.0

func (jn *SemiJoin) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*SemiJoin) TryStreamExecute added in v0.13.0

func (jn *SemiJoin) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type Send

type Send struct {
	// Keyspace specifies the keyspace to send the query to.
	Keyspace *vindexes.Keyspace

	// TargetDestination specifies an explicit target destination to send the query to.
	TargetDestination key.Destination

	// Query specifies the query to be executed.
	Query string

	// IsDML specifies how to deal with autocommit behaviour
	IsDML bool

	// SingleShardOnly specifies that the query must be send to only single shard
	SingleShardOnly bool

	// ShardNameNeeded specified that the shard name is added to the bind variables
	ShardNameNeeded bool

	// MultishardAutocommit specifies that a multishard transaction query can autocommit
	MultishardAutocommit bool
	// contains filtered or unexported fields
}

Send is an operator to send query to the specific keyspace, tabletType and destination

func (*Send) CachedSize added in v0.10.0

func (cached *Send) CachedSize(alloc bool) int64

func (*Send) GetFields

func (s *Send) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements Primitive interface

func (*Send) GetKeyspaceName

func (s *Send) GetKeyspaceName() string

GetKeyspaceName implements Primitive interface

func (*Send) GetTableName

func (s *Send) GetTableName() string

GetTableName implements Primitive interface

func (Send) Inputs

func (Send) Inputs() []Primitive

Inputs implements no inputs

func (*Send) NeedsTransaction

func (s *Send) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*Send) RouteType

func (s *Send) RouteType() string

RouteType implements Primitive interface

func (*Send) TryExecute added in v0.12.0

func (s *Send) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements Primitive interface

func (*Send) TryStreamExecute added in v0.12.0

func (s *Send) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements Primitive interface

type SessionActions

type SessionActions interface {
	// RecordWarning stores the given warning in the current session
	RecordWarning(warning *querypb.QueryWarning)

	SetTarget(target string) error

	SetUDV(key string, value any) error
	GetUDV(key string) *querypb.BindVariable

	SetSysVar(name string, expr string)

	// NeedsReservedConn marks this session as needing a dedicated connection to underlying database
	NeedsReservedConn()

	// InReservedConn provides whether this session is using reserved connection
	InReservedConn() bool

	// ShardSession returns shard info about open connections
	ShardSession() []*srvtopo.ResolvedShard

	SetAutocommit(ctx context.Context, autocommit bool) error
	SetClientFoundRows(context.Context, bool) error
	SetSkipQueryPlanCache(context.Context, bool) error
	SetSQLSelectLimit(int64) error
	SetTransactionMode(vtgatepb.TransactionMode)
	SetWorkload(querypb.ExecuteOptions_Workload)
	SetPlannerVersion(querypb.ExecuteOptions_PlannerVersion)
	SetConsolidator(querypb.ExecuteOptions_Consolidator)
	SetWorkloadName(string)
	SetPriority(string)
	SetFoundRows(uint64)

	SetDDLStrategy(string)
	GetDDLStrategy() string

	GetSessionUUID() string

	SetSessionEnableSystemSettings(context.Context, bool) error
	GetSessionEnableSystemSettings() bool

	GetSystemVariables(func(k string, v string))
	HasSystemVariables() bool

	// SetReadAfterWriteGTID sets the GTID that the user expects a replica to have caught up with before answering a query
	SetReadAfterWriteGTID(string)
	SetReadAfterWriteTimeout(float64)
	SetSessionTrackGTIDs(bool)

	// HasCreatedTempTable will mark the session as having created temp tables
	HasCreatedTempTable()
	GetWarnings() []*querypb.QueryWarning

	// AnyAdvisoryLockTaken returns true of any advisory lock is taken
	AnyAdvisoryLockTaken() bool
	// AddAdvisoryLock adds advisory lock to the session
	AddAdvisoryLock(name string)
	// RemoveAdvisoryLock removes advisory lock from the session
	RemoveAdvisoryLock(name string)

	// VExplainLogging enables logging of all interactions to the tablets so
	// VEXPLAIN QUERIES/ALL can report what's being done
	VExplainLogging()

	// GetVExplainLogs retrieves the vttablet interaction logs
	GetVExplainLogs() []ExecuteEntry

	// SetCommitOrder sets the commit order for the shard session in respect of the type of vindex lookup.
	// This is used to select the right shard session to perform the vindex lookup query.
	SetCommitOrder(co vtgatepb.CommitOrder)

	// GetQueryTimeout gets the query timeout and takes in the query timeout from comments
	GetQueryTimeout(queryTimeoutFromComment int) int

	// SetQueryTimeout sets the query timeout
	SetQueryTimeout(queryTimeout int64)

	// InTransaction returns true if the session has already opened transaction or
	// will start a transaction on the query execution.
	InTransaction() bool
}

SessionActions gives primitives ability to interact with the session state

type SessionPrimitive added in v0.11.0

type SessionPrimitive struct {
	// contains filtered or unexported fields
}

SessionPrimitive the session primitive is a very small primitive used when we have simple engine code that needs to interact with the Session

func NewSessionPrimitive added in v0.11.0

func NewSessionPrimitive(name string, action func(sa SessionActions) (*sqltypes.Result, error)) *SessionPrimitive

NewSessionPrimitive creates a SessionPrimitive

func (*SessionPrimitive) CachedSize added in v0.11.0

func (cached *SessionPrimitive) CachedSize(alloc bool) int64

func (*SessionPrimitive) GetFields added in v0.11.0

func (s *SessionPrimitive) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*SessionPrimitive) GetKeyspaceName added in v0.11.0

func (s *SessionPrimitive) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*SessionPrimitive) GetTableName added in v0.11.0

func (s *SessionPrimitive) GetTableName() string

GetTableName implements the Primitive interface

func (SessionPrimitive) Inputs added in v0.11.0

func (SessionPrimitive) Inputs() []Primitive

Inputs implements no inputs

func (SessionPrimitive) NeedsTransaction added in v0.11.0

func (SessionPrimitive) NeedsTransaction() bool

func (*SessionPrimitive) RouteType added in v0.11.0

func (s *SessionPrimitive) RouteType() string

RouteType implements the Primitive interface

func (*SessionPrimitive) TryExecute added in v0.12.0

func (s *SessionPrimitive) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*SessionPrimitive) TryStreamExecute added in v0.12.0

func (s *SessionPrimitive) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type Set

type Set struct {
	Ops   []SetOp
	Input Primitive
	// contains filtered or unexported fields
}

Set contains the instructions to perform set.

func (*Set) CachedSize added in v0.10.0

func (cached *Set) CachedSize(alloc bool) int64

func (*Set) GetFields

GetFields implements the Primitive interface method.

func (*Set) GetKeyspaceName

func (s *Set) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface method.

func (*Set) GetTableName

func (s *Set) GetTableName() string

GetTableName implements the Primitive interface method.

func (*Set) Inputs

func (s *Set) Inputs() []Primitive

Inputs implements the Primitive interface

func (Set) NeedsTransaction

func (Set) NeedsTransaction() bool

func (*Set) RouteType

func (s *Set) RouteType() string

RouteType implements the Primitive interface method.

func (*Set) TryExecute added in v0.12.0

func (s *Set) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface method.

func (*Set) TryStreamExecute added in v0.12.0

func (s *Set) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface method.

type SetOp

type SetOp interface {
	Execute(ctx context.Context, vcursor VCursor, env *evalengine.ExpressionEnv) error
	VariableName() string
}

SetOp is an interface that different type of set operations implements.

type ShowExec added in v0.14.0

type ShowExec struct {
	Command    sqlparser.ShowCommandType
	ShowFilter *sqlparser.ShowFilter
	// contains filtered or unexported fields
}

ShowExec is a primitive to call into executor via vcursor.

func (*ShowExec) CachedSize added in v0.14.0

func (cached *ShowExec) CachedSize(alloc bool) int64

func (*ShowExec) GetFields added in v0.14.0

func (s *ShowExec) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error)

func (*ShowExec) GetKeyspaceName added in v0.14.0

func (s *ShowExec) GetKeyspaceName() string

func (*ShowExec) GetTableName added in v0.14.0

func (s *ShowExec) GetTableName() string

func (ShowExec) Inputs added in v0.14.0

func (ShowExec) Inputs() []Primitive

Inputs implements no inputs

func (ShowExec) NeedsTransaction added in v0.14.0

func (ShowExec) NeedsTransaction() bool

func (*ShowExec) RouteType added in v0.14.0

func (s *ShowExec) RouteType() string

func (*ShowExec) TryExecute added in v0.14.0

func (s *ShowExec) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (*sqltypes.Result, error)

func (*ShowExec) TryStreamExecute added in v0.14.0

func (s *ShowExec) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

type SimpleProjection added in v0.12.0

type SimpleProjection struct {
	// Cols defines the column numbers from the underlying primitive
	// to be returned.
	Cols  []int
	Input Primitive
}

SimpleProjection selects which columns to keep from the input

func (*SimpleProjection) CachedSize added in v0.12.0

func (cached *SimpleProjection) CachedSize(alloc bool) int64

func (*SimpleProjection) GetFields added in v0.12.0

func (sc *SimpleProjection) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*SimpleProjection) GetKeyspaceName added in v0.12.0

func (sc *SimpleProjection) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*SimpleProjection) GetTableName added in v0.12.0

func (sc *SimpleProjection) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*SimpleProjection) Inputs added in v0.12.0

func (sc *SimpleProjection) Inputs() []Primitive

Inputs returns the input to this primitive

func (*SimpleProjection) NeedsTransaction added in v0.12.0

func (sc *SimpleProjection) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*SimpleProjection) RouteType added in v0.12.0

func (sc *SimpleProjection) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*SimpleProjection) TryExecute added in v0.12.0

func (sc *SimpleProjection) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*SimpleProjection) TryStreamExecute added in v0.12.0

func (sc *SimpleProjection) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type SingleRow

type SingleRow struct {
	// contains filtered or unexported fields
}

SingleRow defines an empty result

func (*SingleRow) GetFields

func (s *SingleRow) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*SingleRow) GetKeyspaceName

func (s *SingleRow) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*SingleRow) GetTableName

func (s *SingleRow) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (SingleRow) Inputs

func (SingleRow) Inputs() []Primitive

Inputs implements no inputs

func (SingleRow) NeedsTransaction

func (SingleRow) NeedsTransaction() bool

func (*SingleRow) RouteType

func (s *SingleRow) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*SingleRow) TryExecute added in v0.12.0

TryExecute performs a non-streaming exec.

func (*SingleRow) TryStreamExecute added in v0.12.0

func (s *SingleRow) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type StreamExecutor

type StreamExecutor interface {
	StreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error
}

StreamExecutor is a subset of Primitive that MergeSort requires its inputs to satisfy.

type SysVarCheckAndIgnore

type SysVarCheckAndIgnore struct {
	Name              string
	Keyspace          *vindexes.Keyspace
	TargetDestination key.Destination `json:",omitempty"`
	Expr              string
}

SysVarCheckAndIgnore implements the SetOp interface to check underlying setting and ignore if same.

func (*SysVarCheckAndIgnore) CachedSize added in v0.10.0

func (cached *SysVarCheckAndIgnore) CachedSize(alloc bool) int64

func (*SysVarCheckAndIgnore) Execute

func (svci *SysVarCheckAndIgnore) Execute(ctx context.Context, vcursor VCursor, env *evalengine.ExpressionEnv) error

Execute implements the SetOp interface method

func (*SysVarCheckAndIgnore) MarshalJSON

func (svci *SysVarCheckAndIgnore) MarshalJSON() ([]byte, error)

MarshalJSON provides the type to SetOp for plan json

func (*SysVarCheckAndIgnore) VariableName

func (svci *SysVarCheckAndIgnore) VariableName() string

VariableName implements the SetOp interface method

type SysVarIgnore

type SysVarIgnore struct {
	Name string
	Expr string
}

SysVarIgnore implements the SetOp interface to ignore the settings.

func (*SysVarIgnore) CachedSize added in v0.10.0

func (cached *SysVarIgnore) CachedSize(alloc bool) int64

func (*SysVarIgnore) Execute

Execute implements the SetOp interface method.

func (*SysVarIgnore) MarshalJSON

func (svi *SysVarIgnore) MarshalJSON() ([]byte, error)

MarshalJSON provides the type to SetOp for plan json

func (*SysVarIgnore) VariableName

func (svi *SysVarIgnore) VariableName() string

VariableName implements the SetOp interface method.

type SysVarReservedConn added in v0.8.0

type SysVarReservedConn struct {
	Name              string
	Keyspace          *vindexes.Keyspace
	TargetDestination key.Destination `json:",omitempty"`
	Expr              string
	SupportSetVar     bool
}

SysVarReservedConn implements the SetOp interface and will write the changes variable into the session

func (*SysVarReservedConn) CachedSize added in v0.10.0

func (cached *SysVarReservedConn) CachedSize(alloc bool) int64

func (*SysVarReservedConn) Execute added in v0.8.0

func (svs *SysVarReservedConn) Execute(ctx context.Context, vcursor VCursor, env *evalengine.ExpressionEnv) error

Execute implements the SetOp interface method

func (*SysVarReservedConn) MarshalJSON added in v0.8.0

func (svs *SysVarReservedConn) MarshalJSON() ([]byte, error)

MarshalJSON provides the type to SetOp for plan json

func (*SysVarReservedConn) VariableName added in v0.8.0

func (svs *SysVarReservedConn) VariableName() string

VariableName implements the SetOp interface method

type SysVarSetAware added in v0.8.0

type SysVarSetAware struct {
	Name string
	Expr evalengine.Expr
}

SysVarSetAware implements the SetOp interface and will write the changes variable into the session The special part is that these settings change the sessions behaviour in different ways

func (*SysVarSetAware) CachedSize added in v0.10.0

func (cached *SysVarSetAware) CachedSize(alloc bool) int64

func (*SysVarSetAware) Execute added in v0.8.0

func (svss *SysVarSetAware) Execute(ctx context.Context, vcursor VCursor, env *evalengine.ExpressionEnv) error

Execute implements the SetOp interface method

func (*SysVarSetAware) MarshalJSON added in v0.8.0

func (svss *SysVarSetAware) MarshalJSON() ([]byte, error)

MarshalJSON marshals all the json

func (*SysVarSetAware) VariableName added in v0.8.0

func (svss *SysVarSetAware) VariableName() string

VariableName implements the SetOp interface method

type Update

type Update struct {
	*DML

	// ChangedVindexValues contains values for updated Vindexes during an update statement.
	ChangedVindexValues map[string]*VindexValues
	// contains filtered or unexported fields
}

Update represents the instructions to perform an update.

func (*Update) CachedSize added in v0.10.0

func (cached *Update) CachedSize(alloc bool) int64

func (*Update) GetFields

func (upd *Update) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (Update) Inputs

func (Update) Inputs() []Primitive

Inputs implements no inputs

func (Update) NeedsTransaction

func (Update) NeedsTransaction() bool

func (*Update) TryExecute added in v0.12.0

func (upd *Update) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*Update) TryStreamExecute added in v0.12.0

func (upd *Update) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type UpdateTarget

type UpdateTarget struct {
	// Target string to be updated
	Target string
	// contains filtered or unexported fields
}

UpdateTarget is an operator to update target string.

func (*UpdateTarget) CachedSize added in v0.10.0

func (cached *UpdateTarget) CachedSize(alloc bool) int64

func (*UpdateTarget) GetFields

func (updTarget *UpdateTarget) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*UpdateTarget) GetKeyspaceName

func (updTarget *UpdateTarget) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*UpdateTarget) GetTableName

func (updTarget *UpdateTarget) GetTableName() string

GetTableName implements the Primitive interface

func (UpdateTarget) Inputs

func (UpdateTarget) Inputs() []Primitive

Inputs implements no inputs

func (UpdateTarget) NeedsTransaction

func (UpdateTarget) NeedsTransaction() bool

func (*UpdateTarget) RouteType

func (updTarget *UpdateTarget) RouteType() string

RouteType implements the Primitive interface

func (*UpdateTarget) TryExecute added in v0.12.0

func (updTarget *UpdateTarget) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*UpdateTarget) TryStreamExecute added in v0.12.0

func (updTarget *UpdateTarget) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type UserDefinedVariable

type UserDefinedVariable struct {
	Name string
	Expr evalengine.Expr
}

UserDefinedVariable implements the SetOp interface to execute user defined variables.

func (*UserDefinedVariable) CachedSize added in v0.10.0

func (cached *UserDefinedVariable) CachedSize(alloc bool) int64

func (*UserDefinedVariable) Execute

func (u *UserDefinedVariable) Execute(ctx context.Context, vcursor VCursor, env *evalengine.ExpressionEnv) error

Execute implements the SetOp interface method.

func (*UserDefinedVariable) MarshalJSON

func (u *UserDefinedVariable) MarshalJSON() ([]byte, error)

MarshalJSON provides the type to SetOp for plan json

func (*UserDefinedVariable) VariableName

func (u *UserDefinedVariable) VariableName() string

VariableName implements the SetOp interface method.

type VCursor

type VCursor interface {
	GetKeyspace() string
	// MaxMemoryRows returns the maxMemoryRows flag value.
	MaxMemoryRows() int

	// ExceedsMaxMemoryRows returns a boolean indicating whether
	// the maxMemoryRows value has been exceeded. Returns false
	// if the max memory rows override directive is set to true
	ExceedsMaxMemoryRows(numRows int) bool

	// V3 functions.
	Execute(ctx context.Context, method string, query string, bindVars map[string]*querypb.BindVariable, rollbackOnError bool, co vtgatepb.CommitOrder) (*sqltypes.Result, error)
	AutocommitApproval() bool

	// Execute the given primitive
	ExecutePrimitive(ctx context.Context, primitive Primitive, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)
	// Execute the given primitive in a new autocommit session
	ExecutePrimitiveStandalone(ctx context.Context, primitive Primitive, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

	// Execute the given primitive
	StreamExecutePrimitive(ctx context.Context, primitive Primitive, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error
	// Execute the given primitive in a new autocommit session
	StreamExecutePrimitiveStandalone(ctx context.Context, primitive Primitive, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(result *sqltypes.Result) error) error

	// Shard-level functions.
	ExecuteMultiShard(ctx context.Context, primitive Primitive, rss []*srvtopo.ResolvedShard, queries []*querypb.BoundQuery, rollbackOnError, canAutocommit bool) (*sqltypes.Result, []error)
	ExecuteStandalone(ctx context.Context, primitive Primitive, query string, bindVars map[string]*querypb.BindVariable, rs *srvtopo.ResolvedShard) (*sqltypes.Result, error)
	StreamExecuteMulti(ctx context.Context, primitive Primitive, query string, rss []*srvtopo.ResolvedShard, bindVars []map[string]*querypb.BindVariable, rollbackOnError bool, autocommit bool, callback func(reply *sqltypes.Result) error) []error

	// Keyspace ID level functions.
	ExecuteKeyspaceID(ctx context.Context, keyspace string, ksid []byte, query string, bindVars map[string]*querypb.BindVariable, rollbackOnError, autocommit bool) (*sqltypes.Result, error)

	// Resolver methods, from key.Destination to srvtopo.ResolvedShard.
	// Will replace all of the Topo functions.
	ResolveDestinations(ctx context.Context, keyspace string, ids []*querypb.Value, destinations []key.Destination) ([]*srvtopo.ResolvedShard, [][]*querypb.Value, error)

	ResolveDestinationsMultiCol(ctx context.Context, keyspace string, ids [][]sqltypes.Value, destinations []key.Destination) ([]*srvtopo.ResolvedShard, [][][]sqltypes.Value, error)

	ExecuteVSchema(ctx context.Context, keyspace string, vschemaDDL *sqlparser.AlterVschema) error

	Session() SessionActions

	ConnCollation() collations.ID
	TimeZone() *time.Location

	ExecuteLock(ctx context.Context, rs *srvtopo.ResolvedShard, query *querypb.BoundQuery, lockFuncType sqlparser.LockingFuncType) (*sqltypes.Result, error)

	InTransactionAndIsDML() bool

	LookupRowLockShardSession() vtgatepb.CommitOrder

	FindRoutedTable(tablename sqlparser.TableName) (*vindexes.Table, error)

	// GetDBDDLPlugin gets the configured plugin for DROP/CREATE DATABASE
	GetDBDDLPluginName() string

	// KeyspaceAvailable returns true when a keyspace is visible from vtgate
	KeyspaceAvailable(ks string) bool

	MessageStream(ctx context.Context, rss []*srvtopo.ResolvedShard, tableName string, callback func(*sqltypes.Result) error) error

	VStream(ctx context.Context, rss []*srvtopo.ResolvedShard, filter *binlogdatapb.Filter, gtid string, callback func(evs []*binlogdatapb.VEvent) error) error

	// ShowExec takes in show command and use executor to execute the query, they are used when topo access is involved.
	ShowExec(ctx context.Context, command sqlparser.ShowCommandType, filter *sqlparser.ShowFilter) (*sqltypes.Result, error)
	// SetExec takes in k,v pair and use executor to set them in topo metadata.
	SetExec(ctx context.Context, name string, value string) error

	// CanUseSetVar returns true if system_settings can use SET_VAR hint.
	CanUseSetVar() bool

	// ReleaseLock releases all the held advisory locks.
	ReleaseLock(ctx context.Context) error
}

VCursor defines the interface the engine will use to execute routes.

type VExplain added in v0.16.0

type VExplain struct {
	Input Primitive
	Type  sqlparser.VExplainType
}

func (*VExplain) CachedSize added in v0.16.0

func (cached *VExplain) CachedSize(alloc bool) int64

func (*VExplain) GetFields added in v0.16.0

func (v *VExplain) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*VExplain) GetKeyspaceName added in v0.16.0

func (v *VExplain) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*VExplain) GetTableName added in v0.16.0

func (v *VExplain) GetTableName() string

GetTableName implements the Primitive interface

func (*VExplain) Inputs added in v0.16.0

func (v *VExplain) Inputs() []Primitive

Inputs implements the Primitive interface

func (*VExplain) NeedsTransaction added in v0.16.0

func (v *VExplain) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*VExplain) RouteType added in v0.16.0

func (v *VExplain) RouteType() string

RouteType implements the Primitive interface

func (*VExplain) TryExecute added in v0.16.0

func (v *VExplain) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*VExplain) TryStreamExecute added in v0.16.0

func (v *VExplain) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type VStream added in v0.11.0

type VStream struct {
	Keyspace          *vindexes.Keyspace
	TargetDestination key.Destination
	TableName         string
	Position          string
	Limit             int
	// contains filtered or unexported fields
}

VStream is an operator for streaming specific keyspace, destination

func (*VStream) CachedSize added in v0.11.0

func (cached *VStream) CachedSize(alloc bool) int64

func (*VStream) GetFields added in v0.11.0

func (v *VStream) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*VStream) GetKeyspaceName added in v0.11.0

func (v *VStream) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*VStream) GetTableName added in v0.11.0

func (v *VStream) GetTableName() string

GetTableName implements the Primitive interface

func (VStream) Inputs added in v0.11.0

func (VStream) Inputs() []Primitive

Inputs implements no inputs

func (VStream) NeedsTransaction added in v0.11.0

func (VStream) NeedsTransaction() bool

func (*VStream) RouteType added in v0.11.0

func (v *VStream) RouteType() string

RouteType implements the Primitive interface

func (*VStream) TryExecute added in v0.12.0

func (v *VStream) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*VStream) TryStreamExecute added in v0.12.0

func (v *VStream) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type VindexFunc

type VindexFunc struct {
	Opcode VindexOpcode
	// Fields is the field info for the result.
	Fields []*querypb.Field
	// Cols contains source column numbers: 0 for id, 1 for keyspace_id.
	Cols []int
	// TODO(sougou): add support for MultiColumn.
	Vindex vindexes.SingleColumn
	Value  evalengine.Expr
	// contains filtered or unexported fields
}

VindexFunc is a primitive that performs vindex functions.

func (*VindexFunc) CachedSize added in v0.10.0

func (cached *VindexFunc) CachedSize(alloc bool) int64

func (*VindexFunc) GetFields

func (vf *VindexFunc) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*VindexFunc) GetKeyspaceName

func (vf *VindexFunc) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*VindexFunc) GetTableName

func (vf *VindexFunc) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (VindexFunc) Inputs

func (VindexFunc) Inputs() []Primitive

Inputs implements no inputs

func (VindexFunc) NeedsTransaction

func (VindexFunc) NeedsTransaction() bool

func (*VindexFunc) RouteType

func (vf *VindexFunc) RouteType() string

RouteType returns a description of the query routing type used by the primitive

func (*VindexFunc) TryExecute added in v0.12.0

func (vf *VindexFunc) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute performs a non-streaming exec.

func (*VindexFunc) TryStreamExecute added in v0.12.0

func (vf *VindexFunc) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute performs a streaming exec.

type VindexLookup added in v0.15.0

type VindexLookup struct {
	Opcode Opcode

	// The vindex to use to do the Map
	Vindex vindexes.LookupPlanable

	// Keyspace specifies the keyspace to send the query to.
	Keyspace *vindexes.Keyspace

	Arguments []string

	// Values specifies the vindex values to use for routing.
	Values []evalengine.Expr

	// We fetch data in order to do the map from this primitive
	Lookup Primitive

	// This is the side that needs to be routed
	SendTo *Route
}

func (*VindexLookup) CachedSize added in v0.15.0

func (cached *VindexLookup) CachedSize(alloc bool) int64

func (*VindexLookup) GetFields added in v0.15.0

func (vr *VindexLookup) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields implements the Primitive interface

func (*VindexLookup) GetKeyspaceName added in v0.15.0

func (vr *VindexLookup) GetKeyspaceName() string

GetKeyspaceName implements the Primitive interface

func (*VindexLookup) GetTableName added in v0.15.0

func (vr *VindexLookup) GetTableName() string

GetTableName implements the Primitive interface

func (*VindexLookup) Inputs added in v0.15.0

func (vr *VindexLookup) Inputs() []Primitive

Inputs implements the Primitive interface

func (*VindexLookup) NeedsTransaction added in v0.15.0

func (vr *VindexLookup) NeedsTransaction() bool

NeedsTransaction implements the Primitive interface

func (*VindexLookup) RouteType added in v0.15.0

func (vr *VindexLookup) RouteType() string

RouteType implements the Primitive interface

func (*VindexLookup) TryExecute added in v0.15.0

func (vr *VindexLookup) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

TryExecute implements the Primitive interface

func (*VindexLookup) TryStreamExecute added in v0.15.0

func (vr *VindexLookup) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

TryStreamExecute implements the Primitive interface

type VindexOpcode

type VindexOpcode int

VindexOpcode is the opcode for a VindexFunc.

func (VindexOpcode) MarshalJSON

func (code VindexOpcode) MarshalJSON() ([]byte, error)

MarshalJSON serializes the VindexOpcode into a JSON representation. It's used for testing and diagnostics.

type VindexValues

type VindexValues struct {
	PvMap  map[string]evalengine.Expr
	Offset int // Offset from ownedVindexQuery to provide input decision for vindex update.
}

VindexValues contains changed values for a vindex.

func (*VindexValues) CachedSize added in v0.10.0

func (cached *VindexValues) CachedSize(alloc bool) int64

type VitessMetadata added in v0.14.0

type VitessMetadata struct {
	Name, Value string
}

VitessMetadata implements the SetOp interface and will write the changes variable into the topo server

func (*VitessMetadata) CachedSize added in v0.14.0

func (cached *VitessMetadata) CachedSize(alloc bool) int64

func (*VitessMetadata) Execute added in v0.14.0

func (v *VitessMetadata) Execute(ctx context.Context, vcursor VCursor, env *evalengine.ExpressionEnv) error

func (*VitessMetadata) VariableName added in v0.14.0

func (v *VitessMetadata) VariableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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