MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / scanOneStmt

Method scanOneStmt

pkg/sql/parser/parse.go:119–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117}
118
119func (p *Parser) scanOneStmt() (sql string, tokens []sqlSymType, done bool) {
120 var lval sqlSymType
121 tokens = p.tokBuf[:0]
122
123 // Scan the first token.
124 for {
125 p.scanner.scan(&lval)
126 if lval.id == 0 {
127 return "", nil, true
128 }
129 if lval.id != ';' {
130 break
131 }
132 }
133
134 startPos := lval.pos
135 // We make the resulting token positions match the returned string.
136 lval.pos = 0
137 tokens = append(tokens, lval)
138 for {
139 if lval.id == ERROR {
140 return p.scanner.in[startPos:], tokens, true
141 }
142 posBeforeScan := p.scanner.pos
143 p.scanner.scan(&lval)
144 if lval.id == 0 || lval.id == ';' {
145 return p.scanner.in[startPos:posBeforeScan], tokens, (lval.id == 0)
146 }
147 lval.pos -= startPos
148 tokens = append(tokens, lval)
149 }
150}
151
152func (p *Parser) parseWithDepth(depth int, sql string, nakedIntType *types.T) (Statements, error) {
153 stmts := Statements(p.stmtBuf[:0])

Callers 2

parseWithDepthMethod · 0.95
TestScanOneStmtFunction · 0.95

Calls 1

scanMethod · 0.80

Tested by 1

TestScanOneStmtFunction · 0.76