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

Function json_object_key

storage/connect/jsonudf.cpp:2764–2793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2762} // end of json_object_key_init
2763
2764char *json_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result,
2765 unsigned long *res_length, uchar *, uchar *)
2766{
2767 char *str = NULL;
2768 PGLOBAL g = (PGLOBAL)initid->ptr;
2769
2770 if (!g->Xchk) {
2771 if (!CheckMemory(g, initid, args, args->arg_count, false, true)) {
2772 PJOB objp;
2773
2774 if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
2775 for (uint i = 0; i < args->arg_count; i += 2)
2776 objp->SetKeyValue(g, MakeValue(g, args, i + 1), MakePSZ(g, args, i));
2777
2778 str = Serialize(g, objp, NULL, 0);
2779 } // endif objp
2780
2781 } // endif CheckMemory
2782
2783 if (!str)
2784 str = strcpy(result, g->Message);
2785
2786 // Keep result of constant function
2787 g->Xchk = (initid->const_item) ? str : NULL;
2788 } else
2789 str = (char*)g->Xchk;
2790
2791 *res_length = strlen(str);
2792 return str;
2793} // end of json_object_key
2794
2795void json_object_key_deinit(UDF_INIT* initid)
2796{

Callers

nothing calls this directly

Calls 6

CheckMemoryFunction · 0.85
JsonNewFunction · 0.85
MakeValueFunction · 0.85
MakePSZFunction · 0.85
SerializeFunction · 0.85
SetKeyValueMethod · 0.45

Tested by

no test coverage detected