vexec

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TableQualifier is the standard schema used by VExec commands
	TableQualifier = "_vt"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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

type ValColumns map[string](*sqlparser.Literal)

ValColumns map column name to Literal, for col=Val expressions in a WHERE clause

Jump to

Keyboard shortcuts

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