MCPcopy Create free account
hub / github.com/apache/cloudberry / get_array_start

Function get_array_start

src/backend/utils/adt/jsonfuncs.c:1243–1279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1241}
1242
1243static void
1244get_array_start(void *state)
1245{
1246 GetState *_state = (GetState *) state;
1247 int lex_level = _state->lex->lex_level;
1248
1249 if (lex_level < _state->npath)
1250 {
1251 /* Initialize counting of elements in this array */
1252 _state->array_cur_index[lex_level] = -1;
1253
1254 /* INT_MIN value is reserved to represent invalid subscript */
1255 if (_state->path_indexes[lex_level] < 0 &&
1256 _state->path_indexes[lex_level] != INT_MIN)
1257 {
1258 /* Negative subscript -- convert to positive-wise subscript */
1259 JsonParseErrorType error;
1260 int nelements;
1261
1262 error = json_count_array_elements(_state->lex, &nelements);
1263 if (error != JSON_SUCCESS)
1264 json_ereport_error(error, _state->lex);
1265
1266 if (-_state->path_indexes[lex_level] <= nelements)
1267 _state->path_indexes[lex_level] += nelements;
1268 }
1269 }
1270 else if (lex_level == 0 && _state->npath == 0)
1271 {
1272 /*
1273 * Special case: we should match the entire array. We only need this
1274 * at the outermost level because at nested levels the match will have
1275 * been started by the outer field or array element callback.
1276 */
1277 _state->result_start = _state->lex->token_start;
1278 }
1279}
1280
1281static void
1282get_array_end(void *state)

Callers

nothing calls this directly

Calls 2

json_ereport_errorFunction · 0.85

Tested by

no test coverage detected