| 2180 | } // end of json_array_add_values_init |
| 2181 | |
| 2182 | char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result, |
| 2183 | unsigned long *res_length, uchar *is_null, uchar *) |
| 2184 | { |
| 2185 | char *str = NULL; |
| 2186 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 2187 | |
| 2188 | if (!g->Xchk) { |
| 2189 | if (!CheckMemory(g, initid, args, args->arg_count, true)) { |
| 2190 | PJSON top; |
| 2191 | PJAR arp; |
| 2192 | PJVAL jvp = MakeTypedValue(g, args, 0, TYPE_JAR, &top); |
| 2193 | |
| 2194 | if (jvp->GetValType() != TYPE_JAR) { |
| 2195 | arp = new(g)JARRAY; |
| 2196 | arp->AddArrayValue(g, jvp); |
| 2197 | top = arp; |
| 2198 | } else |
| 2199 | arp = jvp->GetArray(); |
| 2200 | |
| 2201 | for (uint i = 1; i < args->arg_count; i++) |
| 2202 | arp->AddArrayValue(g, MakeValue(g, args, i)); |
| 2203 | |
| 2204 | arp->InitArray(g); |
| 2205 | str = MakeResult(g, args, top, args->arg_count); |
| 2206 | } // endif CheckMemory |
| 2207 | |
| 2208 | if (!str) { |
| 2209 | PUSH_WARNING(g->Message); |
| 2210 | str = args->args[0]; |
| 2211 | } // endif str |
| 2212 | |
| 2213 | // Keep result of constant function |
| 2214 | g->Xchk = (g->N) ? str : NULL; |
| 2215 | } else |
| 2216 | str = (char*)g->Xchk; |
| 2217 | |
| 2218 | if (!str) { |
| 2219 | *res_length = 0; |
| 2220 | *is_null = 1; |
| 2221 | } else |
| 2222 | *res_length = strlen(str); |
| 2223 | |
| 2224 | return str; |
| 2225 | } // end of json_array_add_values |
| 2226 | |
| 2227 | void json_array_add_values_deinit(UDF_INIT* initid) |
| 2228 | { |
nothing calls this directly
no test coverage detected