Documentation ¶
Index ¶
- Constants
- func GenerateSelectResultRowData(r *mysql.Result) error
- func HandleDeletePlan(p *DeletePlan) error
- func HandleInsertStmt(p *InsertPlan, stmt *ast.InsertStmt) error
- func HandleSelectStmt(p *SelectPlan, stmt *ast.SelectStmt) error
- func HandleUpdatePlan(p *UpdatePlan) error
- func IsSelectLastInsertIDStmt(stmt ast.StmtNode) bool
- func MergeExecResult(rs []*mysql.Result) (*mysql.Result, error)
- func MergeSelectResult(p *SelectPlan, stmt *ast.SelectStmt, rs []*mysql.Result) (*mysql.Result, error)
- func NeedCreateBetweenExprDecorator(p *TableAliasStmtInfo, n *ast.BetweenExpr) (router.Rule, bool, error)
- func NeedCreateColumnNameExprDecoratorInCondition(p *TableAliasStmtInfo, n *ast.ColumnNameExpr) (router.Rule, bool, error)
- func NeedCreateColumnNameExprDecoratorInField(p *TableAliasStmtInfo, n *ast.ColumnNameExpr) (router.Rule, bool, error)
- func NeedCreatePatternInExprDecorator(p *TableAliasStmtInfo, n *ast.PatternInExpr) (router.Rule, bool, error)
- func NeedCreateTableNameDecorator(p *TableAliasStmtInfo, n *ast.TableName, alias string) (router.Rule, bool, error)
- func NeedCreateTableNameDecoratorWithoutAlias(p *StmtInfo, n *ast.TableName) (router.Rule, bool, error)
- func NeedRewriteLimitOrCreateRewrite(stmt *ast.SelectStmt) (bool, int64, int64, *ast.Limit)
- type AggregateFuncCountMerger
- type AggregateFuncMaxMerger
- type AggregateFuncMerger
- type AggregateFuncMinMerger
- type AggregateFuncSumMerger
- type BetweenExprDecorator
- type BinaryOperationFieldtype
- type Checker
- type ColumnNameDecorator
- func (c *ColumnNameDecorator) Accept(v ast.Visitor) (ast.Node, bool)
- func (c *ColumnNameDecorator) GetColumnInfo() (string, string, string)
- func (c *ColumnNameDecorator) Restore(ctx *format.RestoreCtx) error
- func (c *ColumnNameDecorator) SetText(text string)
- func (c *ColumnNameDecorator) Text() string
- type ColumnNameExprDecorator
- type ColumnNameRewriteVisitor
- type DeletePlan
- type Executor
- type ExplainPlan
- type InsertPlan
- type PatternInExprDecorator
- func (p *PatternInExprDecorator) Accept(v ast.Visitor) (node ast.Node, ok bool)
- func (p *PatternInExprDecorator) Format(w io.Writer)
- func (p *PatternInExprDecorator) GetCurrentRouteResult() []int
- func (p *PatternInExprDecorator) GetFlag() uint64
- func (p *PatternInExprDecorator) GetType() *types.FieldType
- func (p *PatternInExprDecorator) Restore(ctx *format.RestoreCtx) error
- func (p *PatternInExprDecorator) SetFlag(flag uint64)
- func (p *PatternInExprDecorator) SetText(text string)
- func (p *PatternInExprDecorator) SetType(tp *types.FieldType)
- func (p *PatternInExprDecorator) Text() string
- type Plan
- type ResultRow
- type RouteResult
- func (r *RouteResult) Check(db, table string) error
- func (r *RouteResult) GetCurrentTableIndex() (int, error)
- func (r *RouteResult) GetShardIndexes() []int
- func (r *RouteResult) HasNext() bool
- func (r *RouteResult) Inter(indexes []int)
- func (r *RouteResult) Next() int
- func (r *RouteResult) Reset()
- func (r *RouteResult) Union(indexes []int)
- type SelectLastInsertIDPlan
- type SelectPlan
- func (s *SelectPlan) ExecuteIn(reqCtx *util.RequestContext, sess Executor) (*mysql.Result, error)
- func (s *SelectPlan) GetColumnCount() int
- func (s *SelectPlan) GetGroupByColumnInfo() (int, int)
- func (s *SelectPlan) GetLimitValue() (int64, int64)
- func (s *SelectPlan) GetOrderByColumnInfo() (int, []bool)
- func (s *SelectPlan) GetOriginColumnCount() int
- func (s *SelectPlan) GetSQLs() map[string]map[string][]string
- func (s *SelectPlan) GetStmt() *ast.SelectStmt
- func (s *SelectPlan) HasGroupBy() bool
- func (s *SelectPlan) HasLimit() bool
- func (s *SelectPlan) HasOrderBy() bool
- func (*SelectPlan) Size() int
- type StmtInfo
- type SubqueryColumnNameRewriteVisitor
- type TableAliasStmtInfo
- type TableNameDecorator
- type UnshardPlan
- type UpdatePlan
Constants ¶
const ( ShardTypeUnshard = "unshard" ShardTypeShard = "shard" )
constants of ShardType
Variables ¶
This section is empty.
Functions ¶
func GenerateSelectResultRowData ¶
GenerateSelectResultRowData generate raw RowData from values 根据value反向构造RowData copy from server.buildResultset()
func HandleDeletePlan ¶
func HandleDeletePlan(p *DeletePlan) error
HandleDeletePlan build a DeletePlan
func HandleInsertStmt ¶
func HandleInsertStmt(p *InsertPlan, stmt *ast.InsertStmt) error
HandleInsertStmt build a InsertPlan
func HandleSelectStmt ¶
func HandleSelectStmt(p *SelectPlan, stmt *ast.SelectStmt) error
HandleSelectStmt build a SelectPlan 处理SelectStmt语法树, 改写其中一些节点, 并获取路由信息和结果聚合函数
func HandleUpdatePlan ¶
func HandleUpdatePlan(p *UpdatePlan) error
HandleUpdatePlan build a UpdatePlan
func IsSelectLastInsertIDStmt ¶
IsSelectLastInsertIDStmt check if the statement is SELECT LAST_INSERT_ID()
func MergeExecResult ¶
MergeExecResult merge execution results, like UPDATE, INSERT, DELETE, ...
func MergeSelectResult ¶
func MergeSelectResult(p *SelectPlan, stmt *ast.SelectStmt, rs []*mysql.Result) (*mysql.Result, error)
MergeSelectResult merge select results
func NeedCreateBetweenExprDecorator ¶
func NeedCreateBetweenExprDecorator(p *TableAliasStmtInfo, n *ast.BetweenExpr) (router.Rule, bool, error)
NeedCreateBetweenExprDecorator check if BetweenExpr needs decoration
func NeedCreateColumnNameExprDecoratorInCondition ¶
func NeedCreateColumnNameExprDecoratorInCondition(p *TableAliasStmtInfo, n *ast.ColumnNameExpr) (router.Rule, bool, error)
NeedCreateColumnNameExprDecoratorInCondition check if ColumnNameExpr in condition needs decoration 用于JOIN ON条件或WHERE条件中判断列名是否需要装饰 与上面的区别在于, 当只存在列名, 不存在db名和表名时, 还会根据列名去查找对应的条件 (因为装饰之后需要在比较条件中计算路由)
func NeedCreateColumnNameExprDecoratorInField ¶
func NeedCreateColumnNameExprDecoratorInField(p *TableAliasStmtInfo, n *ast.ColumnNameExpr) (router.Rule, bool, error)
NeedCreateColumnNameExprDecoratorInField check if ColumnNameExpr in field needs decoration 用于Field列表中判断列名是否需要装饰 如果db名和表名都不存在, 则不需要装饰
func NeedCreatePatternInExprDecorator ¶
func NeedCreatePatternInExprDecorator(p *TableAliasStmtInfo, n *ast.PatternInExpr) (router.Rule, bool, error)
NeedCreatePatternInExprDecorator check if PatternInExpr needs decoration
func NeedCreateTableNameDecorator ¶
func NeedCreateTableNameDecorator(p *TableAliasStmtInfo, n *ast.TableName, alias string) (router.Rule, bool, error)
NeedCreateTableNameDecorator check if TableName with alias needs decorate SELECT语句可能带有表别名, 需要记录表别名
func NeedCreateTableNameDecoratorWithoutAlias ¶
func NeedCreateTableNameDecoratorWithoutAlias(p *StmtInfo, n *ast.TableName) (router.Rule, bool, error)
NeedCreateTableNameDecoratorWithoutAlias check if TableName without alias needs decorate 不带表别名时, 只用StmtInfo就可以判断
func NeedRewriteLimitOrCreateRewrite ¶
NeedRewriteLimitOrCreateRewrite check if SelectStmt need rewrite limit clause, if need, create a rewritten limit clause. count == -1代表没有Limit子句
Types ¶
type AggregateFuncCountMerger ¶
type AggregateFuncCountMerger struct {
// contains filtered or unexported fields
}
AggregateFuncCountMerger merge COUNT() column in result
func (*AggregateFuncCountMerger) MergeTo ¶
func (a *AggregateFuncCountMerger) MergeTo(from, to ResultRow) error
MergeTo implement AggregateFuncMerger
type AggregateFuncMaxMerger ¶
type AggregateFuncMaxMerger struct {
// contains filtered or unexported fields
}
AggregateFuncMaxMerger merge MAX() column in result
func (*AggregateFuncMaxMerger) MergeTo ¶
func (a *AggregateFuncMaxMerger) MergeTo(from, to ResultRow) error
MergeTo implement AggregateFuncMerger
type AggregateFuncMerger ¶
type AggregateFuncMerger interface { // MergeTo 合并结果集, from为待合并行, to为结果聚合行 MergeTo(from, to ResultRow) error }
AggregateFuncMerger is the merger of aggregate function
func CreateAggregateFunctionMerger ¶
func CreateAggregateFunctionMerger(funcType string, fieldIndex int) (AggregateFuncMerger, error)
CreateAggregateFunctionMerger create AggregateFunctionMerger by function type currently support: "count", "sum", "max", "min"
type AggregateFuncMinMerger ¶
type AggregateFuncMinMerger struct {
// contains filtered or unexported fields
}
AggregateFuncMinMerger merge MIN() column in result
func (*AggregateFuncMinMerger) MergeTo ¶
func (a *AggregateFuncMinMerger) MergeTo(from, to ResultRow) error
MergeTo implement AggregateFuncMerger
type AggregateFuncSumMerger ¶
type AggregateFuncSumMerger struct {
// contains filtered or unexported fields
}
AggregateFuncSumMerger merge SUM() column in result
func (*AggregateFuncSumMerger) MergeTo ¶
func (a *AggregateFuncSumMerger) MergeTo(from, to ResultRow) error
MergeTo implement AggregateFuncMerger
type BetweenExprDecorator ¶
type BetweenExprDecorator struct { *ast.BetweenExpr // origin // contains filtered or unexported fields }
BetweenExprDecorator decorate BetweenExpr Between只需要改写表名并计算路由, 不需要改写边界值.
func CreateBetweenExprDecorator ¶
func CreateBetweenExprDecorator(n *ast.BetweenExpr, rule router.Rule, result *RouteResult) (*BetweenExprDecorator, error)
CreateBetweenExprDecorator create BetweenExprDecorator
func (*BetweenExprDecorator) GetCurrentRouteResult ¶
func (b *BetweenExprDecorator) GetCurrentRouteResult() []int
GetCurrentRouteResult return route result
func (*BetweenExprDecorator) Restore ¶
func (b *BetweenExprDecorator) Restore(ctx *format.RestoreCtx) error
Restore column name restore is different from BetweenExpr
type BinaryOperationFieldtype ¶
type BinaryOperationFieldtype int
BinaryOperationFieldtype declares field type of binary operation
const ( UnsupportExpr BinaryOperationFieldtype = iota ValueExpr ColumnNameExpr FuncCallExpr )
Expr type
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker 用于检查SelectStmt是不是分表的Visitor, 以及是否包含DB信息
func NewChecker ¶
NewChecker db为USE db中设置的DB名. 如果没有执行USE db, 则为空字符串
func (*Checker) IsDatabaseInvalid ¶
IsDatabaseInvalid 判断执行计划中是否包含db信息, 如果不包含, 且又含有表名, 则是一个错的执行计划, 应该返回以下错误: ERROR 1046 (3D000): No database selected
type ColumnNameDecorator ¶
type ColumnNameDecorator struct {
// contains filtered or unexported fields
}
ColumnNameDecorator decorate ColumnName to rewrite table name
func (*ColumnNameDecorator) Accept ¶
Accept implement ast.Node do nothing and return current decorator
func (*ColumnNameDecorator) GetColumnInfo ¶
func (c *ColumnNameDecorator) GetColumnInfo() (string, string, string)
GetColumnInfo get column info, return db, table, column
func (*ColumnNameDecorator) Restore ¶
func (c *ColumnNameDecorator) Restore(ctx *format.RestoreCtx) error
Restore implement ast.Node
func (*ColumnNameDecorator) SetText ¶
func (c *ColumnNameDecorator) SetText(text string)
SetText implement ast.Node
func (*ColumnNameDecorator) Text ¶
func (c *ColumnNameDecorator) Text() string
Text implement ast.Node
type ColumnNameExprDecorator ¶
type ColumnNameExprDecorator struct { *ast.ColumnNameExpr Name *ColumnNameDecorator }
ColumnNameExprDecorator decorate ColumnNameExpr to rewrite table name
func CreateColumnNameExprDecorator ¶
func CreateColumnNameExprDecorator(n *ast.ColumnNameExpr, rule router.Rule, result *RouteResult) *ColumnNameExprDecorator
CreateColumnNameExprDecorator create ColumnNameExprDecorator
func (*ColumnNameExprDecorator) Restore ¶
func (cc *ColumnNameExprDecorator) Restore(ctx *format.RestoreCtx) error
Restore implement ast.Node
type ColumnNameRewriteVisitor ¶
type ColumnNameRewriteVisitor struct {
// contains filtered or unexported fields
}
ColumnNameRewriteVisitor visit ColumnNameExpr, check if need decorate, and then decorate it.
func NewColumnNameRewriteVisitor ¶
func NewColumnNameRewriteVisitor(p *TableAliasStmtInfo) *ColumnNameRewriteVisitor
NewColumnNameRewriteVisitor constructor of ColumnNameRewriteVisitor
type DeletePlan ¶
type DeletePlan struct { *TableAliasStmtInfo // contains filtered or unexported fields }
DeletePlan is the plan for delete statement
func NewDeletePlan ¶
func NewDeletePlan(stmt *ast.DeleteStmt, db, sql string, r *router.Router) *DeletePlan
NewDeletePlan constructor of DeletePlan
func (*DeletePlan) ExecuteIn ¶
func (p *DeletePlan) ExecuteIn(reqCtx *util.RequestContext, sess Executor) (*mysql.Result, error)
ExecuteIn implement Plan
type Executor ¶
type Executor interface { // 执行分片或非分片单条SQL ExecuteSQL(ctx *util.RequestContext, slice, db, sql string) (*mysql.Result, error) // 执行分片SQL ExecuteSQLs(*util.RequestContext, map[string]map[string][]string) ([]*mysql.Result, error) // 用于执行INSERT时设置last insert id SetLastInsertID(uint64) GetLastInsertID() uint64 }
Executor TODO: move to package executor
type ExplainPlan ¶
type ExplainPlan struct {
// contains filtered or unexported fields
}
ExplainPlan is the plan for explain statement
func (*ExplainPlan) ExecuteIn ¶
func (p *ExplainPlan) ExecuteIn(*util.RequestContext, Executor) (*mysql.Result, error)
ExecuteIn implement Plan
type InsertPlan ¶
type InsertPlan struct { *StmtInfo // contains filtered or unexported fields }
InsertPlan is the plan for insert statement
func NewInsertPlan ¶
func NewInsertPlan(db string, sql string, r *router.Router, seq *sequence.SequenceManager) *InsertPlan
NewInsertPlan constructor of InsertPlan
func (*InsertPlan) ExecuteIn ¶
func (s *InsertPlan) ExecuteIn(reqCtx *util.RequestContext, sess Executor) (*mysql.Result, error)
ExecuteIn implement Plan
func (*InsertPlan) GetStmt ¶
func (s *InsertPlan) GetStmt() *ast.InsertStmt
GetStmt return InsertStmt
type PatternInExprDecorator ¶
type PatternInExprDecorator struct { Expr ast.ExprNode List []ast.ExprNode Not bool // contains filtered or unexported fields }
PatternInExprDecorator decorate PatternInExpr 这里记录tableIndexes和indexValueMap是没有问题的, 因为如果是OR条件, 导致路由索引[]int变宽, 改写的SQL只是IN这一项没有值, 并不会影响SQL正确性和执行结果.
func CreatePatternInExprDecorator ¶
func CreatePatternInExprDecorator(n *ast.PatternInExpr, rule router.Rule, result *RouteResult) (*PatternInExprDecorator, error)
CreatePatternInExprDecorator create PatternInExprDecorator 必须先检查是否需要装饰
func (*PatternInExprDecorator) Format ¶
func (p *PatternInExprDecorator) Format(w io.Writer)
Format implement ast.ExprNode
func (*PatternInExprDecorator) GetCurrentRouteResult ¶
func (p *PatternInExprDecorator) GetCurrentRouteResult() []int
GetCurrentRouteResult get route result of current decorator
func (*PatternInExprDecorator) GetFlag ¶
func (p *PatternInExprDecorator) GetFlag() uint64
GetFlag implement ast.ExprNode
func (*PatternInExprDecorator) GetType ¶
func (p *PatternInExprDecorator) GetType() *types.FieldType
GetType implement ast.ExprNode
func (*PatternInExprDecorator) Restore ¶
func (p *PatternInExprDecorator) Restore(ctx *format.RestoreCtx) error
Restore implement ast.Node
func (*PatternInExprDecorator) SetFlag ¶
func (p *PatternInExprDecorator) SetFlag(flag uint64)
SetFlag implement ast.ExprNode
func (*PatternInExprDecorator) SetText ¶
func (p *PatternInExprDecorator) SetText(text string)
SetText implement ast.Node
func (*PatternInExprDecorator) SetType ¶
func (p *PatternInExprDecorator) SetType(tp *types.FieldType)
SetType implement ast.ExprNode
func (*PatternInExprDecorator) Text ¶
func (p *PatternInExprDecorator) Text() string
Text implement ast.Node
type Plan ¶
type Plan interface { ExecuteIn(*util.RequestContext, Executor) (*mysql.Result, error) // only for cache Size() int }
Plan is a interface for select/insert etc.
type ResultRow ¶
type ResultRow []interface{}
ResultRow is one Row in Result
type RouteResult ¶
type RouteResult struct {
// contains filtered or unexported fields
}
RouteResult is the route result of a statement 遍历AST之后得到的路由结果 db, table唯一确定了一个路由, 这里只记录分片表的db和table, 如果是关联表, 必须关联到同一个父表
func NewRouteResult ¶
func NewRouteResult(db, table string, initIndexes []int) *RouteResult
NewRouteResult constructor of RouteResult
func (*RouteResult) Check ¶
func (r *RouteResult) Check(db, table string) error
Check check if the db and table is valid
func (*RouteResult) GetCurrentTableIndex ¶
func (r *RouteResult) GetCurrentTableIndex() (int, error)
GetCurrentTableIndex get current table index
func (*RouteResult) GetShardIndexes ¶
func (r *RouteResult) GetShardIndexes() []int
GetShardIndexes get shard indexes
func (*RouteResult) Inter ¶
func (r *RouteResult) Inter(indexes []int)
Inter inter indexes with origin indexes in RouteResult 如果是关联表, db, table需要用父表的db和table
func (*RouteResult) Union ¶
func (r *RouteResult) Union(indexes []int)
Union union indexes with origin indexes in RouteResult 如果是关联表, db, table需要用父表的db和table
type SelectLastInsertIDPlan ¶
type SelectLastInsertIDPlan struct {
// contains filtered or unexported fields
}
SelectLastInsertIDPlan is the plan for SELECT LAST_INSERT_ID() TODO: fix below https://dev.mysql.com/doc/refman/5.6/en/information-functions.html#function_last-insert-id The value of LAST_INSERT_ID() is not changed if you set the AUTO_INCREMENT column of a row to a non-“magic” value (that is, a value that is not NULL and not 0).
func CreateSelectLastInsertIDPlan ¶
func CreateSelectLastInsertIDPlan() *SelectLastInsertIDPlan
CreateSelectLastInsertIDPlan constructor of SelectLastInsertIDPlan
func (*SelectLastInsertIDPlan) ExecuteIn ¶
func (p *SelectLastInsertIDPlan) ExecuteIn(reqCtx *util.RequestContext, se Executor) (*mysql.Result, error)
ExecuteIn implement Plan
type SelectPlan ¶
type SelectPlan struct { *TableAliasStmtInfo // contains filtered or unexported fields }
SelectPlan is the plan for select statement
func NewSelectPlan ¶
func NewSelectPlan(db string, sql string, r *router.Router) *SelectPlan
NewSelectPlan constructor of SelectPlan db is the session db
func (*SelectPlan) ExecuteIn ¶
func (s *SelectPlan) ExecuteIn(reqCtx *util.RequestContext, sess Executor) (*mysql.Result, error)
ExecuteIn implement Plan
func (*SelectPlan) GetColumnCount ¶
func (s *SelectPlan) GetColumnCount() int
GetColumnCount get column count with extra columns
func (*SelectPlan) GetGroupByColumnInfo ¶
func (s *SelectPlan) GetGroupByColumnInfo() (int, int)
GetGroupByColumnInfo get extra column offset and length for group by
func (*SelectPlan) GetLimitValue ¶
func (s *SelectPlan) GetLimitValue() (int64, int64)
GetLimitValue get offset, count in limit clause
func (*SelectPlan) GetOrderByColumnInfo ¶
func (s *SelectPlan) GetOrderByColumnInfo() (int, []bool)
GetOrderByColumnInfo get extra column offset and length for order by
func (*SelectPlan) GetOriginColumnCount ¶
func (s *SelectPlan) GetOriginColumnCount() int
GetOriginColumnCount get origin column count in statement, since group by and order by may add extra columns to FieldList.
func (*SelectPlan) GetSQLs ¶
func (s *SelectPlan) GetSQLs() map[string]map[string][]string
GetSQLs get generated SQLs the first key is slice, the second key is backend database name, the value is sql list.
func (*SelectPlan) HasGroupBy ¶
func (s *SelectPlan) HasGroupBy() bool
HasGroupBy if the select statement has group by clause, return true
func (*SelectPlan) HasLimit ¶
func (s *SelectPlan) HasLimit() bool
HasLimit if the select statement has limit clause, return true
func (*SelectPlan) HasOrderBy ¶
func (s *SelectPlan) HasOrderBy() bool
HasOrderBy if select statement has order by clause, return true
type StmtInfo ¶
type StmtInfo struct {
// contains filtered or unexported fields
}
StmtInfo 各种Plan的一些公共属性
func NewStmtInfo ¶
NewStmtInfo constructor of StmtInfo
func (*StmtInfo) GetRouteResult ¶
func (s *StmtInfo) GetRouteResult() *RouteResult
GetRouteResult get route result
type SubqueryColumnNameRewriteVisitor ¶
type SubqueryColumnNameRewriteVisitor struct {
// contains filtered or unexported fields
}
SubqueryColumnNameRewriteVisitor visit ColumnNameExpr in subquery, check if need decorate, and then decorate it.
func NewSubqueryColumnNameRewriteVisitor ¶
func NewSubqueryColumnNameRewriteVisitor(p *TableAliasStmtInfo) *SubqueryColumnNameRewriteVisitor
NewSubqueryColumnNameRewriteVisitor consturctor of SubqueryColumnNameRewriteVisitor
type TableAliasStmtInfo ¶
type TableAliasStmtInfo struct { *StmtInfo // contains filtered or unexported fields }
TableAliasStmtInfo 使用到表别名, 且依赖表别名做路由计算的StmtNode, 目前包括UPDATE, SELECT INSERT也可以使用表别名, 但是由于只存在一个表, 可以直接去掉, 因此不需要.
func NewTableAliasStmtInfo ¶
func NewTableAliasStmtInfo(db string, sql string, r *router.Router) *TableAliasStmtInfo
NewTableAliasStmtInfo means table alias StmtInfo
func (*TableAliasStmtInfo) GetSettedRuleFromColumnInfo ¶
func (t *TableAliasStmtInfo) GetSettedRuleFromColumnInfo(db, table, column string) (router.Rule, bool, error)
GetSettedRuleFromColumnInfo 用于WHERE条件或JOIN ON条件中, 查找列名对应的路由规则
func (*TableAliasStmtInfo) RecordShardTable ¶
func (t *TableAliasStmtInfo) RecordShardTable(db, table, alias string) (router.Rule, error)
RecordShardTable 将表信息记录到StmtInfo中, 并返回表信息对应的路由规则
func (*TableAliasStmtInfo) RecordSubqueryTableAlias ¶
func (t *TableAliasStmtInfo) RecordSubqueryTableAlias(alias string) (router.Rule, error)
RecordSubqueryTableAlias 记录表名位置的子查询的别名, 便于后续处理 返回已存在Rule的第一个 (任意一个即可) 限制: 子查询中的表对应的路由规则必须与外层查询相关联, 或者为全局表
type TableNameDecorator ¶
type TableNameDecorator struct {
// contains filtered or unexported fields
}
TableNameDecorator decorate TableName
func CreateTableNameDecorator ¶
func CreateTableNameDecorator(n *ast.TableName, rule router.Rule, result *RouteResult) (*TableNameDecorator, error)
CreateTableNameDecorator create TableNameDecorator the table has been checked before
func (*TableNameDecorator) Accept ¶
Accept implement ast.Node do nothing and return current decorator
func (*TableNameDecorator) Restore ¶
func (t *TableNameDecorator) Restore(ctx *format.RestoreCtx) error
Restore implement ast.Node
func (*TableNameDecorator) SetText ¶
func (t *TableNameDecorator) SetText(text string)
SetText implement ast.Node
func (*TableNameDecorator) Text ¶
func (t *TableNameDecorator) Text() string
Text implement ast.Node
type UnshardPlan ¶
type UnshardPlan struct {
// contains filtered or unexported fields
}
UnshardPlan is the plan for unshard statement
func CreateUnshardPlan ¶
func CreateUnshardPlan(stmt ast.StmtNode, db, sql string) *UnshardPlan
CreateUnshardPlan constructor of UnshardPlan
func (*UnshardPlan) ExecuteIn ¶
func (p *UnshardPlan) ExecuteIn(reqCtx *util.RequestContext, se Executor) (*mysql.Result, error)
ExecuteIn implement Plan
type UpdatePlan ¶
type UpdatePlan struct { *TableAliasStmtInfo // contains filtered or unexported fields }
UpdatePlan is the plan for update statement
func NewUpdatePlan ¶
func NewUpdatePlan(stmt *ast.UpdateStmt, db, sql string, r *router.Router) *UpdatePlan
NewUpdatePlan constructor of UpdatePlan
func (*UpdatePlan) ExecuteIn ¶
func (s *UpdatePlan) ExecuteIn(reqCtx *util.RequestContext, sess Executor) (*mysql.Result, error)
ExecuteIn implement Plan
Source Files ¶
- decorator_between_expr.go
- decorator_binary_operation_expr.go
- decorator_column_name.go
- decorator_limit.go
- decorator_pattern_in_expr.go
- decorator_table_name.go
- merge_result.go
- plan.go
- plan_delete.go
- plan_explain.go
- plan_insert.go
- plan_select.go
- plan_select_subquery.go
- plan_unshard.go
- plan_update.go
- route_result.go
- util.go