MCPcopy Create free account
hub / github.com/MariaDB/server / bson_array_delete

Function bson_array_delete

storage/connect/bsonudf.cpp:2269–2320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2267} // end of bson_array_delete_init
2268
2269char *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
2311fin:
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
2322void bson_array_delete_deinit(UDF_INIT* initid)
2323{

Callers

nothing calls this directly

Calls 8

CheckMemoryFunction · 0.85
MakePSZFunction · 0.85
MakeValueMethod · 0.80
SetChangedMethod · 0.80
MakeResultMethod · 0.80
GetIntArgPtrFunction · 0.70
CheckPathMethod · 0.45
DeleteValueMethod · 0.45

Tested by

no test coverage detected