| 2927 | } // end of json_object_delete_init |
| 2928 | |
| 2929 | char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result, |
| 2930 | unsigned long *res_length, uchar *is_null, uchar *error) |
| 2931 | { |
| 2932 | char *str = NULL; |
| 2933 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 2934 | |
| 2935 | if (g->Xchk) { |
| 2936 | // This constant function was recalled |
| 2937 | str = (char*)g->Xchk; |
| 2938 | goto fin; |
| 2939 | } // endif Xchk |
| 2940 | |
| 2941 | if (!CheckMemory(g, initid, args, 1, false, true, true)) { |
| 2942 | PCSZ key; |
| 2943 | PJOB jobp; |
| 2944 | PJSON jsp, top; |
| 2945 | PJVAL jvp = MakeValue(g, args, 0, &top); |
| 2946 | |
| 2947 | jsp = jvp->GetJson(); |
| 2948 | |
| 2949 | if (CheckPath(g, args, jsp, jvp, 2)) |
| 2950 | PUSH_WARNING(g->Message); |
| 2951 | else if (jvp && jvp->GetValType() == TYPE_JOB) { |
| 2952 | key = MakeKey(GetMemPtr(g, args, 0), args, 1); |
| 2953 | jobp = jvp->GetObject(); |
| 2954 | jobp->DeleteKey(key); |
| 2955 | str = MakeResult(g, args, top); |
| 2956 | } else { |
| 2957 | PUSH_WARNING("First argument target is not an object"); |
| 2958 | // if (g->Mrr) *error = 1; (only if no path) |
| 2959 | } // endif jvp |
| 2960 | |
| 2961 | } // endif CheckMemory |
| 2962 | |
| 2963 | // In case of error or file, return unchanged argument |
| 2964 | if (!str) |
| 2965 | str = MakePSZ(g, args, 0); |
| 2966 | |
| 2967 | if (g->N) |
| 2968 | // Keep result of constant function |
| 2969 | g->Xchk = str; |
| 2970 | |
| 2971 | fin: |
| 2972 | if (!str) { |
| 2973 | *is_null = 1; |
| 2974 | *error = 1; |
| 2975 | *res_length = 0; |
| 2976 | } else |
| 2977 | *res_length = strlen(str); |
| 2978 | |
| 2979 | return str; |
| 2980 | } // end of json_object_delete |
| 2981 | |
| 2982 | void json_object_delete_deinit(UDF_INIT* initid) |
| 2983 | { |
nothing calls this directly
no test coverage detected