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

Function doParseDArrayFromString

pkg/sql/sem/tree/parse_array.go:215–258  ·  view source on GitHub ↗

doParseDArrayFromString 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 ParseContext (either for the time or the local timezone).

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

Source from the content-addressed store, hash-verified

213// The dependsOnContext return value indicates if we had to consult the
214// ParseContext (either for the time or the local timezone).
215func doParseDArrayFromString(
216 ctx ParseContext, s string, t *types.T,
217) (_ *DArray, dependsOnContext bool, _ error) {
218 parser := parseState{
219 s: s,
220 ctx: ctx,
221 result: NewDArray(t),
222 t: t,
223 }
224
225 parser.eatWhitespace()
226 if parser.peek() != '{' {
227 return nil, false, enclosingError
228 }
229 parser.advance()
230 parser.eatWhitespace()
231 if parser.peek() != '}' {
232 if err := parser.parseElement(); err != nil {
233 return nil, false, err
234 }
235 parser.eatWhitespace()
236 for string(parser.peek()) == t.Delimiter() {
237 parser.advance()
238 parser.eatWhitespace()
239 if err := parser.parseElement(); err != nil {
240 return nil, false, err
241 }
242 }
243 }
244 parser.eatWhitespace()
245 if parser.eof() {
246 return nil, false, enclosingError
247 }
248 if parser.peek() != '}' {
249 return nil, false, malformedError
250 }
251 parser.advance()
252 parser.eatWhitespace()
253 if !parser.eof() {
254 return nil, false, extraTextError
255 }
256
257 return parser.result, parser.dependsOnContext, nil
258}

Callers 1

ParseDArrayFromStringFunction · 0.85

Calls 7

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…