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

Method consumeUnit

pkg/sql/sem/tree/interval.go:125–145  ·  view source on GitHub ↗

Consumes the next unit.

(skipCharacter byte)

Source from the content-addressed store, hash-verified

123
124// Consumes the next unit.
125func (l *intervalLexer) consumeUnit(skipCharacter byte) string {
126 if l.err != nil {
127 return ""
128 }
129
130 offset := l.offset
131 for ; l.offset < len(l.str); l.offset++ {
132 if (l.str[l.offset] >= '0' && l.str[l.offset] <= '9') ||
133 l.str[l.offset] == skipCharacter ||
134 l.str[l.offset] == '-' {
135 break
136 }
137 }
138
139 if offset == l.offset {
140 l.err = pgerror.Newf(
141 pgcode.InvalidDatetimeFormat, "interval: missing unit at position %d: %q", offset, l.str)
142 return ""
143 }
144 return l.str[offset:l.offset]
145}
146
147// Consumes any number of spaces.
148func (l *intervalLexer) consumeSpaces() {

Callers 2

iso8601ToDurationFunction · 0.95
parseDurationFunction · 0.95

Calls 1

NewfFunction · 0.92

Tested by

no test coverage detected