hint

package
v3.1.0-fork Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindHint

func BindHint(stmt ast.StmtNode, hintsSet *HintsSet) ast.StmtNode

BindHint will add hints for stmt according to the hints in `hintsSet`.

func ExtractTableHintsFromStmtNode

func ExtractTableHintsFromStmtNode(node ast.Node) []*ast.TableOptimizerHint

ExtractTableHintsFromStmtNode extracts table hints from this node.

func GenerateQBName

func GenerateQBName(nodeType NodeType, blockOffset int) model.CIStr

GenerateQBName builds QBName from offset.

func RestoreIndexHint

func RestoreIndexHint(hint *ast.IndexHint) (string, error)

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.
	Ctx       sessionctx.Context
	// contains filtered or unexported fields
}

BlockHintProcessor processes hints at different level of sql statement.

func (*BlockHintProcessor) Enter

func (p *BlockHintProcessor) Enter(in ast.Node) (ast.Node, bool)

Enter implements Visitor interface.

func (*BlockHintProcessor) GetCurrentStmtHints

func (p *BlockHintProcessor) GetCurrentStmtHints(hints []*ast.TableOptimizerHint, nodeType NodeType, currentOffset int) []*ast.TableOptimizerHint

GetCurrentStmtHints extracts all hints that take effects at current stmt.

func (*BlockHintProcessor) GetHintOffset

func (p *BlockHintProcessor) GetHintOffset(qbName model.CIStr, nodeType NodeType, currentOffset int) int

GetHintOffset gets the offset of stmt that the hints take effects.

func (*BlockHintProcessor) Leave

func (p *BlockHintProcessor) Leave(in ast.Node) (ast.Node, bool)

Leave implements Visitor interface.

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

func CollectHint(in ast.StmtNode) *HintsSet

CollectHint collects hints for a statement.

func ParseHintsSet

func ParseHintsSet(p *parser.Parser, sql, charset, collation, db string) (*HintsSet, []error, error)

ParseHintsSet parses a SQL string, then collects and normalizes the HintsSet.

func (*HintsSet) ContainTableHint

func (hs *HintsSet) ContainTableHint(hint string) bool

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.

func (*HintsSet) Restore

func (hs *HintsSet) Restore() (string, error)

Restore returns the string format of HintsSet.

type NodeType

type NodeType int

NodeType indicates if the node is for SELECT / UPDATE / DELETE.

const (
	// TypeUpdate for Update.
	TypeUpdate NodeType = iota
	// TypeDelete for DELETE.
	TypeDelete
	// TypeSelect for SELECT.
	TypeSelect
)

Jump to

Keyboard shortcuts

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