Documentation ¶
Index ¶
- Variables
- func GetSubqueryAndOtherSide(node *sqlparser.ComparisonExpr) (*sqlparser.Subquery, sqlparser.Expr)
- func RewriteDerivedTableExpression(expr sqlparser.Expr, vt TableInfo) sqlparser.Expr
- func ValidAsMapKey(s sqlparser.SQLNode) bool
- type AmbiguousColumnError
- type BuggyError
- type CTE
- type CTETable
- type CantGroupOn
- type CantUseMultipleVindexHints
- type CantUseOptionHereError
- type ColumnInfo
- type ColumnNotFoundClauseError
- type ColumnNotFoundError
- type ColumnsMissingInSchemaError
- type DerivedTable
- type ExprDependencies
- type FakeSI
- func (*FakeSI) ConnCollation() collations.ID
- func (s *FakeSI) Environment() *vtenv.Environment
- func (s *FakeSI) FindMirrorRule(tablename sqlparser.TableName) (*vindexes.MirrorRule, error)
- func (s *FakeSI) FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.Table, vindexes.Vindex, string, topodatapb.TabletType, ...)
- func (s *FakeSI) ForeignKeyMode(keyspace string) (vschemapb.Keyspace_ForeignKeyMode, error)
- func (s *FakeSI) GetAggregateUDFs() []string
- func (s *FakeSI) GetForeignKeyChecksState() *bool
- func (s *FakeSI) KeyspaceError(keyspace string) error
- type InvalidUseOfGroupFunction
- type JSONTablesError
- type LockOnlyWithDualError
- type MirrorInfo
- type MissingInVSchemaError
- type NextWithMultipleTablesError
- type NoSuchVindexFound
- type NotSequenceTableError
- type NotSingleRouteErr
- type QualifiedOrderInUnionError
- type QuerySignature
- type RealTable
- func (r *RealTable) GetAliasedTableExpr() *sqlparser.AliasedTableExpr
- func (r *RealTable) GetMirrorRule() *vindexes.MirrorRule
- func (r *RealTable) GetVindexHint() *sqlparser.IndexHint
- func (r *RealTable) GetVindexTable() *vindexes.Table
- func (r *RealTable) IsInfSchema() bool
- func (r *RealTable) Name() (sqlparser.TableName, error)
- type SQLCalcFoundRowsUsageError
- type SchemaInformation
- type SemTable
- func (st *SemTable) ASTEquals() *sqlparser.Comparator
- func (st *SemTable) AddColumnEquality(colName *sqlparser.ColName, expr sqlparser.Expr)
- func (st *SemTable) AddExprs(tbl *sqlparser.AliasedTableExpr, cols sqlparser.SelectExprs)
- func (st *SemTable) AndExpressions(exprs ...sqlparser.Expr) sqlparser.Expr
- func (st *SemTable) CanTakeSelectUnshardedShortcut() (*vindexes.Keyspace, bool)
- func (st *SemTable) CanTakeUnshardedShortcut() (*vindexes.Keyspace, bool)
- func (st *SemTable) Clone(n sqlparser.SQLNode) sqlparser.SQLNode
- func (st *SemTable) Cloned(from, to sqlparser.SQLNode)
- func (st *SemTable) ColumnLookup(col *sqlparser.ColName) (int, error)
- func (st *SemTable) ContainsExpr(e sqlparser.Expr, expres []sqlparser.Expr) bool
- func (st *SemTable) CopyDependencies(from, to sqlparser.Expr)
- func (st *SemTable) CopyExprInfo(src, dest sqlparser.Expr)
- func (st *SemTable) CopySemanticInfo(from, to sqlparser.SQLNode)
- func (st *SemTable) DefaultCollation() collations.ID
- func (st *SemTable) DirectDeps(expr sqlparser.Expr) TableSet
- func (st *SemTable) EqualsExpr(a, b sqlparser.Expr) bool
- func (st *SemTable) EqualsExprWithDeps(a, b sqlparser.Expr) bool
- func (st *SemTable) ErrIfFkDependentColumnUpdated(updateExprs sqlparser.UpdateExprs) error
- func (st *SemTable) ForeignKeysPresent() bool
- func (st *SemTable) GetChildForeignKeysForTable(tbl sqlparser.TableName) ([]vindexes.ChildFKInfo, error)
- func (st *SemTable) GetChildForeignKeysForTableSet(target TableSet) (fks []vindexes.ChildFKInfo)
- func (st *SemTable) GetChildForeignKeysForTargets() (fks []vindexes.ChildFKInfo)
- func (st *SemTable) GetChildForeignKeysList() []vindexes.ChildFKInfo
- func (st *SemTable) GetExprAndEqualities(expr sqlparser.Expr) []sqlparser.Expr
- func (st *SemTable) GetMirrorInfo() MirrorInfo
- func (st *SemTable) GetParentForeignKeysForTableSet(target TableSet) (fks []vindexes.ParentFKInfo)
- func (st *SemTable) GetParentForeignKeysForTargets() (fks []vindexes.ParentFKInfo)
- func (st *SemTable) GetParentForeignKeysList() []vindexes.ParentFKInfo
- func (st *SemTable) GetTargetTableSetForTableName(name sqlparser.TableName) (TableSet, error)
- func (st *SemTable) GetUpdateExpressionsForFk(foreignKey string) sqlparser.UpdateExprs
- func (st *SemTable) HasNonLiteralForeignKeyUpdate(updExprs sqlparser.UpdateExprs) bool
- func (st *SemTable) NewTableId() TableSet
- func (st *SemTable) RecursiveDeps(expr sqlparser.Expr) TableSet
- func (st *SemTable) RemoveNonRequiredForeignKeys(verifyAllFks bool, ...) error
- func (st *SemTable) RemoveParentForeignKey(fkToIgnore string) error
- func (st *SemTable) ReplaceTableSetFor(id TableSet, t *sqlparser.AliasedTableExpr)
- func (st *SemTable) SelectExprs(sel sqlparser.SelectStatement) sqlparser.SelectExprs
- func (st *SemTable) SingleKeyspace() (ks *vindexes.Keyspace)
- func (st *SemTable) SingleUnshardedKeyspace() (ks *vindexes.Keyspace, tables []*vindexes.Table)
- func (st *SemTable) TableInfoFor(id TableSet) (TableInfo, error)
- func (st *SemTable) TableInfoForExpr(expr sqlparser.Expr) (TableInfo, error)
- func (st *SemTable) TableSetFor(t *sqlparser.AliasedTableExpr) TableSet
- func (st *SemTable) TypeForExpr(e sqlparser.Expr) (evalengine.Type, bool)
- func (st *SemTable) Uniquify(in []sqlparser.Expr) []sqlparser.Expr
- func (st *SemTable) UpdateChildFKExpr(origUpdExpr *sqlparser.UpdateExpr, newExpr sqlparser.Expr)
- type ShardedError
- type SubqueryColumnCountError
- type TableInfo
- type TableNotUpdatableError
- type TableSet
- func (ts TableSet) Constituents() (result []TableSet)
- func (ts TableSet) ForEachTable(callback func(int))
- func (ts TableSet) Format(f fmt.State, verb rune)
- func (ts TableSet) IsEmpty() bool
- func (ts TableSet) IsOverlapping(other TableSet) bool
- func (ts TableSet) IsSolvedBy(other TableSet) bool
- func (ts TableSet) KeepOnly(other TableSet) TableSet
- func (ts TableSet) Merge(other TableSet) TableSet
- func (ts TableSet) NotEmpty() bool
- func (ts TableSet) NumberOfTables() int
- func (ts TableSet) Remove(other TableSet) TableSet
- func (ts TableSet) TableOffset() int
- func (ts TableSet) WithTable(tableidx int) TableSet
- type UnionColumnsDoNotMatchError
- type UnionWithSQLCalcFoundRowsError
- type UnsupportedConstruct
- type UnsupportedMultiTablesInUpdateError
- type UnsupportedNaturalJoinError
- type VindexTable
Constants ¶
This section is empty.
Variables ¶
var ErrNotSingleTable = vterrors.VT13001("should only be used for single tables")
ErrNotSingleTable refers to an error happening when something should be used only for single tables
Functions ¶
func GetSubqueryAndOtherSide ¶ added in v0.13.0
GetSubqueryAndOtherSide returns the subquery and other side of a comparison, iff one of the sides is a SubQuery
func RewriteDerivedTableExpression ¶ added in v0.15.0
RewriteDerivedTableExpression rewrites all the ColName instances in the supplied expression with the expressions behind the column definition of the derived table SELECT foo FROM (SELECT id+42 as foo FROM user) as t We need `foo` to be translated to `id+42` on the inside of the derived table
func ValidAsMapKey ¶ added in v0.13.0
Types ¶
type AmbiguousColumnError ¶ added in v0.17.0
type AmbiguousColumnError struct{ Column string }
func (*AmbiguousColumnError) Error ¶ added in v0.17.0
func (e *AmbiguousColumnError) Error() string
AmbiguousColumnError
func (*AmbiguousColumnError) ErrorCode ¶ added in v0.17.0
func (e *AmbiguousColumnError) ErrorCode() vtrpcpb.Code
func (*AmbiguousColumnError) ErrorState ¶ added in v0.17.0
func (e *AmbiguousColumnError) ErrorState() vterrors.State
type BuggyError ¶ added in v0.17.0
type BuggyError struct{ Msg string }
func (*BuggyError) Error ¶ added in v0.17.0
func (e *BuggyError) Error() string
BuggyError is used for checking conditions that should never occur
type CTETable ¶ added in v0.21.0
type CTETable struct { TableName string ASTNode *sqlparser.AliasedTableExpr *CTE }
CTETable contains the information about the CTE table. This is a special TableInfo that is used to represent the recursive table inside a CTE. For the query: WITH RECURSIVE cte AS (SELECT 1 UNION ALL SELECT * FROM cte as C1) SELECT * FROM cte as C2 The CTE table C1 is represented by a CTETable.
func (*CTETable) GetAliasedTableExpr ¶ added in v0.21.0
func (cte *CTETable) GetAliasedTableExpr() *sqlparser.AliasedTableExpr
func (*CTETable) GetMirrorRule ¶ added in v0.21.0
func (cte *CTETable) GetMirrorRule() *vindexes.MirrorRule
GetMirrorRule implements TableInfo.
func (*CTETable) GetVindexTable ¶ added in v0.21.0
func (*CTETable) IsInfSchema ¶ added in v0.21.0
type CantGroupOn ¶ added in v0.18.3
type CantGroupOn struct{ Column string }
func (*CantGroupOn) ErrorCode ¶ added in v0.18.3
func (*CantGroupOn) ErrorCode() vtrpcpb.Code
func (*CantGroupOn) ErrorState ¶ added in v0.18.3
func (e *CantGroupOn) ErrorState() vterrors.State
type CantUseMultipleVindexHints ¶ added in v0.20.0
type CantUseMultipleVindexHints struct{ Table string }
func (*CantUseMultipleVindexHints) Error ¶ added in v0.20.0
func (c *CantUseMultipleVindexHints) Error() string
CantUseMultipleVindexHints
func (*CantUseMultipleVindexHints) ErrorCode ¶ added in v0.20.0
func (c *CantUseMultipleVindexHints) ErrorCode() vtrpcpb.Code
type CantUseOptionHereError ¶ added in v0.17.0
type CantUseOptionHereError struct{ Msg string }
func (*CantUseOptionHereError) Error ¶ added in v0.17.0
func (e *CantUseOptionHereError) Error() string
CantUseOptionHereError
func (*CantUseOptionHereError) ErrorCode ¶ added in v0.17.0
func (e *CantUseOptionHereError) ErrorCode() vtrpcpb.Code
func (*CantUseOptionHereError) ErrorState ¶ added in v0.17.0
func (e *CantUseOptionHereError) ErrorState() vterrors.State
type ColumnInfo ¶ added in v0.12.0
type ColumnInfo struct { Name string Type evalengine.Type Invisible bool }
ColumnInfo contains information about columns
type ColumnNotFoundClauseError ¶ added in v0.18.3
func (*ColumnNotFoundClauseError) Error ¶ added in v0.18.3
func (e *ColumnNotFoundClauseError) Error() string
ColumnNotFoundInGroupByError
func (*ColumnNotFoundClauseError) ErrorCode ¶ added in v0.18.3
func (*ColumnNotFoundClauseError) ErrorCode() vtrpcpb.Code
func (*ColumnNotFoundClauseError) ErrorState ¶ added in v0.18.3
func (e *ColumnNotFoundClauseError) ErrorState() vterrors.State
type ColumnNotFoundError ¶ added in v0.17.0
func (ColumnNotFoundError) Error ¶ added in v0.17.0
func (e ColumnNotFoundError) Error() string
ColumnNotFoundError
func (ColumnNotFoundError) ErrorCode ¶ added in v0.17.0
func (e ColumnNotFoundError) ErrorCode() vtrpcpb.Code
func (ColumnNotFoundError) ErrorState ¶ added in v0.17.0
func (e ColumnNotFoundError) ErrorState() vterrors.State
type ColumnsMissingInSchemaError ¶ added in v0.18.0
type ColumnsMissingInSchemaError struct{}
func (*ColumnsMissingInSchemaError) Error ¶ added in v0.18.0
func (e *ColumnsMissingInSchemaError) Error() string
ColumnsMissingInSchemaError
func (*ColumnsMissingInSchemaError) ErrorCode ¶ added in v0.18.0
func (e *ColumnsMissingInSchemaError) ErrorCode() vtrpcpb.Code
type DerivedTable ¶ added in v0.13.0
type DerivedTable struct { ASTNode *sqlparser.AliasedTableExpr // contains filtered or unexported fields }
DerivedTable contains the information about the projection, tables involved in derived table.
func (*DerivedTable) GetAliasedTableExpr ¶ added in v0.19.0
func (dt *DerivedTable) GetAliasedTableExpr() *sqlparser.AliasedTableExpr
func (*DerivedTable) GetMirrorRule ¶ added in v0.21.0
func (dt *DerivedTable) GetMirrorRule() *vindexes.MirrorRule
GetMirrorRule implements TableInfo.
func (*DerivedTable) GetVindexTable ¶ added in v0.13.0
func (dt *DerivedTable) GetVindexTable() *vindexes.Table
GetVindexTable implements the TableInfo interface
func (*DerivedTable) IsInfSchema ¶ added in v0.13.0
func (dt *DerivedTable) IsInfSchema() bool
IsInfSchema implements the TableInfo interface
type ExprDependencies ¶ added in v0.12.0
ExprDependencies stores the tables that an expression depends on as a map
type FakeSI ¶ added in v0.11.0
type FakeSI struct { Tables map[string]*vindexes.Table VindexTables map[string]vindexes.Vindex KsForeignKeyMode map[string]vschemapb.Keyspace_ForeignKeyMode KsError map[string]error UDFs []string }
FakeSI is a fake SchemaInformation for testing
func (*FakeSI) ConnCollation ¶ added in v0.13.0
func (*FakeSI) ConnCollation() collations.ID
func (*FakeSI) Environment ¶ added in v0.19.0
func (s *FakeSI) Environment() *vtenv.Environment
func (*FakeSI) FindMirrorRule ¶ added in v0.21.0
FindMirrorRule implements SchemaInformation.
func (*FakeSI) FindTableOrVindex ¶ added in v0.11.0
func (s *FakeSI) FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.Table, vindexes.Vindex, string, topodatapb.TabletType, key.Destination, error)
FindTableOrVindex implements the SchemaInformation interface
func (*FakeSI) ForeignKeyMode ¶ added in v0.19.0
func (s *FakeSI) ForeignKeyMode(keyspace string) (vschemapb.Keyspace_ForeignKeyMode, error)
func (*FakeSI) GetAggregateUDFs ¶ added in v0.20.0
func (*FakeSI) GetForeignKeyChecksState ¶ added in v0.19.0
func (*FakeSI) KeyspaceError ¶ added in v0.19.0
type InvalidUseOfGroupFunction ¶ added in v0.18.3
type InvalidUseOfGroupFunction struct{}
func (*InvalidUseOfGroupFunction) Error ¶ added in v0.18.3
func (*InvalidUseOfGroupFunction) Error() string
InvalidUseOfGroupFunction
func (*InvalidUseOfGroupFunction) ErrorCode ¶ added in v0.18.3
func (*InvalidUseOfGroupFunction) ErrorCode() vtrpcpb.Code
func (*InvalidUseOfGroupFunction) ErrorState ¶ added in v0.18.3
func (*InvalidUseOfGroupFunction) ErrorState() vterrors.State
type JSONTablesError ¶ added in v0.17.0
type JSONTablesError struct{ Table string }
func (*JSONTablesError) Error ¶ added in v0.17.0
func (e *JSONTablesError) Error() string
JSONTablesError
type LockOnlyWithDualError ¶ added in v0.17.0
type LockOnlyWithDualError struct{ Node *sqlparser.LockingFunc }
func (*LockOnlyWithDualError) Error ¶ added in v0.17.0
func (e *LockOnlyWithDualError) Error() string
LockOnlyWithDualError
func (*LockOnlyWithDualError) ErrorCode ¶ added in v0.17.0
func (e *LockOnlyWithDualError) ErrorCode() vtrpcpb.Code
type MirrorInfo ¶ added in v0.21.0
type MirrorInfo struct {
Percent float32
}
MirrorInfo stores information used to produce mirror operators.
type MissingInVSchemaError ¶ added in v0.17.0
type MissingInVSchemaError struct{ Table TableInfo }
func (*MissingInVSchemaError) Error ¶ added in v0.17.0
func (e *MissingInVSchemaError) Error() string
MissingInVSchemaError
func (*MissingInVSchemaError) ErrorCode ¶ added in v0.17.0
func (e *MissingInVSchemaError) ErrorCode() vtrpcpb.Code
type NextWithMultipleTablesError ¶ added in v0.17.0
type NextWithMultipleTablesError struct{ CountTables int }
func (*NextWithMultipleTablesError) Error ¶ added in v0.17.0
func (e *NextWithMultipleTablesError) Error() string
NextWithMultipleTablesError
type NoSuchVindexFound ¶ added in v0.20.0
func (*NoSuchVindexFound) Error ¶ added in v0.20.0
func (c *NoSuchVindexFound) Error() string
NoSuchVindexFound
func (*NoSuchVindexFound) ErrorCode ¶ added in v0.20.0
func (c *NoSuchVindexFound) ErrorCode() vtrpcpb.Code
type NotSequenceTableError ¶ added in v0.17.0
type NotSequenceTableError struct{ Table string }
func (*NotSequenceTableError) Error ¶ added in v0.17.0
func (e *NotSequenceTableError) Error() string
NotSequenceTableError
func (*NotSequenceTableError) ErrorCode ¶ added in v0.17.0
func (e *NotSequenceTableError) ErrorCode() vtrpcpb.Code
type NotSingleRouteErr ¶ added in v0.21.0
type NotSingleRouteErr struct {
Inner error
}
NotSingleRouteErr is used to mark an error as something that should only be returned if the planner fails to merge everything down to a single route
func (NotSingleRouteErr) Error ¶ added in v0.21.0
func (p NotSingleRouteErr) Error() string
type QualifiedOrderInUnionError ¶ added in v0.17.0
type QualifiedOrderInUnionError struct{ Table string }
func (*QualifiedOrderInUnionError) Error ¶ added in v0.17.0
func (e *QualifiedOrderInUnionError) Error() string
QualifiedOrderInUnionError
type QuerySignature ¶ added in v0.18.0
type QuerySignature struct { Aggregation bool DML bool Distinct bool HashJoin bool SubQueries bool Union bool RecursiveCTE bool }
QuerySignature is used to identify shortcuts in the planning process
type RealTable ¶ added in v0.12.0
type RealTable struct { ASTNode *sqlparser.AliasedTableExpr Table *vindexes.Table CTE *CTE VindexHint *sqlparser.IndexHint MirrorRule *vindexes.MirrorRule // contains filtered or unexported fields }
RealTable contains the alias table expr and vindex table
func (*RealTable) GetAliasedTableExpr ¶ added in v0.19.0
func (r *RealTable) GetAliasedTableExpr() *sqlparser.AliasedTableExpr
GetExpr implements the TableInfo interface
func (*RealTable) GetMirrorRule ¶ added in v0.21.0
func (r *RealTable) GetMirrorRule() *vindexes.MirrorRule
GetMirrorRule implements TableInfo.
func (*RealTable) GetVindexHint ¶ added in v0.20.0
GetVindexHint implements the TableInfo interface
func (*RealTable) GetVindexTable ¶ added in v0.12.0
GetVindexTable implements the TableInfo interface
func (*RealTable) IsInfSchema ¶ added in v0.12.0
IsInfSchema implements the TableInfo interface
type SQLCalcFoundRowsUsageError ¶ added in v0.17.0
type SQLCalcFoundRowsUsageError struct{}
func (*SQLCalcFoundRowsUsageError) Error ¶ added in v0.17.0
func (e *SQLCalcFoundRowsUsageError) Error() string
SQLCalcFoundRowsUsageError
func (*SQLCalcFoundRowsUsageError) ErrorCode ¶ added in v0.17.0
func (e *SQLCalcFoundRowsUsageError) ErrorCode() vtrpcpb.Code
type SchemaInformation ¶ added in v0.11.0
type SchemaInformation interface { FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.Table, vindexes.Vindex, string, topodatapb.TabletType, key.Destination, error) ConnCollation() collations.ID Environment() *vtenv.Environment // ForeignKeyMode returns the foreign_key flag value ForeignKeyMode(keyspace string) (vschemapb.Keyspace_ForeignKeyMode, error) GetForeignKeyChecksState() *bool KeyspaceError(keyspace string) error GetAggregateUDFs() []string FindMirrorRule(tablename sqlparser.TableName) (*vindexes.MirrorRule, error) }
SchemaInformation is used to provide table information from Vschema.
type SemTable ¶
type SemTable struct { // Tables stores information about the tables in the query, including derived tables Tables []TableInfo // Comments stores any comments of the /* vt+ */ type in the query Comments *sqlparser.ParsedComments // Warning stores any warnings generated during semantic analysis. Warning string // Collation represents the default collation for the query, usually inherited // from the connection's default collation. Collation collations.ID // ExprTypes maps expressions to their respective types in the query. ExprTypes map[sqlparser.Expr]evalengine.Type // NotSingleRouteErr stores errors related to missing schema information. // This typically occurs when a column's existence is uncertain. // Instead of failing early, the query is allowed to proceed, possibly // succeeding once it reaches MySQL. NotSingleRouteErr error // NotUnshardedErr stores errors that occur if the query isn't planned as a single route // targeting an unsharded keyspace. This typically arises when information is missing, but // for unsharded tables, the code operates in a passthrough mode, relying on the underlying // MySQL engine to handle errors appropriately. NotUnshardedErr error // Recursive contains dependencies from the expression to the actual tables // in the query (excluding derived tables). For columns in derived tables, // this map holds the accumulated dependencies for the column expression. Recursive ExprDependencies // Direct stores information about the closest dependency for an expression. // It doesn't recurse inside derived tables to find the original dependencies. Direct ExprDependencies // Targets contains the TableSet of each table getting modified by the update/delete statement. Targets TableSet // ColumnEqualities is used for transitive closures (e.g., if a == b and b == c, then a == c). ColumnEqualities map[columnName][]sqlparser.Expr // ExpandedColumns is a map of all the added columns for a given table. // The columns were added because of the use of `*` in the query ExpandedColumns map[sqlparser.TableName][]*sqlparser.ColName // StatementIDs is a map of statements and all the table IDs that are contained within StatementIDs map[sqlparser.Statement]TableSet // QuerySignature is used to identify shortcuts in the planning process QuerySignature QuerySignature // contains filtered or unexported fields }
SemTable contains semantic analysis information about the query.
func Analyze ¶ added in v0.11.0
func Analyze(statement sqlparser.Statement, currentDb string, si SchemaInformation) (*SemTable, error)
Analyze analyzes the parsed query.
func AnalyzeStrict ¶ added in v0.17.0
func AnalyzeStrict(statement sqlparser.Statement, currentDb string, si SchemaInformation) (*SemTable, error)
AnalyzeStrict analyzes the parsed query, and fails the analysis for any possible errors
func EmptySemTable ¶ added in v0.13.0
func EmptySemTable() *SemTable
EmptySemTable creates a new empty SemTable
func (*SemTable) ASTEquals ¶ added in v0.16.0
func (st *SemTable) ASTEquals() *sqlparser.Comparator
ASTEquals returns a sqlparser.Comparator that uses the semantic information in this SemTable to explicitly compare column names for equality.
func (*SemTable) AddColumnEquality ¶ added in v0.12.0
AddColumnEquality adds a relation of the given colName to the ColumnEqualities map
func (*SemTable) AddExprs ¶ added in v0.11.0
func (st *SemTable) AddExprs(tbl *sqlparser.AliasedTableExpr, cols sqlparser.SelectExprs)
AddExprs adds new select exprs to the SemTable.
func (*SemTable) AndExpressions ¶ added in v0.16.0
AndExpressions ands together two or more expressions, minimising the expr when possible
func (*SemTable) CanTakeSelectUnshardedShortcut ¶ added in v0.21.0
func (*SemTable) CanTakeUnshardedShortcut ¶ added in v0.21.0
func (*SemTable) Cloned ¶ added in v0.17.0
Cloned copies the dependencies from one expression into the other
func (*SemTable) ColumnLookup ¶ added in v0.13.0
ColumnLookup implements the TranslationLookup interface
func (*SemTable) ContainsExpr ¶ added in v0.16.0
func (*SemTable) CopyDependencies ¶ added in v0.12.0
CopyDependencies copies the dependencies from one expression into the other
func (*SemTable) CopyExprInfo ¶ added in v0.13.0
CopyExprInfo lookups src in the ExprTypes map and, if a key is found, assign the corresponding Type value of src to dest.
func (*SemTable) CopySemanticInfo ¶ added in v0.18.0
CopySemanticInfo copies all semantic information we have about this SQLNode so that it also applies to the `to` node
func (*SemTable) DefaultCollation ¶ added in v0.13.0
func (st *SemTable) DefaultCollation() collations.ID
func (*SemTable) DirectDeps ¶ added in v0.12.0
DirectDeps return the table dependencies of the expression.
func (*SemTable) EqualsExpr ¶ added in v0.16.0
EqualsExpr compares two expressions using the semantic analysis information. This means that we use the binding info to recognize that two ColName's can point to the same table column even though they are written differently. Example would be the `foobar` column in the following query: `SELECT foobar FROM tbl ORDER BY tbl.foobar` The expression in the select list is not equal to the one in the ORDER BY, but they point to the same column and would be considered equal by this method
func (*SemTable) EqualsExprWithDeps ¶ added in v0.17.0
EqualsExprWithDeps compares two expressions taking into account their semantic information. Dependency data typically pertains only to column expressions, this method considers them for all expression types. The method checks if dependency information exists for both expressions. If it does, the dependencies must match. If we are missing dependency information for either
func (*SemTable) ErrIfFkDependentColumnUpdated ¶ added in v0.19.0
func (st *SemTable) ErrIfFkDependentColumnUpdated(updateExprs sqlparser.UpdateExprs) error
ErrIfFkDependentColumnUpdated checks if a foreign key column that is being updated is dependent on another column which also being updated.
func (*SemTable) ForeignKeysPresent ¶ added in v0.19.0
ForeignKeysPresent returns whether there are any foreign key constraints left in the semantic table that require handling.
func (*SemTable) GetChildForeignKeysForTable ¶ added in v0.19.0
func (st *SemTable) GetChildForeignKeysForTable(tbl sqlparser.TableName) ([]vindexes.ChildFKInfo, error)
GetChildForeignKeysForTable gets the child foreign keys as a list for the specified TableName.
func (*SemTable) GetChildForeignKeysForTableSet ¶ added in v0.20.0
func (st *SemTable) GetChildForeignKeysForTableSet(target TableSet) (fks []vindexes.ChildFKInfo)
GetChildForeignKeysForTableSet gets the child foreign keys as a listfor the TableSet.
func (*SemTable) GetChildForeignKeysForTargets ¶ added in v0.20.0
func (st *SemTable) GetChildForeignKeysForTargets() (fks []vindexes.ChildFKInfo)
GetChildForeignKeysForTargets gets the child foreign keys as a list for all the target tables.
func (*SemTable) GetChildForeignKeysList ¶ added in v0.19.0
func (st *SemTable) GetChildForeignKeysList() []vindexes.ChildFKInfo
GetChildForeignKeysList gets the child foreign keys as a list.
func (*SemTable) GetExprAndEqualities ¶ added in v0.12.0
GetExprAndEqualities returns a slice containing the given expression, and it's known equalities if any
func (*SemTable) GetMirrorInfo ¶ added in v0.21.0
func (st *SemTable) GetMirrorInfo() MirrorInfo
func (*SemTable) GetParentForeignKeysForTableSet ¶ added in v0.20.0
func (st *SemTable) GetParentForeignKeysForTableSet(target TableSet) (fks []vindexes.ParentFKInfo)
GetParentForeignKeysForTableSet gets the parent foreign keys as a list for the TableSet.
func (*SemTable) GetParentForeignKeysForTargets ¶ added in v0.20.0
func (st *SemTable) GetParentForeignKeysForTargets() (fks []vindexes.ParentFKInfo)
GetParentForeignKeysForTargets gets the parent foreign keys as a list for all the target tables.
func (*SemTable) GetParentForeignKeysList ¶ added in v0.19.0
func (st *SemTable) GetParentForeignKeysList() []vindexes.ParentFKInfo
GetParentForeignKeysList gets the parent foreign keys as a list.
func (*SemTable) GetTargetTableSetForTableName ¶ added in v0.20.0
GetTargetTableSetForTableName returns the TableSet for the given table name from the target tables.
func (*SemTable) GetUpdateExpressionsForFk ¶ added in v0.19.0
func (st *SemTable) GetUpdateExpressionsForFk(foreignKey string) sqlparser.UpdateExprs
GetUpdateExpressionsForFk gets the update expressions for the given serialized foreign key constraint.
func (*SemTable) HasNonLiteralForeignKeyUpdate ¶ added in v0.19.0
func (st *SemTable) HasNonLiteralForeignKeyUpdate(updExprs sqlparser.UpdateExprs) bool
HasNonLiteralForeignKeyUpdate checks for non-literal updates in expressions linked to a foreign key.
func (*SemTable) NewTableId ¶ added in v0.20.0
NewTableId creates a new table id and returns it.
func (*SemTable) RecursiveDeps ¶ added in v0.12.0
RecursiveDeps return the table dependencies of the expression.
func (*SemTable) RemoveNonRequiredForeignKeys ¶ added in v0.19.0
func (st *SemTable) RemoveNonRequiredForeignKeys(verifyAllFks bool, getAction func(fk vindexes.ChildFKInfo) sqlparser.ReferenceAction) error
RemoveNonRequiredForeignKeys prunes the list of foreign keys that the query involves. This function considers whether VTGate needs to validate all foreign keys or can delegate some of the responsibility to MySQL. In the latter case, the following types of foreign keys can be safely removed from our list: 1. Shard-scoped parent foreign keys: MySQL itself will reject a DML operation that violates these constraints. 2. Shard-scoped RESTRICT foreign keys: MySQL will also fail the operation if these foreign key constraints are breached.
func (*SemTable) RemoveParentForeignKey ¶ added in v0.19.0
RemoveParentForeignKey removes the given foreign key from the parent foreign keys that sem table stores.
func (*SemTable) ReplaceTableSetFor ¶ added in v0.13.1
func (st *SemTable) ReplaceTableSetFor(id TableSet, t *sqlparser.AliasedTableExpr)
ReplaceTableSetFor replaces the given single TabletSet with the new *sqlparser.AliasedTableExpr
func (*SemTable) SelectExprs ¶ added in v0.18.0
func (st *SemTable) SelectExprs(sel sqlparser.SelectStatement) sqlparser.SelectExprs
func (*SemTable) SingleKeyspace ¶ added in v0.19.0
SingleKeyspace returns the single keyspace if all tables in the query are in the same keyspace
func (*SemTable) SingleUnshardedKeyspace ¶ added in v0.13.0
SingleUnshardedKeyspace returns the single keyspace if all tables in the query are in the same, unsharded keyspace
func (*SemTable) TableInfoFor ¶ added in v0.11.0
TableInfoFor returns the table info for the table set. It should contains only single table.
func (*SemTable) TableInfoForExpr ¶ added in v0.12.0
TableInfoForExpr returns the table info of the table that this expression depends on. Careful: this only works for expressions that have a single table dependency
func (*SemTable) TableSetFor ¶
func (st *SemTable) TableSetFor(t *sqlparser.AliasedTableExpr) TableSet
TableSetFor returns the bitmask for this particular table
func (*SemTable) TypeForExpr ¶ added in v0.17.0
TypeForExpr returns the type of expressions in the query Note that PlanningContext has the same method, and you should use that if you have a PlanningContext
func (*SemTable) Uniquify ¶ added in v0.18.0
Uniquify takes a slice of expressions and removes any duplicates
func (*SemTable) UpdateChildFKExpr ¶ added in v0.20.0
func (st *SemTable) UpdateChildFKExpr(origUpdExpr *sqlparser.UpdateExpr, newExpr sqlparser.Expr)
UpdateChildFKExpr updates the child foreign key expression with the new expression.
type ShardedError ¶ added in v0.14.5
type ShardedError struct {
Inner error
}
ShardedError is used to mark an error as something that should only be returned if the query is not unsharded
func (ShardedError) Error ¶ added in v0.14.5
func (p ShardedError) Error() string
func (ShardedError) Unwrap ¶ added in v0.18.3
func (p ShardedError) Unwrap() error
type SubqueryColumnCountError ¶ added in v0.18.0
type SubqueryColumnCountError struct{ Expected int }
func (*SubqueryColumnCountError) Error ¶ added in v0.18.0
func (e *SubqueryColumnCountError) Error() string
func (*SubqueryColumnCountError) ErrorCode ¶ added in v0.18.0
func (e *SubqueryColumnCountError) ErrorCode() vtrpcpb.Code
SubqueryColumnCountError
type TableInfo ¶ added in v0.11.0
type TableInfo interface { // Name returns the table name Name() (sqlparser.TableName, error) // GetVindexTable returns the vschema version of this TableInfo GetVindexTable() *vindexes.Table // IsInfSchema returns true if this table is information_schema IsInfSchema() bool // getAliasedTableExpr returns the AST struct behind this table GetAliasedTableExpr() *sqlparser.AliasedTableExpr // GetMirrorRule returns the vschema mirror rule for this TableInfo GetMirrorRule() *vindexes.MirrorRule // contains filtered or unexported methods }
TableInfo contains information about tables
type TableNotUpdatableError ¶ added in v0.17.0
type TableNotUpdatableError struct{ Table string }
func (*TableNotUpdatableError) Error ¶ added in v0.17.0
func (e *TableNotUpdatableError) Error() string
TableNotUpdatableError
func (*TableNotUpdatableError) ErrorCode ¶ added in v0.17.0
func (e *TableNotUpdatableError) ErrorCode() vtrpcpb.Code
func (*TableNotUpdatableError) ErrorState ¶ added in v0.17.0
func (e *TableNotUpdatableError) ErrorState() vterrors.State
type TableSet ¶
TableSet is how a set of tables is expressed. Tables get unique bits assigned in the order that they are encountered during semantic analysis.
func EmptyTableSet ¶ added in v0.13.0
func EmptyTableSet() TableSet
EmptyTableSet creates an empty TableSet
func MergeTableSets ¶ added in v0.12.0
MergeTableSets merges all the given TableSet into a single one
func SingleTableSet ¶ added in v0.12.0
SingleTableSet creates a TableSet that contains only the given table
func TableSetFromIds ¶ added in v0.12.0
TableSetFromIds returns TableSet for all the id passed in argument.
func (TableSet) Constituents ¶
Constituents returns a slice with the indices for all tables in this TableSet
func (TableSet) ForEachTable ¶ added in v0.12.0
ForEachTable calls the given callback with the indices for all tables in this TableSet
func (TableSet) IsEmpty ¶ added in v0.15.1
IsEmpty returns true if there are no tables in the tableset
func (TableSet) IsOverlapping ¶
IsOverlapping returns true if at least one table exists in both sets
func (TableSet) IsSolvedBy ¶
IsSolvedBy returns true if all of `ts` is contained in `other`
func (TableSet) KeepOnly ¶ added in v0.13.0
KeepOnly removes all the tables not in `other` from this TableSet
func (TableSet) NotEmpty ¶ added in v0.19.0
NonEmpty returns true if there are tables in the tableset
func (TableSet) NumberOfTables ¶
NumberOfTables returns the number of bits set
func (TableSet) Remove ¶ added in v0.15.1
Remove returns a new TableSet with all the tables in `other` removed
func (TableSet) TableOffset ¶ added in v0.11.0
TableOffset returns the offset in the Tables array from TableSet
type UnionColumnsDoNotMatchError ¶ added in v0.17.0
func (*UnionColumnsDoNotMatchError) Error ¶ added in v0.17.0
func (e *UnionColumnsDoNotMatchError) Error() string
func (*UnionColumnsDoNotMatchError) ErrorCode ¶ added in v0.17.0
func (e *UnionColumnsDoNotMatchError) ErrorCode() vtrpcpb.Code
func (*UnionColumnsDoNotMatchError) ErrorState ¶ added in v0.17.0
func (e *UnionColumnsDoNotMatchError) ErrorState() vterrors.State
UnionColumnsDoNotMatchError
type UnionWithSQLCalcFoundRowsError ¶ added in v0.17.0
type UnionWithSQLCalcFoundRowsError struct{}
func (*UnionWithSQLCalcFoundRowsError) Error ¶ added in v0.17.0
func (e *UnionWithSQLCalcFoundRowsError) Error() string
UnionWithSQLCalcFoundRowsError
type UnsupportedConstruct ¶ added in v0.17.0
type UnsupportedConstruct struct {
// contains filtered or unexported fields
}
func (*UnsupportedConstruct) Error ¶ added in v0.17.0
func (e *UnsupportedConstruct) Error() string
func (*UnsupportedConstruct) ErrorCode ¶ added in v0.17.0
func (e *UnsupportedConstruct) ErrorCode() vtrpcpb.Code
type UnsupportedMultiTablesInUpdateError ¶ added in v0.17.0
func (*UnsupportedMultiTablesInUpdateError) Error ¶ added in v0.17.0
func (e *UnsupportedMultiTablesInUpdateError) Error() string
UnsupportedMultiTablesInUpdateError
type UnsupportedNaturalJoinError ¶ added in v0.17.0
type UnsupportedNaturalJoinError struct{ JoinExpr *sqlparser.JoinTableExpr }
func (*UnsupportedNaturalJoinError) Error ¶ added in v0.17.0
func (e *UnsupportedNaturalJoinError) Error() string
UnsupportedNaturalJoinError
type VindexTable ¶ added in v0.12.0
VindexTable contains a vindexes.Vindex and a TableInfo. The former represents the vindex we are keeping information about, and the latter represents the additional table information (usually a RealTable or an AliasedTable) of our vindex.
func (*VindexTable) GetAliasedTableExpr ¶ added in v0.19.0
func (v *VindexTable) GetAliasedTableExpr() *sqlparser.AliasedTableExpr
GetExpr implements the TableInfo interface
func (*VindexTable) GetMirrorRule ¶ added in v0.21.0
func (v *VindexTable) GetMirrorRule() *vindexes.MirrorRule
GetMirrorRule implements TableInfo.
func (*VindexTable) GetVindexTable ¶ added in v0.12.0
func (v *VindexTable) GetVindexTable() *vindexes.Table
GetVindexTable implements the TableInfo interface
func (*VindexTable) IsInfSchema ¶ added in v0.12.0
func (v *VindexTable) IsInfSchema() bool
IsInfSchema implements the TableInfo interface