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

Function jbin_object_list

storage/connect/jsonudf.cpp:5370–5416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5368} // end of jbin_object_list_init
5369
5370char *jbin_object_list(UDF_INIT *initid, UDF_ARGS *args, char *result,
5371 unsigned long *res_length, uchar *is_null, uchar *error)
5372{
5373 PJAR jarp = NULL;
5374 PGLOBAL g = (PGLOBAL)initid->ptr;
5375 PBSON bsp = (PBSON)g->Xchk;
5376
5377 if (!bsp || bsp->Changed) {
5378 if (!CheckMemory(g, initid, args, 1, true, true)) {
5379 char *p;
5380 PJSON jsp;
5381 PJVAL jvp = MakeValue(g, args, 0);
5382
5383 if ((p = jvp->GetString(g))) {
5384 if (!(jsp = ParseJson(g, p, strlen(p)))) {
5385 PUSH_WARNING(g->Message);
5386 return NULL;
5387 } // endif jsp
5388
5389 } else
5390 jsp = jvp->GetJson();
5391
5392 if (jsp->GetType() == TYPE_JOB) {
5393 jarp = ((PJOB)jsp)->GetKeyList(g);
5394 } else {
5395 PUSH_WARNING("First argument is not an object");
5396 if (g->Mrr) *error = 1;
5397 } // endif jsp type
5398
5399 } // endif CheckMemory
5400
5401 if ((bsp = JbinAlloc(g, args, initid->max_length, jarp)))
5402 safe_strcat(bsp->Msg, sizeof(bsp->Msg), " array");
5403
5404 // Keep result of constant function
5405 g->Xchk = (initid->const_item) ? bsp : NULL;
5406 } // endif bsp
5407
5408 if (!bsp) {
5409 *is_null = 1;
5410 *error = 1;
5411 *res_length = 0;
5412 } else
5413 *res_length = sizeof(BSON);
5414
5415 return (char*)bsp;
5416} // end of jbin_object_list
5417
5418void jbin_object_list_deinit(UDF_INIT* initid)
5419{

Callers

nothing calls this directly

Calls 9

CheckMemoryFunction · 0.85
MakeValueFunction · 0.85
ParseJsonFunction · 0.85
JbinAllocFunction · 0.85
safe_strcatFunction · 0.85
GetStringMethod · 0.45
GetJsonMethod · 0.45
GetTypeMethod · 0.45
GetKeyListMethod · 0.45

Tested by

no test coverage detected