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

Method parseElement

pkg/sql/sem/tree/parse_array.go:157–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

155}
156
157func (p *parseState) parseElement() error {
158 var next string
159 var err error
160 r := p.peek()
161 switch r {
162 case '{':
163 return nestedArraysNotSupportedError
164 case '"':
165 p.advance()
166 next, err = p.parseQuotedString()
167 if err != nil {
168 return err
169 }
170 p.advance()
171 default:
172 if !p.isElementChar(r) {
173 return malformedError
174 }
175 next, err = p.parseUnquotedString()
176 if err != nil {
177 return err
178 }
179 if strings.EqualFold(next, "null") {
180 return p.result.Append(DNull)
181 }
182 }
183
184 d, dependsOnContext, err := ParseAndRequireString(p.t, next, p.ctx)
185 if err != nil {
186 return err
187 }
188 if dependsOnContext {
189 p.dependsOnContext = true
190 }
191 return p.result.Append(d)
192}
193
194// ParseDArrayFromString parses the string-form of constructing arrays, handling
195// cases such as `'{1,2,3}'::INT[]`. The input type t is the type of the

Callers 1

doParseDArrayFromStringFunction · 0.95

Calls 7

peekMethod · 0.95
advanceMethod · 0.95
parseQuotedStringMethod · 0.95
isElementCharMethod · 0.95
parseUnquotedStringMethod · 0.95
ParseAndRequireStringFunction · 0.85
AppendMethod · 0.45

Tested by

no test coverage detected