MCPcopy Create free account
hub / github.com/dolthub/doltgresql / doParseDArrayFromString

Function doParseDArrayFromString

postgres/parser/sem/tree/parse_array.go:185–228  ·  view source on GitHub ↗

doParseDArraryFromString does most of the work of ParseDArrayFromString, except the error it returns isn't prettified as a parsing error. The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

(
	ctx ParseTimeContext, s string, t *types.T,
)

Source from the content-addressed store, hash-verified

183// The dependsOnContext return value indicates if we had to consult the
184// ParseTimeContext (either for the time or the local timezone).
185func doParseDArrayFromString(
186 ctx ParseTimeContext, s string, t *types.T,
187) (_ *DArray, dependsOnContext bool, _ error) {
188 parser := parseState{
189 s: s,
190 ctx: ctx,
191 result: NewDArray(t),
192 t: t,
193 }
194
195 parser.eatWhitespace()
196 if parser.peek() != '{' {
197 return nil, false, enclosingError
198 }
199 parser.advance()
200 parser.eatWhitespace()
201 if parser.peek() != '}' {
202 if err := parser.parseElement(); err != nil {
203 return nil, false, err
204 }
205 parser.eatWhitespace()
206 for parser.peek() == ',' {
207 parser.advance()
208 parser.eatWhitespace()
209 if err := parser.parseElement(); err != nil {
210 return nil, false, err
211 }
212 }
213 }
214 parser.eatWhitespace()
215 if parser.eof() {
216 return nil, false, enclosingError
217 }
218 if parser.peek() != '}' {
219 return nil, false, malformedError
220 }
221 parser.advance()
222 parser.eatWhitespace()
223 if !parser.eof() {
224 return nil, false, extraTextError
225 }
226
227 return parser.result, parser.dependsOnContext, nil
228}

Callers 1

ParseDArrayFromStringFunction · 0.85

Calls 6

eatWhitespaceMethod · 0.95
peekMethod · 0.95
advanceMethod · 0.95
parseElementMethod · 0.95
eofMethod · 0.95
NewDArrayFunction · 0.85

Tested by

no test coverage detected