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

Function jbin_object_nonull

storage/connect/jsonudf.cpp:5104–5142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5102} // end of jbin_object_nonull_init
5103
5104char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
5105 unsigned long *res_length, uchar *is_null, uchar *error)
5106{
5107 PGLOBAL g = (PGLOBAL)initid->ptr;
5108 PBSON bsp = (PBSON)g->Xchk;
5109
5110 if (!bsp || bsp->Changed) {
5111 if (!CheckMemory(g, initid, args, args->arg_count, false, true)) {
5112 PJVAL jvp;
5113 PJOB objp;
5114
5115 if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
5116 for (uint i = 0; i < args->arg_count; i++)
5117 if (!(jvp = MakeValue(g, args, i))->IsNull())
5118 objp->SetKeyValue(g, jvp, MakeKey(g, args, i));
5119
5120 if ((bsp = JbinAlloc(g, args, initid->max_length, objp)))
5121 safe_strcat(bsp->Msg, sizeof(bsp->Msg), " object");
5122
5123 } else
5124 bsp = NULL;
5125
5126 } else
5127 if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
5128 strmake(bsp->Msg, g->Message, BMX-1);
5129
5130 // Keep result of constant function
5131 g->Xchk = (initid->const_item) ? bsp : NULL;
5132 } // endif bsp
5133
5134 if (!bsp) {
5135 *is_null = 1;
5136 *error = 1;
5137 *res_length = 0;
5138 } else
5139 *res_length = sizeof(BSON);
5140
5141 return (char*)bsp;
5142} // end of jbin_object_nonull
5143
5144void jbin_object_nonull_deinit(UDF_INIT* initid)
5145{

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected