Current step of the patch matches the JSON construction. Now we should either stop the search or go to the next step of the path. */
| 1418 | step of the path. |
| 1419 | */ |
| 1420 | static int handle_match(json_engine_t *je, json_path_t *p, |
| 1421 | json_path_step_t **p_cur_step, |
| 1422 | MEM_ROOT_DYNAMIC_ARRAY *array_counters) |
| 1423 | { |
| 1424 | json_path_step_t *initial_step= |
| 1425 | (json_path_step_t*)(p->steps.buffer), |
| 1426 | *next_step= NULL, |
| 1427 | *last_step= |
| 1428 | (json_path_step_t*)(p->steps.buffer) + p->last_step_idx; |
| 1429 | int value= 0; |
| 1430 | size_t idx= 0; |
| 1431 | |
| 1432 | idx= *p_cur_step - initial_step; |
| 1433 | next_step= |
| 1434 | (json_path_step_t*)(p->steps.buffer)+(idx+1); |
| 1435 | |
| 1436 | DBUG_ASSERT(*p_cur_step < last_step); |
| 1437 | |
| 1438 | if (json_read_value(je)) |
| 1439 | return 1; |
| 1440 | |
| 1441 | if (json_value_scalar(je)) |
| 1442 | { |
| 1443 | while (next_step->type == JSON_PATH_ARRAY && next_step->n_item == 0) |
| 1444 | { |
| 1445 | next_step++; |
| 1446 | if (next_step > last_step) |
| 1447 | { |
| 1448 | je->s.c_str= je->value_begin; |
| 1449 | return 1; |
| 1450 | } |
| 1451 | } |
| 1452 | return 0; |
| 1453 | } |
| 1454 | |
| 1455 | if (next_step->type == JSON_PATH_ARRAY && next_step->n_item == 0 && |
| 1456 | je->value_type & JSON_VALUE_OBJECT) |
| 1457 | { |
| 1458 | do |
| 1459 | { |
| 1460 | int val= SKIPPED_STEP_MARK; |
| 1461 | int idx= (int)(next_step-initial_step); |
| 1462 | |
| 1463 | set_json_array_value_ptr(idx, array_counters->max_element, array_counters, val); |
| 1464 | |
| 1465 | next_step++; |
| 1466 | if (next_step > last_step) |
| 1467 | { |
| 1468 | je->s.c_str= je->value_begin; |
| 1469 | je->stack_p--; |
| 1470 | return 1; |
| 1471 | } |
| 1472 | } while (next_step->type == JSON_PATH_ARRAY && next_step->n_item == 0); |
| 1473 | } |
| 1474 | |
| 1475 | if ((int) je->value_type != |
| 1476 | (int) (next_step->type & JSON_PATH_KEY_OR_ARRAY)) |
| 1477 | return json_skip_level(je); |
no test coverage detected