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

Function HasMultipleStatements

pkg/sql/scanner/scan.go:1104–1122  ·  view source on GitHub ↗

HasMultipleStatements returns true if the sql string contains more than one statements. An error is returned if an invalid token was encountered.

(sql string)

Source from the content-addressed store, hash-verified

1102// HasMultipleStatements returns true if the sql string contains more than one
1103// statements. An error is returned if an invalid token was encountered.
1104func HasMultipleStatements(sql string) (multipleStmt bool, err error) {
1105 var s SQLScanner
1106 var lval fakeSym
1107 s.Init(sql)
1108 count := 0
1109 for {
1110 done, hasToks, err := s.scanOne(&lval)
1111 if err != nil {
1112 return false, err
1113 }
1114 if hasToks {
1115 count++
1116 }
1117 if done || count > 1 {
1118 break
1119 }
1120 }
1121 return count > 1, nil
1122}
1123
1124// scanOne is a simplified version of (*Parser).scanOneStmt() for use
1125// by HasMultipleStatements().

Callers

nothing calls this directly

Calls 2

scanOneMethod · 0.95
InitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…