MCPcopy Create free account
hub / github.com/bytebase/bytebase / scanIdentifier

Method scanIdentifier

backend/plugin/parser/tokenizer/tokenizer.go:483–500  ·  view source on GitHub ↗

Assume that identifier only contains letters, underscores, digits (0-9), or dollar signs ($). See https://www.postgresql.org/docs/current/sql-syntax-lexical.html.

(delimiter rune)

Source from the content-addressed store, hash-verified

481// Assume that identifier only contains letters, underscores, digits (0-9), or dollar signs ($).
482// See https://www.postgresql.org/docs/current/sql-syntax-lexical.html.
483func (t *Tokenizer) scanIdentifier(delimiter rune) error {
484 if t.char(0) != delimiter {
485 return errors.Errorf("delimiter doesn't start with delimiter: %c, but found: %c", delimiter, t.char(0))
486 }
487
488 t.skip(1)
489 for {
490 switch t.char(0) {
491 case delimiter:
492 t.skip(1)
493 return nil
494 case eofRune:
495 return errors.Errorf("invalid indentifier: not found delimiter: %c, but found EOF", delimiter)
496 default:
497 t.skip(1)
498 }
499 }
500}
501
502// There are two ways to include a single quote('), using \' or two single-quotes.
503// We only handle the case \', because the second case does not require special handling.

Calls 3

charMethod · 0.95
skipMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected