MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / SplitFirstStatement

Function SplitFirstStatement

pkg/sql/parser/scanner.go:23–35  ·  view source on GitHub ↗

SplitFirstStatement returns the length of the prefix of the string up to and including the first semicolon that separates statements. If there is no including the first semicolon that separates statements. If there is no semicolon, returns ok=false.

(sql string)

Source from the content-addressed store, hash-verified

21// including the first semicolon that separates statements. If there is no
22// semicolon, returns ok=false.
23func SplitFirstStatement(sql string) (pos int, ok bool) {
24 s := makeSQLScanner(sql)
25 var lval = &sqlSymType{}
26 for {
27 s.Scan(lval)
28 switch lval.ID() {
29 case 0, lexbase.ERROR:
30 return 0, false
31 case ';':
32 return s.Pos(), true
33 }
34 }
35}
36
37// Tokens decomposes the input into lexical tokens.
38func Tokens(sql string) (tokens []TokenString, ok bool) {

Callers

nothing calls this directly

Calls 4

makeSQLScannerFunction · 0.85
IDMethod · 0.65
PosMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…