Documentation ¶
Index ¶
- Constants
- Variables
- type Executor
- type TabletVExec
- func (e *TabletVExec) AddOrReplaceInsertColumnVal(colName string, val *sqlparser.Literal) error
- func (e *TabletVExec) AnalyzeQuery(ctx context.Context, query string) (err error)
- func (e *TabletVExec) ColumnStringVal(columns ValColumns, colName string) (string, error)
- func (e *TabletVExec) ReplaceInsertColumnVal(colName string, val *sqlparser.Literal) error
- func (e *TabletVExec) SetColumnStringVal(columns ValColumns, colName string, val string)
- func (e *TabletVExec) ToStringVal(val string) *sqlparser.Literal
- type ValColumns
Constants ¶
const (
// TableQualifier is the standard schema used by VExec commands
TableQualifier = "_vt"
)
Variables ¶
var ( // ErrColumNotFound is returned when we expect some column to exist and it does not ErrColumNotFound = errors.New("Column not found") )
Functions ¶
This section is empty.
Types ¶
type Executor ¶ added in v0.10.0
type Executor interface {
VExec(ctx context.Context, vx *TabletVExec) (qr *querypb.QueryResult, err error)
}
Executor should be implemented by any tablet-side structs which accept VExec commands
type TabletVExec ¶
type TabletVExec struct { Workflow string Keyspace string Query string Stmt sqlparser.Statement TableName string WhereCols ValColumns UpdateCols ValColumns InsertCols ValColumns }
TabletVExec is a utility structure, created when a VExec command is intercepted on the tablet. This structure will parse and analyze the query, and make available some useful data. VExec interceptors receive an instance of this struct so they can run more analysis/checks on the given query, and potentially modify it.
func NewTabletVExec ¶
func NewTabletVExec(workflow, keyspace string) *TabletVExec
NewTabletVExec creates a new instance of TabletVExec
func (*TabletVExec) AddOrReplaceInsertColumnVal ¶ added in v0.9.0
func (e *TabletVExec) AddOrReplaceInsertColumnVal(colName string, val *sqlparser.Literal) error
AddOrReplaceInsertColumnVal manipulates the existing INSERT statement to replace a column value into a given value
func (*TabletVExec) AnalyzeQuery ¶
func (e *TabletVExec) AnalyzeQuery(ctx context.Context, query string) (err error)
AnalyzeQuery analyzes a given statement and produces the following ingredients, useful for VExec interceptors:
- parsed statement
- table name
- column names with values, for col=VAL in a WHERE expression e.g. in "UPDATE my_table SET ... WHERE keyspace='test' AND shard='-80' AND status > 2", the ValColumns are "keyspace" and "shard" with matching values. `status` is a range operator therefore not included.package vexec Equals operator is of special importance because it is known to filter results. An interceptor may require, for example, that a `DELETE` statement includes a WHERE with a UNIQUE KEY column with Equals operator to ensure we're not doing anything too risky.
func (*TabletVExec) ColumnStringVal ¶
func (e *TabletVExec) ColumnStringVal(columns ValColumns, colName string) (string, error)
ColumnStringVal returns a string value from a given column, or error if the column is not found
func (*TabletVExec) ReplaceInsertColumnVal ¶
func (e *TabletVExec) ReplaceInsertColumnVal(colName string, val *sqlparser.Literal) error
ReplaceInsertColumnVal manipulates the existing INSERT statement to replace a column value into a given value
func (*TabletVExec) SetColumnStringVal ¶
func (e *TabletVExec) SetColumnStringVal(columns ValColumns, colName string, val string)
SetColumnStringVal modifies a column value into a given string
func (*TabletVExec) ToStringVal ¶
func (e *TabletVExec) ToStringVal(val string) *sqlparser.Literal
ToStringVal converts a string to a string -typed Literal
type ValColumns ¶
ValColumns map column name to Literal, for col=Val expressions in a WHERE clause