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

Method readTarget

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

readTarget reads a comma-separated list of target variables from the given start position to the given end position. It returns the target list and its end position.

(
	pos, endPos int,
)

Source from the content-addressed store, hash-verified

649// start position to the given end position. It returns the target list and its
650// end position.
651func (l *lexer) readTarget(
652 pos, endPos int,
653) (target []plpgsqltree.Variable, targetEnd int, err error) {
654 for ; pos < endPos; pos += 2 {
655 tok := l.tokens[pos]
656 if tok.id != IDENT {
657 return nil, 0, errors.Newf("\"%s\" is not a scalar variable", tok.str)
658 }
659 variable := plpgsqltree.Variable(strings.TrimSpace(l.getStr(pos, pos+1)))
660 target = append(target, variable)
661 if pos+1 == endPos || l.tokens[pos+1].id != ',' {
662 // This is the end of the target list.
663 break
664 }
665 }
666 return target, pos + 1, nil
667}
668
669func checkLoopLabels(start, end string) error {
670 if start == "" && end != "" {

Callers 3

MakeExecSqlStmtMethod · 0.95
MakeFetchOrMoveStmtMethod · 0.95
ReadTargetMethod · 0.95

Calls 2

getStrMethod · 0.95
VariableMethod · 0.65

Tested by

no test coverage detected