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

Function jsonget_string

storage/connect/jsonudf.cpp:3567–3644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3565} // end of jsonget_string_init
3566
3567char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
3568 unsigned long *res_length, uchar *is_null, uchar *)
3569{
3570 char *p, *path, *str = NULL;
3571 PJSON jsp;
3572 PJSNX jsx;
3573 PJVAL jvp;
3574 PGLOBAL g = (PGLOBAL)initid->ptr;
3575
3576 if (g->N) {
3577 str = (char*)g->Activityp;
3578 goto err;
3579 } else if (initid->const_item)
3580 g->N = 1;
3581
3582 try {
3583 if (!g->Xchk) {
3584 if (CheckMemory(g, initid, args, 1, true)) {
3585 PUSH_WARNING("CheckMemory error");
3586 goto err;
3587 } else
3588 jvp = MakeValue(g, args, 0);
3589
3590 if ((p = jvp->GetString(g))) {
3591 if (!(jsp = ParseJson(g, p, strlen(p)))) {
3592 PUSH_WARNING(g->Message);
3593 goto err;
3594 } // endif jsp
3595
3596 } else
3597 jsp = jvp->GetJson();
3598
3599 if (g->Mrr) { // First argument is a constant
3600 g->Xchk = jsp;
3601 JsonMemSave(g);
3602 } // endif Mrr
3603
3604 } else
3605 jsp = (PJSON)g->Xchk;
3606
3607 path = MakePSZ(g, args, 1);
3608 jsx = JsnxNew(g, jsp, TYPE_STRING, initid->max_length);
3609
3610 if (!jsx || jsx->SetJpath(g, path)) {
3611 PUSH_WARNING(g->Message);
3612 goto err;
3613 } // endif SetJpath
3614
3615 jsx->ReadValue(g);
3616
3617 if (!jsx->GetValue()->IsNull())
3618 str = jsx->GetValue()->GetCharValue();
3619
3620 if (initid->const_item)
3621 // Keep result of constant function
3622 g->Activityp = (PACTIVITY)str;
3623
3624 } catch (int n) {

Callers

nothing calls this directly

Calls 14

CheckMemoryFunction · 0.85
MakeValueFunction · 0.85
ParseJsonFunction · 0.85
MakePSZFunction · 0.85
JsnxNewFunction · 0.85
JsonMemSaveFunction · 0.70
htrcFunction · 0.70
GetStringMethod · 0.45
GetJsonMethod · 0.45
SetJpathMethod · 0.45
ReadValueMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected