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

Function json_object_list

storage/connect/jsonudf.cpp:3006–3056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3004} // end of json_object_list_init
3005
3006char *json_object_list(UDF_INIT *initid, UDF_ARGS *args, char *result,
3007 unsigned long *res_length, uchar *is_null, uchar *error)
3008{
3009 char *str = NULL;
3010 PGLOBAL g = (PGLOBAL)initid->ptr;
3011
3012 if (!g->N) {
3013 if (!CheckMemory(g, initid, args, 1, true, true)) {
3014 char *p;
3015 PJSON jsp;
3016 PJVAL jvp = MakeValue(g, args, 0);
3017
3018 if ((p = jvp->GetString(g))) {
3019 if (!(jsp = ParseJson(g, p, strlen(p)))) {
3020 PUSH_WARNING(g->Message);
3021 return NULL;
3022 } // endif jsp
3023
3024 } else
3025 jsp = jvp->GetJson();
3026
3027 if (jsp->GetType() == TYPE_JOB) {
3028 PJAR jarp = ((PJOB)jsp)->GetKeyList(g);
3029
3030 if (!(str = Serialize(g, jarp, NULL, 0)))
3031 PUSH_WARNING(g->Message);
3032
3033 } else {
3034 PUSH_WARNING("First argument is not an object");
3035 if (g->Mrr) *error = 1;
3036 } // endif jvp
3037
3038 } // endif CheckMemory
3039
3040 if (initid->const_item) {
3041 // Keep result of constant function
3042 g->Xchk = str;
3043 g->N = 1; // str can be NULL
3044 } // endif const_item
3045
3046 } else
3047 str = (char*)g->Xchk;
3048
3049 if (!str) {
3050 *is_null = 1;
3051 *res_length = 0;
3052 } else
3053 *res_length = strlen(str);
3054
3055 return str;
3056} // end of json_object_list
3057
3058void json_object_list_deinit(UDF_INIT* initid)
3059{

Callers

nothing calls this directly

Calls 8

CheckMemoryFunction · 0.85
MakeValueFunction · 0.85
ParseJsonFunction · 0.85
SerializeFunction · 0.85
GetStringMethod · 0.45
GetJsonMethod · 0.45
GetTypeMethod · 0.45
GetKeyListMethod · 0.45

Tested by

no test coverage detected