/ Check if a path was specified and set jvp according to it. */ /
| 1391 | /* Check if a path was specified and set jvp according to it. */ |
| 1392 | /*********************************************************************************/ |
| 1393 | static my_bool CheckPath(PGLOBAL g, UDF_ARGS *args, PJSON jsp, PJVAL& jvp, int n) |
| 1394 | { |
| 1395 | for (uint i = n; i < args->arg_count; i++) |
| 1396 | if (args->arg_type[i] == STRING_RESULT && args->args[i]) { |
| 1397 | // A path to a subset of the json tree is given |
| 1398 | char *path = MakePSZ(g, args, i); |
| 1399 | |
| 1400 | if (path) { |
| 1401 | PJSNX jsx = new(g)JSNX(g, jsp, TYPE_STRING); |
| 1402 | |
| 1403 | if (jsx->SetJpath(g, path)) |
| 1404 | return true; |
| 1405 | |
| 1406 | if (!(jvp = jsx->GetJson(g))) { |
| 1407 | snprintf(g->Message, sizeof(g->Message), "No sub-item at '%s'", path); |
| 1408 | return true; |
| 1409 | } // endif jvp |
| 1410 | |
| 1411 | } else { |
| 1412 | snprintf(g->Message, sizeof(g->Message), "Path argument is null"); |
| 1413 | return true; |
| 1414 | } // endif path |
| 1415 | |
| 1416 | break; |
| 1417 | } // endif type |
| 1418 | |
| 1419 | return false; |
| 1420 | } // end of CheckPath |
| 1421 | |
| 1422 | /*********************************************************************************/ |
| 1423 | /* Make the result according to the first argument type. */ |
no test coverage detected