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

Function bson_array_add_values

storage/connect/bsonudf.cpp:2087–2127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2085} // end of bson_array_add_values_init
2086
2087char* bson_array_add_values(UDF_INIT* initid, UDF_ARGS* args, char* result,
2088 unsigned long* res_length, uchar * is_null, uchar *) {
2089 char* str = NULL;
2090 PGLOBAL g = (PGLOBAL)initid->ptr;
2091
2092 if (!g->Xchk) {
2093 if (!CheckMemory(g, initid, args, args->arg_count, true)) {
2094 BJNX bnx(g);
2095 PBVAL arp = bnx.MakeValue(args, 0, true);
2096
2097 if (arp->Type != TYPE_JAR) {
2098 PUSH_WARNING("First argument is not an array");
2099 goto fin;
2100 } // endif arp
2101
2102 for (uint i = 1; i < args->arg_count; i++)
2103 bnx.AddArrayValue(arp, bnx.MakeValue(args, i));
2104
2105 bnx.SetChanged(true);
2106 str = bnx.MakeResult(args, arp, INT_MAX);
2107 } // endif CheckMemory
2108
2109 if (!str) {
2110 PUSH_WARNING(g->Message);
2111 str = args->args[0];
2112 } // endif str
2113
2114 // Keep result of constant function
2115 g->Xchk = (g->N) ? str : NULL;
2116 } else
2117 str = (char*)g->Xchk;
2118
2119 fin:
2120 if (!str) {
2121 *res_length = 0;
2122 *is_null = 1;
2123 } else
2124 *res_length = strlen(str);
2125
2126 return str;
2127} // end of bson_array_add_values
2128
2129void bson_array_add_values_deinit(UDF_INIT* initid) {
2130 JsonFreeMem((PGLOBAL)initid->ptr);

Callers

nothing calls this directly

Calls 5

CheckMemoryFunction · 0.85
MakeValueMethod · 0.80
SetChangedMethod · 0.80
MakeResultMethod · 0.80
AddArrayValueMethod · 0.45

Tested by

no test coverage detected