Documentation ¶
Index ¶
- func BindHint(stmt ast.StmtNode, hintsSet *HintsSet) ast.StmtNode
- func CheckBindingFromHistoryBindable(node ast.Node, hintStr string) error
- func ExtractTableHintsFromStmtNode(node ast.Node, sctx sessionctx.Context) []*ast.TableOptimizerHint
- func GenerateQBName(nodeType NodeType, blockOffset int) (model.CIStr, error)
- func RestoreIndexHint(hint *ast.IndexHint) (string, error)
- func RestoreOptimizerHints(hints []*ast.TableOptimizerHint) string
- func RestoreTableOptimizerHint(hint *ast.TableOptimizerHint) string
- type BlockHintProcessor
- func (p *BlockHintProcessor) Enter(in ast.Node) (ast.Node, bool)
- func (p *BlockHintProcessor) GetCurrentStmtHints(hints []*ast.TableOptimizerHint, currentOffset int) []*ast.TableOptimizerHint
- func (p *BlockHintProcessor) GetHintOffset(qbName model.CIStr, currentOffset int) int
- func (p *BlockHintProcessor) HandleUnusedViewHints()
- func (*BlockHintProcessor) Leave(in ast.Node) (ast.Node, bool)
- func (p *BlockHintProcessor) MaxSelectStmtOffset() int
- type HintsSet
- type NodeType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckBindingFromHistoryBindable ¶
CheckBindingFromHistoryBindable checks whether the ast and hint string from history is bindable. Not support: 1. query use tiFlash engine 2. query with sub query 3. query with more than 2 table join
func ExtractTableHintsFromStmtNode ¶
func ExtractTableHintsFromStmtNode(node ast.Node, sctx sessionctx.Context) []*ast.TableOptimizerHint
ExtractTableHintsFromStmtNode extracts table hints from this node.
func GenerateQBName ¶
GenerateQBName builds QBName from offset.
func RestoreIndexHint ¶
RestoreIndexHint returns string format of IndexHint.
func RestoreOptimizerHints ¶
func RestoreOptimizerHints(hints []*ast.TableOptimizerHint) string
RestoreOptimizerHints restores these hints.
func RestoreTableOptimizerHint ¶
func RestoreTableOptimizerHint(hint *ast.TableOptimizerHint) string
RestoreTableOptimizerHint returns string format of TableOptimizerHint.
Types ¶
type BlockHintProcessor ¶
type BlockHintProcessor struct { QbNameMap map[string]int // Map from query block name to select stmt offset. QbHints map[int][]*ast.TableOptimizerHint // Group all hints at same query block. // Used for the view's hint QbNameMap4View map[string][]ast.HintTable // Map from view's query block name to view's table list. QbHints4View map[string][]*ast.TableOptimizerHint // Group all hints at same query block for view hints. QbNameUsed4View map[string]struct{} // Store all the qb_name hints which are used for view Ctx sessionctx.Context // contains filtered or unexported fields }
BlockHintProcessor processes hints at different level of sql statement.
func (*BlockHintProcessor) GetCurrentStmtHints ¶
func (p *BlockHintProcessor) GetCurrentStmtHints(hints []*ast.TableOptimizerHint, currentOffset int) []*ast.TableOptimizerHint
GetCurrentStmtHints extracts all hints that take effects at current stmt.
func (*BlockHintProcessor) GetHintOffset ¶
func (p *BlockHintProcessor) GetHintOffset(qbName model.CIStr, currentOffset int) int
GetHintOffset gets the offset of stmt that the hints take effects.
func (*BlockHintProcessor) HandleUnusedViewHints ¶
func (p *BlockHintProcessor) HandleUnusedViewHints()
HandleUnusedViewHints handle the unused view hints.
func (*BlockHintProcessor) MaxSelectStmtOffset ¶
func (p *BlockHintProcessor) MaxSelectStmtOffset() int
MaxSelectStmtOffset returns the current stmt offset.
type HintsSet ¶
type HintsSet struct {
// contains filtered or unexported fields
}
HintsSet contains all hints of a query.
func CollectHint ¶
CollectHint collects hints for a statement.
func ParseHintsSet ¶
func ParseHintsSet(p *parser.Parser, sql, charset, collation, db string) (*HintsSet, ast.StmtNode, []error, error)
ParseHintsSet parses a SQL string, then collects and normalizes the HintsSet.
func (*HintsSet) ContainTableHint ¶
ContainTableHint checks whether the table hint set contains a hint.
func (*HintsSet) GetFirstTableHints ¶
func (hs *HintsSet) GetFirstTableHints() []*ast.TableOptimizerHint
GetFirstTableHints gets the first table hints.