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

Method ParseReturnQuery

pkg/sql/plpgsql/parser/lexer.go:393–408  ·  view source on GitHub ↗

ParseReturnQuery handles reading and parsing the query for a RETURN QUERY statement, which can be nonexistent.

()

Source from the content-addressed store, hash-verified

391// ParseReturnQuery handles reading and parsing the query for a RETURN QUERY
392// statement, which can be nonexistent.
393func (l *lexer) ParseReturnQuery() (plpgsqltree.Statement, error) {
394 startPos, endPos, _, err := l.readSQLConstruct(false /* isExpr */, false /* allowEmpty */, ';')
395 if err != nil || startPos == endPos {
396 return nil, err
397 }
398 queryStr := l.getStr(startPos, endPos)
399 stmt, err := parser.ParseOne(queryStr)
400 if err != nil {
401 return nil, err
402 }
403 ann := tree.MakeAnnotations(stmt.NumAnnotations)
404 return &plpgsqltree.ReturnQuery{
405 SqlStmt: stmt.AST,
406 Annotations: &ann,
407 }, nil
408}
409
410// peekForExecute checks whether the next token is EXECUTE, used to identify
411// dynamic SQL statements.

Callers 1

ParseMethod · 0.80

Calls 4

readSQLConstructMethod · 0.95
getStrMethod · 0.95
ParseOneFunction · 0.92
MakeAnnotationsFunction · 0.92

Tested by

no test coverage detected