| 1241 | } |
| 1242 | |
| 1243 | static void |
| 1244 | get_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 | |
| 1281 | static void |
| 1282 | get_array_end(void *state) |
nothing calls this directly
no test coverage detected