Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewNumValFn = func(constant.Value, string, bool) interface{} {
return struct{}{}
}
NewNumValFn allows us to use tree.NewNumVal without a dependency on tree.
var NewPlaceholderFn = func(string) (interface{}, error) { return struct{}{}, nil }
NewPlaceholderFn allows us to use tree.NewPlaceholder without a dependency on tree.
Functions ¶
func FirstLexicalToken ¶
FirstLexicalToken returns the first lexical token. Returns 0 if there is no token.
func HasMultipleStatements ¶
HasMultipleStatements returns true if the sql string contains more than one statements. An error is returned if an invalid token was encountered.
func LastLexicalToken ¶
LastLexicalToken returns the last lexical token. If the string has no lexical tokens, returns 0 and ok=false.
Types ¶
type InspectToken ¶
InspectToken is the type of token that can be scanned by Inspect.
func Inspect ¶
func Inspect(sql string) []InspectToken
Inspect analyses the string and returns the tokens found in it. If an incomplete token was encountered at the end, an InspectToken entry with ID -1 is appended.
If a syntax error was encountered, it is returned as a token with type ERROR.
See TestInspect and the examples in testdata/inspect for more details.
type SQLScanner ¶
type SQLScanner struct {
Scanner
}
SQLScanner is a scanner with a SQL specific scan function
func (*SQLScanner) Scan ¶
func (s *SQLScanner) Scan(lval ScanSymType)
Scan scans the next token and populates its information into lval.
type ScanSymType ¶
type ScanSymType interface { ID() int32 SetID(int32) Pos() int32 SetPos(int32) Str() string SetStr(string) UnionVal() interface{} SetUnionVal(interface{}) }
ScanSymType is the interface for accessing the fields of a yacc symType.
type Scanner ¶
type Scanner struct { // Comments is the list of parsed comments from the SQL statement. Comments []string // contains filtered or unexported fields }
Scanner lexes SQL statements.
func (*Scanner) Cleanup ¶
func (s *Scanner) Cleanup()
Cleanup is used to avoid holding on to memory unnecessarily (for the cases where we reuse a Scanner).
func (*Scanner) ScanComment ¶
func (s *Scanner) ScanComment(lval ScanSymType) (present, ok bool)
ScanComment scans the input as a comment.