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

Function bsonget_string

storage/connect/bsonudf.cpp:3782–3861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3780} // end of bsonget_string_init
3781
3782char *bsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
3783 unsigned long *res_length, uchar *is_null, uchar *)
3784{
3785 char *p, *path, *str = NULL;
3786 PBVAL jsp, jvp;
3787 PBJNX bxp = NULL;
3788 PGLOBAL g = (PGLOBAL)initid->ptr;
3789
3790 if (g->N) {
3791 str = (char*)g->Activityp;
3792 goto err;
3793 } else if (initid->const_item)
3794 g->N = 1;
3795
3796 try {
3797 if (!g->Xchk) {
3798 if (CheckMemory(g, initid, args, 1, true)) {
3799 PUSH_WARNING("CheckMemory error");
3800 goto err;
3801 } else {
3802 BJNX bnx(g);
3803
3804 jvp = bnx.MakeValue(args, 0);
3805
3806 if ((p = bnx.GetString(jvp))) {
3807 if (!(jsp = bnx.ParseJson(g, p, strlen(p)))) {
3808 PUSH_WARNING(g->Message);
3809 goto err;
3810 } // endif jsp
3811
3812 } else
3813 jsp = jvp;
3814
3815 if (g->Mrr) { // First argument is a constant
3816 g->Xchk = jsp;
3817 JsonMemSave(g);
3818 } // endif Mrr
3819
3820 } // endelse CheckMemory
3821
3822 } else
3823 jsp = (PBVAL)g->Xchk;
3824
3825 path = MakePSZ(g, args, 1);
3826 bxp = new(g) BJNX(g, jsp, TYPE_STRING, initid->max_length);
3827
3828 if (bxp->SetJpath(g, path)) {
3829 PUSH_WARNING(g->Message);
3830 goto err;
3831 } else
3832 bxp->ReadValue(g);
3833
3834 if (!bxp->GetValue()->IsNull())
3835 str = bxp->GetValue()->GetCharValue();
3836
3837 if (initid->const_item)
3838 // Keep result of constant function
3839 g->Activityp = (PACTIVITY)str;

Callers

nothing calls this directly

Calls 12

CheckMemoryFunction · 0.85
MakePSZFunction · 0.85
MakeValueMethod · 0.80
ParseJsonMethod · 0.80
JsonMemSaveFunction · 0.70
htrcFunction · 0.70
GetStringMethod · 0.45
SetJpathMethod · 0.45
ReadValueMethod · 0.45
IsNullMethod · 0.45
GetValueMethod · 0.45
GetCharValueMethod · 0.45

Tested by

no test coverage detected