MCPcopy Create free account
hub / github.com/dolthub/doltgresql / parse

Method parse

postgres/parser/parser/parse.go:203–237  ·  view source on GitHub ↗

parse parses a statement from the given scanned tokens.

(
	depth int, sql string, tokens []sqlSymType, nakedIntType *types.T,
)

Source from the content-addressed store, hash-verified

201
202// parse parses a statement from the given scanned tokens.
203func (p *Parser) parse(
204 depth int, sql string, tokens []sqlSymType, nakedIntType *types.T,
205) (Statement, error) {
206 p.lexer.init(sql, tokens, nakedIntType)
207 defer p.lexer.cleanup()
208 if p.parserImpl.Parse(&p.lexer) != 0 {
209 if p.lexer.lastError == nil {
210 // This should never happen -- there should be an error object
211 // every time Parse() returns nonzero. We're just playing safe
212 // here.
213 p.lexer.Error("syntax error")
214 }
215 err := p.lexer.lastError
216
217 // Compatibility with 19.1 telemetry: prefix the telemetry keys
218 // with the "syntax." prefix.
219 // TODO(knz): move the auto-prefixing of feature names to a
220 // higher level in the call stack.
221 tkeys := errors.GetTelemetryKeys(err)
222 if len(tkeys) > 0 {
223 for i := range tkeys {
224 tkeys[i] = "syntax." + tkeys[i]
225 }
226 err = errors.WithTelemetry(err, tkeys...)
227 }
228
229 return Statement{}, err
230 }
231 return Statement{
232 AST: p.lexer.stmt,
233 SQL: sql,
234 NumPlaceholders: p.lexer.numPlaceholders,
235 NumAnnotations: p.lexer.numAnnotations,
236 }, nil
237}
238
239// unaryNegation constructs an AST node for a negation. This attempts
240// to preserve constant NumVals and embed the negative sign inside

Callers 3

parseWithDepthMethod · 0.95
mainFunction · 0.80
assertEqualRowsFunction · 0.80

Calls 4

initMethod · 0.45
cleanupMethod · 0.45
ParseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected