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

Function bson_object_values

storage/connect/bsonudf.cpp:2751–2802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2749} // end of bson_object_values_init
2750
2751char *bson_object_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
2752 unsigned long *res_length, uchar *is_null, uchar *error)
2753{
2754 char *str = NULL;
2755 PGLOBAL g = (PGLOBAL)initid->ptr;
2756
2757 if (!g->N) {
2758 if (!CheckMemory(g, initid, args, 1, true, true)) {
2759 BJNX bnx(g);
2760 char *p;
2761 PBVAL jsp, jarp;
2762 PBVAL jvp = bnx.MakeValue(args, 0);
2763
2764 if ((p = bnx.GetString(jvp))) {
2765 if (!(jsp = bnx.ParseJson(g, p, strlen(p)))) {
2766 PUSH_WARNING(g->Message);
2767 return NULL;
2768 } // endif jsp
2769
2770 } else
2771 jsp = jvp;
2772
2773 if (jsp->Type == TYPE_JOB) {
2774 jarp = bnx.GetObjectValList(jsp);
2775
2776 if (!(str = bnx.Serialize(g, jarp, NULL, 0)))
2777 PUSH_WARNING(g->Message);
2778
2779 } else {
2780 PUSH_WARNING("First argument is not an object");
2781 if (g->Mrr) *error = 1;
2782 } // endif jvp
2783
2784 } // endif CheckMemory
2785
2786 if (initid->const_item) {
2787 // Keep result of constant function
2788 g->Xchk = str;
2789 g->N = 1; // str can be NULL
2790 } // endif const_item
2791
2792 } else
2793 str = (char*)g->Xchk;
2794
2795 if (!str) {
2796 *is_null = 1;
2797 *res_length = 0;
2798 } else
2799 *res_length = strlen(str);
2800
2801 return str;
2802} // end of bson_object_values
2803
2804void bson_object_values_deinit(UDF_INIT* initid)
2805{

Callers

nothing calls this directly

Calls 6

CheckMemoryFunction · 0.85
MakeValueMethod · 0.80
ParseJsonMethod · 0.80
GetObjectValListMethod · 0.80
GetStringMethod · 0.45
SerializeMethod · 0.45

Tested by

no test coverage detected