| 2267 | } // end of bson_array_delete_init |
| 2268 | |
| 2269 | char *bson_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result, |
| 2270 | unsigned long *res_length, uchar *is_null, uchar *error) |
| 2271 | { |
| 2272 | char *str = NULL; |
| 2273 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 2274 | |
| 2275 | if (g->Xchk) { |
| 2276 | // This constant function was recalled |
| 2277 | str = (char*)g->Xchk; |
| 2278 | goto fin; |
| 2279 | } // endif Xchk |
| 2280 | |
| 2281 | if (!CheckMemory(g, initid, args, 1, false, false, true)) { |
| 2282 | int *x; |
| 2283 | uint n = 1; |
| 2284 | BJNX bnx(g, NULL, TYPE_STRING); |
| 2285 | PBVAL arp, top; |
| 2286 | PBVAL jvp = bnx.MakeValue(args, 0, true, &top); |
| 2287 | |
| 2288 | if (!(x = GetIntArgPtr(g, args, n))) |
| 2289 | PUSH_WARNING("Missing or null array index"); |
| 2290 | else if (bnx.CheckPath(g, args, jvp, arp, 1)) |
| 2291 | PUSH_WARNING(g->Message); |
| 2292 | else if (arp && arp->Type == TYPE_JAR) { |
| 2293 | bnx.DeleteValue(arp, *x); |
| 2294 | bnx.SetChanged(true); |
| 2295 | str = bnx.MakeResult(args, top, n); |
| 2296 | } else { |
| 2297 | PUSH_WARNING("First argument target is not an array"); |
| 2298 | // if (g->Mrr) *error = 1; |
| 2299 | } // endif jvp |
| 2300 | |
| 2301 | } // endif CheckMemory |
| 2302 | |
| 2303 | // In case of error or file, return unchanged argument |
| 2304 | if (!str) |
| 2305 | str = MakePSZ(g, args, 0); |
| 2306 | |
| 2307 | if (g->N) |
| 2308 | // Keep result of constant function |
| 2309 | g->Xchk = str; |
| 2310 | |
| 2311 | fin: |
| 2312 | if (!str) { |
| 2313 | *is_null = 1; |
| 2314 | *error = 1; |
| 2315 | *res_length = 0; |
| 2316 | } else |
| 2317 | *res_length = strlen(str); |
| 2318 | |
| 2319 | return str; |
| 2320 | } // end of bson_array_delete |
| 2321 | |
| 2322 | void bson_array_delete_deinit(UDF_INIT* initid) |
| 2323 | { |
nothing calls this directly
no test coverage detected