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

Function bson_object_delete

storage/connect/bsonudf.cpp:2605–2658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2603} // end of bson_object_delete_init
2604
2605char *bson_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
2606 unsigned long *res_length, uchar *is_null, uchar *error)
2607{
2608 char *str = NULL;
2609 PGLOBAL g = (PGLOBAL)initid->ptr;
2610
2611 if (g->Xchk) {
2612 // This constant function was recalled
2613 str = (char*)g->Xchk;
2614 goto fin;
2615 } // endif Xchk
2616
2617 if (!CheckMemory(g, initid, args, 1, false, true, true)) {
2618 bool chg;
2619 BJNX bnx(g, NULL, TYPE_STRG);
2620 PSZ key;
2621 PBVAL jsp, objp, top;
2622 PBVAL jvp = bnx.MakeValue(args, 0, false, &top);
2623
2624 jsp = jvp;
2625
2626 if (bnx.CheckPath(g, args, jsp, jvp, 2))
2627 PUSH_WARNING(g->Message);
2628 else if (jvp && jvp->Type == TYPE_JOB) {
2629 key = bnx.MakeKey(args, 1);
2630 objp = jvp;
2631 chg = bnx.DeleteKey(objp, key);
2632 bnx.SetChanged(chg);
2633 str = bnx.MakeResult(args, top);
2634 } else {
2635 PUSH_WARNING("First argument target is not an object");
2636 // if (g->Mrr) *error = 1; (only if no path)
2637 } // endif jvp
2638
2639 } // endif CheckMemory
2640
2641 // In case of error or file, return unchanged argument
2642 if (!str)
2643 str = MakePSZ(g, args, 0);
2644
2645 if (g->N)
2646 // Keep result of constant function
2647 g->Xchk = str;
2648
2649fin:
2650 if (!str) {
2651 *is_null = 1;
2652 *error = 1;
2653 *res_length = 0;
2654 } else
2655 *res_length = strlen(str);
2656
2657 return str;
2658} // end of bson_object_delete
2659
2660void bson_object_delete_deinit(UDF_INIT* initid)
2661{

Callers

nothing calls this directly

Calls 8

CheckMemoryFunction · 0.85
MakePSZFunction · 0.85
MakeValueMethod · 0.80
MakeKeyMethod · 0.80
SetChangedMethod · 0.80
MakeResultMethod · 0.80
CheckPathMethod · 0.45
DeleteKeyMethod · 0.45

Tested by

no test coverage detected