| 2370 | } // end of json_array_delete_init |
| 2371 | |
| 2372 | char *json_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result, |
| 2373 | unsigned long *res_length, uchar *is_null, uchar *error) |
| 2374 | { |
| 2375 | char *str = NULL; |
| 2376 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 2377 | |
| 2378 | if (g->Xchk) { |
| 2379 | // This constant function was recalled |
| 2380 | str = (char*)g->Xchk; |
| 2381 | goto fin; |
| 2382 | } // endif Xchk |
| 2383 | |
| 2384 | if (!CheckMemory(g, initid, args, 1, false, false, true)) { |
| 2385 | int *x; |
| 2386 | uint n = 1; |
| 2387 | PJSON top; |
| 2388 | PJAR arp; |
| 2389 | PJVAL jvp = MakeTypedValue(g, args, 0, TYPE_JSON, &top); |
| 2390 | |
| 2391 | if (!(x = GetIntArgPtr(g, args, n))) |
| 2392 | PUSH_WARNING("Missing or null array index"); |
| 2393 | else if (CheckPath(g, args, jvp->GetJson(), jvp, 1)) |
| 2394 | PUSH_WARNING(g->Message); |
| 2395 | else if (jvp && jvp->GetValType() == TYPE_JAR) { |
| 2396 | arp = jvp->GetArray(); |
| 2397 | arp->DeleteValue(*x); |
| 2398 | arp->InitArray(GetMemPtr(g, args, 0)); |
| 2399 | str = MakeResult(g, args, top, n); |
| 2400 | } else { |
| 2401 | PUSH_WARNING("First argument target is not an array"); |
| 2402 | // if (g->Mrr) *error = 1; |
| 2403 | } // endif jvp |
| 2404 | |
| 2405 | } // endif CheckMemory |
| 2406 | |
| 2407 | // In case of error or file, return unchanged argument |
| 2408 | if (!str) |
| 2409 | str = MakePSZ(g, args, 0); |
| 2410 | |
| 2411 | if (g->N) |
| 2412 | // Keep result of constant function |
| 2413 | g->Xchk = str; |
| 2414 | |
| 2415 | fin: |
| 2416 | if (!str) { |
| 2417 | *is_null = 1; |
| 2418 | *error = 1; |
| 2419 | *res_length = 0; |
| 2420 | } else |
| 2421 | *res_length = strlen(str); |
| 2422 | |
| 2423 | return str; |
| 2424 | } // end of json_array_delete |
| 2425 | |
| 2426 | void json_array_delete_deinit(UDF_INIT* initid) |
| 2427 | { |
nothing calls this directly
no test coverage detected