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

Method scanFnBlock

pkg/sql/plpgsql/parser/parse.go:52–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52func (p *Parser) scanFnBlock() (sql string, tokens []plpgsqlSymType, done bool) {
53 var lval plpgsqlSymType
54 tokens = p.tokBuf[:0]
55
56 // Scan the first token.
57 p.scanner.Scan(&lval)
58 if lval.id == 0 {
59 return "", nil, true
60 }
61
62 startPos := lval.pos
63 // We make the resulting token positions match the returned string.
64 lval.pos = 0
65 tokens = append(tokens, lval)
66 for {
67 if lval.id == ERROR {
68 return p.scanner.In()[startPos:], tokens, true
69 }
70 // Reset the plpgsqlSymType struct before scanning.
71 lval = plpgsqlSymType{}
72 posBeforeScan := p.scanner.Pos()
73 p.scanner.Scan(&lval)
74 if lval.id == 0 {
75 return p.scanner.In()[startPos:posBeforeScan], tokens, (lval.id == 0)
76 }
77 lval.pos -= startPos
78 tokens = append(tokens, lval)
79 }
80}
81
82func (p *Parser) parseWithDepth(
83 depth int, plpgsql string, nakedIntType *types.T,

Callers 1

parseWithDepthMethod · 0.95

Calls 3

InMethod · 0.80
PosMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected