MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / scanBitString

Method scanBitString

pkg/sql/parser/scan.go:752–785  ·  view source on GitHub ↗

scanBitString scans the content inside B'....'.

(lval *sqlSymType, ch int)

Source from the content-addressed store, hash-verified

750
751// scanBitString scans the content inside B'....'.
752func (s *scanner) scanBitString(lval *sqlSymType, ch int) bool {
753 buf := s.buffer()
754outer:
755 for {
756 b := s.next()
757 switch b {
758 case ch:
759 newline, ok := s.skipWhitespace(lval, false)
760 if !ok {
761 return false
762 }
763 // SQL allows joining adjacent strings separated by whitespace
764 // as long as that whitespace contains at least one
765 // newline. Kind of strange to require the newline, but that
766 // is the standard.
767 if s.peek() == ch && newline {
768 s.pos++
769 continue
770 }
771 break outer
772
773 case '0', '1':
774 buf = append(buf, byte(b))
775 default:
776 lval.id = ERROR
777 lval.str = fmt.Sprintf(`"%c" is not a valid binary digit`, rune(b))
778 return false
779 }
780 }
781
782 lval.id = BITCONST
783 lval.str = s.finishString(buf)
784 return true
785}
786
787// scanString scans the content inside '...'. This is used for simple
788// string literals '...' but also e'....' and b'...'. For x'...', see

Callers 1

scanMethod · 0.95

Calls 5

bufferMethod · 0.95
nextMethod · 0.95
skipWhitespaceMethod · 0.95
peekMethod · 0.95
finishStringMethod · 0.95

Tested by

no test coverage detected