engine

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: Apache-2.0 Imports: 29 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// Unsharded is for routing a dml statement
	// to an unsharded keyspace.
	Unsharded = DMLOpcode(iota)
	// Equal is for routing an dml statement to a single shard.
	// Requires: A Vindex, and a single Value.
	Equal
	// In is for routing an dml statement to a multi shard.
	// Requires: A Vindex, and a multi Values.
	In
	// Scatter is for routing a scattered dml statement.
	Scatter
	// 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 UpdateOpcode values.

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
	// InsertShardedIgnore is for INSERT IGNORE and
	// INSERT...ON DUPLICATE KEY constructs.
	InsertShardedIgnore
)
View Source
const (
	NormalJoin = JoinOpcode(iota)
	LeftJoin
)

This is the list of JoinOpcode values.

View Source
const (
	AggregateCount = AggregateOpcode(iota)
	AggregateSum
	AggregateMin
	AggregateMax
	AggregateCountDistinct
	AggregateSumDistinct
)

These constants list the possible aggregate opcodes.

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 (
	PulloutValue = PulloutOpcode(iota)
	PulloutIn
	PulloutNotIn
	PulloutExists
)

This is the list of PulloutOpcode values.

View Source
const (
	// SelectUnsharded is the opcode for routing a
	// select statement to an unsharded database.
	SelectUnsharded = RouteOpcode(iota)
	// SelectEqualUnique is for routing a query to
	// a single shard. Requires: A Unique Vindex, and
	// a single Value.
	SelectEqualUnique
	// SelectEqual is for routing a query using a
	// non-unique vindex. Requires: A Vindex, and
	// a single Value.
	SelectEqual
	// SelectIN is for routing a query that has an IN
	// clause using a Vindex. Requires: A Vindex,
	// and a Values list.
	SelectIN
	// SelectScatter is for routing a scatter query
	// to all shards of a keyspace.
	SelectScatter
	// SelectNext is for fetching from a sequence.
	SelectNext
	// SelectDBA is for executing a DBA statement.
	SelectDBA
	// SelectReference is for fetching from a reference table.
	SelectReference
	// SelectNone is used for queries that always return empty values
	SelectNone
)

This is the list of RouteOpcode values.

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

These are opcode values for VindexFunc.

Variables

View Source
var SupportedAggregates = map[string]AggregateOpcode{
	"count": AggregateCount,
	"sum":   AggregateSum,
	"min":   AggregateMin,
	"max":   AggregateMax,

	"count_distinct": AggregateCountDistinct,
	"sum_distinct":   AggregateSumDistinct,
}

SupportedAggregates maps the list of supported aggregate functions to their opcodes.

Functions

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 interface{}, f func(interface{}) 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 InsertVarName

func InsertVarName(col sqlparser.ColIdent, 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 AggregateOpcode

type AggregateOpcode int

AggregateOpcode is the aggregation Opcode.

func (AggregateOpcode) MarshalJSON

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

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

func (AggregateOpcode) String

func (code AggregateOpcode) String() string

type AggregateParams

type AggregateParams struct {
	Opcode AggregateOpcode
	Col    int
	// Alias is set only for distinct opcodes.
	Alias string `json:",omitempty"`
}

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

func (AggregateParams) String

func (ap AggregateParams) String() string

type AlterVSchema

type AlterVSchema struct {
	Keyspace *vindexes.Keyspace

	DDL *sqlparser.DDL
	// contains filtered or unexported fields
}

AlterVSchema operator applies changes to VSchema

func (*AlterVSchema) Execute

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

Execute implements the Primitive interface

func (*AlterVSchema) GetFields

func (v *AlterVSchema) GetFields(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) StreamExecute

func (v *AlterVSchema) StreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error

StreamExecute implements the Primitive interface

type Concatenate

type Concatenate struct {
	Sources []Primitive
}

Concatenate specified the parameter for concatenate primitive

func (*Concatenate) Execute

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

Execute performs a non-streaming exec.

func (*Concatenate) GetFields

func (c *Concatenate) GetFields(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) StreamExecute

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

StreamExecute performs a streaming exec.

type DML

type DML struct {
	// Opcode is the execution opcode.
	Opcode DMLOpcode

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

	// TargetDestination specifies the destination to send the query to.
	TargetDestination key.Destination

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

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

	// Values specifies the vindex values to use for routing.
	// For now, only one value is specified.
	Values []sqltypes.PlanValue

	// Keyspace Id Vindex
	KsidVindex vindexes.SingleColumn

	// 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
	// contains filtered or unexported fields
}

DML contains the common elements between Update and Delete plans

func (DML) NeedsTransaction

func (DML) NeedsTransaction() bool

type DMLOpcode

type DMLOpcode int

DMLOpcode is a number representing the opcode for the Update or Delete primitve.

func (DMLOpcode) String

func (op DMLOpcode) String() string

type Delete

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

Delete represents the instructions to perform a delete.

func (*Delete) Execute

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

Execute performs a non-streaming exec.

func (*Delete) GetFields

func (del *Delete) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*Delete) GetKeyspaceName

func (del *Delete) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*Delete) GetTableName

func (del *Delete) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (Delete) Inputs

func (Delete) Inputs() []Primitive

Inputs implements no inputs

func (Delete) NeedsTransaction

func (Delete) NeedsTransaction() bool

func (*Delete) RouteType

func (del *Delete) RouteType() string

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

func (*Delete) StreamExecute

func (del *Delete) StreamExecute(VCursor, map[string]*querypb.BindVariable, bool, func(*sqltypes.Result) error) error

StreamExecute performs a streaming exec.

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 PlanValue. New
	// values will be generated based on how many were not
	// supplied (NULL).
	Values sqltypes.PlanValue
}

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

type Insert

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

	// 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 []sqltypes.PlanValue

	// 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
	// contains filtered or unexported fields
}

Insert represents the instructions to perform an insert operation.

func NewInsert

func NewInsert(opcode InsertOpcode, keyspace *vindexes.Keyspace, vindexValues []sqltypes.PlanValue, 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) Execute

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

Execute performs a non-streaming exec.

func (*Insert) GetFields

func (ins *Insert) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

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 (Insert) Inputs() []Primitive

Inputs implements no inputs

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) StreamExecute

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

StreamExecute 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) Execute

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

Execute performs a non-streaming exec.

func (*Join) GetFields

func (jn *Join) GetFields(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

func (*Join) RouteType

func (jn *Join) RouteType() string

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

func (*Join) StreamExecute

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

StreamExecute 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  sqltypes.PlanValue
	Offset sqltypes.PlanValue
	Input  Primitive
}

Limit is a primitive that performs the LIMIT operation.

func (*Limit) Execute

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

Execute satisfies the Primtive interface.

func (*Limit) GetFields

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

GetFields satisfies the Primtive 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

func (*Limit) RouteType

func (l *Limit) RouteType() string

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

func (*Limit) StreamExecute

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

StreamExecute satisfies the Primtive interface.

type Match

type Match func(node Primitive) bool

Match is used to check if a Primitive matches

type MemorySort

type MemorySort struct {
	UpperLimit sqltypes.PlanValue
	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) Execute

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

Execute satisfies the Primitive interface.

func (*MemorySort) GetFields

func (ms *MemorySort) GetFields(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

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) StreamExecute

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

StreamExecute satisfies the Primitive interface.

type MergeSort

type MergeSort struct {
	Primitives []StreamExecutor
	OrderBy    []OrderbyParams
	// 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) Execute

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

Execute is not supported.

func (*MergeSort) GetFields

func (ms *MergeSort) GetFields(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) StreamExecute

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

StreamExecute performs a streaming exec.

type OrderbyParams

type OrderbyParams struct {
	Col  int
	Desc bool
}

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

func (OrderbyParams) String

func (obp OrderbyParams) String() string

type OrderedAggregate

type OrderedAggregate struct {
	// HasDistinct is true if one of the aggregates is distinct.
	HasDistinct bool `json:",omitempty"`
	// Aggregates specifies the aggregation parameters for each
	// aggregation function: function opcode and input column number.
	Aggregates []AggregateParams

	// Keys specifies the input values that must be used for
	// the aggregation key.
	Keys []int

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

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

Execute is a Primitive function.

func (*OrderedAggregate) GetFields

func (oa *OrderedAggregate) GetFields(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

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) StreamExecute

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

StreamExecute 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.
	sqlparser.BindVarNeeds                         // Stores BindVars needed to be provided as part of expression rewriting

	ExecCount    uint64        // Count of times this plan was executed
	ExecTime     time.Duration // Total execution time
	ShardQueries uint64        // Total number of shard queries
	Rows         uint64        // Total number of rows
	Errors       uint64        // Total number of errors
	// contains filtered or unexported fields
}

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, rows, errors uint64)

AddStats updates the plan execution statistics

func (*Plan) MarshalJSON

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

MarshalJSON serializes the plan into a JSON representation.

func (*Plan) Size

func (p *Plan) Size() int

Size is defined so that Plan can be given to a cache.LRUCache. VTGate needs to maintain a cache of plans. It uses LRUCache, which in turn requires its objects to define a Size function.

func (*Plan) Stats

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

Stats returns a copy of the plan execution statistics

type Primitive

type Primitive interface {
	RouteType() string
	GetKeyspaceName() string
	GetTableName() string
	Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)
	StreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error
	GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
	NeedsTransaction() bool

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

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]interface{}
	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
}

func (*Projection) Execute

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

func (*Projection) GetFields

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

func (*Projection) GetKeyspaceName

func (p *Projection) GetKeyspaceName() string

func (*Projection) GetTableName

func (p *Projection) GetTableName() string

func (*Projection) Inputs

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

func (Projection) NeedsTransaction

func (Projection) NeedsTransaction() bool

func (*Projection) RouteType

func (p *Projection) RouteType() string

func (*Projection) StreamExecute

func (p *Projection) StreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error

type PulloutOpcode

type PulloutOpcode int

PulloutOpcode is a number representing the opcode for the PulloutSubquery primitive.

func (PulloutOpcode) MarshalJSON

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

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

func (PulloutOpcode) String

func (code PulloutOpcode) String() string

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) Execute

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

Execute satisfies the Primitive interface.

func (*PulloutSubquery) GetFields

func (ps *PulloutSubquery) GetFields(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

func (*PulloutSubquery) RouteType

func (ps *PulloutSubquery) RouteType() string

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

func (*PulloutSubquery) StreamExecute

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

StreamExecute performs a streaming exec.

type Reserve

type Reserve struct {
	Input Primitive
}

Reserve will mark the session as needing a reserved connection and then execute the inner Primitive

func (*Reserve) Execute

func (r *Reserve) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

Execute is part of the Primitive interface

func (*Reserve) GetFields

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

GetFields is part of the Primitive interface

func (*Reserve) GetKeyspaceName

func (r *Reserve) GetKeyspaceName() string

GetKeyspaceName is part of the Primitive interface

func (*Reserve) GetTableName

func (r *Reserve) GetTableName() string

GetTableName is part of the Primitive interface

func (*Reserve) Inputs

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

Inputs is part of the Primitive interface

func (*Reserve) NeedsTransaction

func (r *Reserve) NeedsTransaction() bool

NeedsTransaction is part of the Primitive interface

func (*Reserve) RouteType

func (r *Reserve) RouteType() string

RouteType is part of the Primitive interface

func (*Reserve) StreamExecute

func (r *Reserve) StreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

StreamExecute is part of the Primitive interface

type Route

type Route struct {
	// the fields are described in the RouteOpcode values comments.
	// Opcode is the execution opcode.
	Opcode RouteOpcode

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

	// TargetDestination specifies an explicit target destination to send the query to.
	// This bypases the core of the v3 engine.
	TargetDestination key.Destination

	// 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 table to send the query to.
	TableName string

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

	// Vindex specifies the vindex to be used.
	Vindex vindexes.SingleColumn
	// Values specifies the vindex values to use for routing.
	Values []sqltypes.PlanValue

	// 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
	// contains filtered or unexported fields
}

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

func NewRoute

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

NewRoute creates a Route.

func NewSimpleRoute

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

NewSimpleRoute creates a Route with the bare minimum of parameters.

func (*Route) Execute

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

Execute performs a non-streaming exec.

func (*Route) GetFields

func (route *Route) GetFields(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) StreamExecute

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

StreamExecute performs a streaming exec.

type RouteOpcode

type RouteOpcode int

RouteOpcode is a number representing the opcode for the Route primitve. Adding new opcodes here will require review of the join code and the finalizeOptions code in planbuilder.

func (RouteOpcode) MarshalJSON

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

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

type Rows

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

Rows simply returns a number or rows

func NewRowsPrimitive

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

NewRowsPrimitive returns a new Rows primitie

func (*Rows) Execute

func (r *Rows) Execute(VCursor, map[string]*querypb.BindVariable, bool) (*sqltypes.Result, error)

Execute implements the Primitive interface

func (*Rows) GetFields

func (r *Rows) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltypes.Result, error)

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) StreamExecute

func (r *Rows) StreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error

StreamExecute implements the Primitive interface

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
	// contains filtered or unexported fields
}

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

func (*Send) Execute

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

Execute implements Primitive interface

func (*Send) GetFields

func (s *Send) GetFields(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) StreamExecute

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

StreamExecute 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 interface{}) error

	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
}

SessionActions gives primitives ability to interact with the session state

type Set

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

Set contains the instructions to perform set.

func (*Set) Execute

func (s *Set) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, _ bool) (*sqltypes.Result, error)

Execute implements the Primitive interface method.

func (*Set) GetFields

func (s *Set) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltypes.Result, error)

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) StreamExecute

func (s *Set) StreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error

StreamExecute implements the Primitive interface method.

type SetOp

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

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

type SingleRow

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

SingleRow defines an empty result

func (*SingleRow) Execute

func (s *SingleRow) Execute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (*sqltypes.Result, error)

Execute performs a non-streaming exec.

func (*SingleRow) GetFields

func (s *SingleRow) GetFields(vcursor VCursor, bindVars map[string]*query.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) StreamExecute

func (s *SingleRow) StreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error

StreamExecute performs a streaming exec.

type StreamExecutor

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

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

type Subquery

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

Subquery specifies the parameters for a subquery primitive.

func (*Subquery) Execute

func (sq *Subquery) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error)

Execute performs a non-streaming exec.

func (*Subquery) GetFields

func (sq *Subquery) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

GetFields fetches the field info.

func (*Subquery) GetKeyspaceName

func (sq *Subquery) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*Subquery) GetTableName

func (sq *Subquery) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (*Subquery) Inputs

func (sq *Subquery) Inputs() []Primitive

Inputs returns the input to this primitive

func (*Subquery) NeedsTransaction

func (sq *Subquery) NeedsTransaction() bool

func (*Subquery) RouteType

func (sq *Subquery) RouteType() string

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

func (*Subquery) StreamExecute

func (sq *Subquery) StreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error

StreamExecute performs a streaming exec.

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) Execute

func (svci *SysVarCheckAndIgnore) Execute(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) 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 SysVarSet

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

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

func (*SysVarSet) Execute

func (svs *SysVarSet) Execute(vcursor VCursor, env evalengine.ExpressionEnv) error

Execute implements the SetOp interface method

func (*SysVarSet) MarshalJSON

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

MarshalJSON provides the type to SetOp for plan json

func (*SysVarSet) VariableName

func (svs *SysVarSet) VariableName() string

VariableName implements the SetOp interface method

type SysVarSetSpecial

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

SysVarSetSpecial 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

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) Execute

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

Execute performs a non-streaming exec.

func (*Update) GetFields

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

GetFields fetches the field info.

func (*Update) GetKeyspaceName

func (upd *Update) GetKeyspaceName() string

GetKeyspaceName specifies the Keyspace that this primitive routes to.

func (*Update) GetTableName

func (upd *Update) GetTableName() string

GetTableName specifies the table that this primitive routes to.

func (Update) Inputs

func (Update) Inputs() []Primitive

Inputs implements no inputs

func (Update) NeedsTransaction

func (Update) NeedsTransaction() bool

func (*Update) RouteType

func (upd *Update) RouteType() string

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

func (*Update) StreamExecute

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

StreamExecute 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) Execute

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

Execute implements the Primitive interface

func (UpdateTarget) GetFields

func (updTarget UpdateTarget) GetFields(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) StreamExecute

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

StreamExecute 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) Execute

func (u *UserDefinedVariable) Execute(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 {
	// Context returns the context of the current request.
	Context() context.Context

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

	// SetContextTimeout updates the context and sets a timeout.
	SetContextTimeout(timeout time.Duration) context.CancelFunc

	// ErrorGroupCancellableContext updates context that can be cancelled.
	ErrorGroupCancellableContext() *errgroup.Group

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

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

	// Keyspace ID level functions.
	ExecuteKeyspaceID(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(keyspace string, ids []*querypb.Value, destinations []key.Destination) ([]*srvtopo.ResolvedShard, [][]*querypb.Value, error)

	ExecuteVSchema(keyspace string, vschemaDDL *sqlparser.DDL) error

	Session() SessionActions
}

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

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  sqltypes.PlanValue
	// contains filtered or unexported fields
}

VindexFunc is a primitive that performs vindex functions.

func (*VindexFunc) Execute

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

Execute performs a non-streaming exec.

func (*VindexFunc) GetFields

func (vf *VindexFunc) GetFields(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) StreamExecute

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

StreamExecute performs a streaming exec.

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 map[string]sqltypes.PlanValue

VindexValues contains changed values for a vindex.

Jump to

Keyboard shortcuts

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