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

Function jbin_object

storage/connect/jsonudf.cpp:5049–5086  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5047} // end of jbin_object_init
5048
5049char *jbin_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
5050 unsigned long *res_length, uchar *is_null, uchar *error)
5051{
5052 PGLOBAL g = (PGLOBAL)initid->ptr;
5053 PBSON bsp = (PBSON)g->Xchk;
5054
5055 if (!bsp || bsp->Changed) {
5056 if (!CheckMemory(g, initid, args, args->arg_count, true)) {
5057 PJOB objp;
5058
5059 if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
5060 for (uint i = 0; i < args->arg_count; i++)
5061 objp->SetKeyValue(g, MakeValue(g, args, i), MakeKey(g, args, i));
5062
5063
5064 if ((bsp = JbinAlloc(g, args, initid->max_length, objp)))
5065 safe_strcat(bsp->Msg, sizeof(bsp->Msg), " object");
5066
5067 } else
5068 bsp = NULL;
5069
5070 } else
5071 if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
5072 strmake(bsp->Msg, g->Message, BMX-1);
5073
5074 // Keep result of constant function
5075 g->Xchk = (initid->const_item) ? bsp : NULL;
5076 } // endif bsp
5077
5078 if (!bsp) {
5079 *is_null = 1;
5080 *error = 1;
5081 *res_length = 0;
5082 } else
5083 *res_length = sizeof(BSON);
5084
5085 return (char*)bsp;
5086} // end of jbin_object
5087
5088void jbin_object_deinit(UDF_INIT* initid)
5089{

Callers

nothing calls this directly

Calls 8

CheckMemoryFunction · 0.85
JsonNewFunction · 0.85
MakeValueFunction · 0.85
MakeKeyFunction · 0.85
JbinAllocFunction · 0.85
safe_strcatFunction · 0.85
strmakeFunction · 0.85
SetKeyValueMethod · 0.45

Tested by

no test coverage detected