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

Function jsonlocate

storage/connect/jsonudf.cpp:3917–4005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3915} // end of jsonlocate_init
3916
3917char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
3918 unsigned long *res_length, uchar *is_null, uchar *error)
3919{
3920 char *path = NULL;
3921 int k;
3922 PJVAL jvp, jvp2;
3923 PJSON jsp;
3924 PJSNX jsx;
3925 PGLOBAL g = (PGLOBAL)initid->ptr;
3926
3927 if (g->N) {
3928 if (g->Activityp) {
3929 path = (char*)g->Activityp;
3930 *res_length = strlen(path);
3931 return path;
3932 } else {
3933 *res_length = 0;
3934 *is_null = 1;
3935 return NULL;
3936 } // endif Activityp
3937
3938 } else if (initid->const_item)
3939 g->N = 1;
3940
3941 try {
3942 if (!g->Xchk) {
3943 if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
3944 PUSH_WARNING("CheckMemory error");
3945 *error = 1;
3946 goto err;
3947 } else
3948 jvp = MakeTypedValue(g, args, 0, TYPE_JSON);
3949
3950 //if ((p = jvp->GetString(g))) {
3951 // if (!(jsp = ParseJson(g, p, strlen(p)))) {
3952 // PUSH_WARNING(g->Message);
3953 // goto err;
3954 // } // endif jsp
3955 //} else
3956 // jsp = jvp->GetJson();
3957
3958 if (!(jsp = jvp->GetJson())) {
3959 PUSH_WARNING("First argument is not a valid JSON item");
3960 goto err;
3961 } // endif jsp
3962
3963 if (g->Mrr) { // First argument is a constant
3964 g->Xchk = jsp;
3965 JsonMemSave(g);
3966 } // endif Mrr
3967
3968 } else
3969 jsp = (PJSON)g->Xchk;
3970
3971 // The item to locate
3972 jvp2 = MakeValue(g, args, 1);
3973
3974 k = (args->arg_count > 2) ? (int)*(long long*)args->args[2] : 1;

Callers 1

jsoncontainsFunction · 0.85

Calls 7

CheckMemoryFunction · 0.85
MakeTypedValueFunction · 0.85
MakeValueFunction · 0.85
JsonMemSaveFunction · 0.70
htrcFunction · 0.70
GetJsonMethod · 0.45
LocateMethod · 0.45

Tested by

no test coverage detected