| 5225 | } // end of jbin_object_add_init |
| 5226 | |
| 5227 | char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result, |
| 5228 | unsigned long *res_length, uchar *is_null, uchar *error) |
| 5229 | { |
| 5230 | PJSON top = NULL; |
| 5231 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 5232 | PBSON bsp = (PBSON)g->Xchk; |
| 5233 | |
| 5234 | if (bsp && !bsp->Changed) { |
| 5235 | // This constant function was recalled |
| 5236 | bsp = (PBSON)g->Xchk; |
| 5237 | *res_length = sizeof(BSON); |
| 5238 | return (char*)bsp; |
| 5239 | } // endif bsp |
| 5240 | |
| 5241 | if (!CheckMemory(g, initid, args, 2, false, true, true)) { |
| 5242 | PCSZ key; |
| 5243 | PJOB jobp; |
| 5244 | PJVAL jvp = MakeValue(g, args, 0, &top); |
| 5245 | PJSON jsp = jvp->GetJson(); |
| 5246 | |
| 5247 | if (CheckPath(g, args, jsp, jvp, 2)) |
| 5248 | PUSH_WARNING(g->Message); |
| 5249 | else if (jvp && jvp->GetValType() == TYPE_JOB) { |
| 5250 | PGLOBAL gb = GetMemPtr(g, args, 0); |
| 5251 | |
| 5252 | jobp = jvp->GetObject(); |
| 5253 | jvp = MakeValue(gb, args, 1); |
| 5254 | key = MakeKey(gb, args, 1); |
| 5255 | jobp->SetKeyValue(gb, jvp, key); |
| 5256 | } else { |
| 5257 | PUSH_WARNING("First argument target is not an object"); |
| 5258 | // if (g->Mrr) *error = 1; (only if no path) |
| 5259 | } // endif jvp |
| 5260 | |
| 5261 | } // endif CheckMemory |
| 5262 | |
| 5263 | // In case of error unchanged argument will be returned |
| 5264 | bsp = MakeBinResult(g, args, top, initid->max_length); |
| 5265 | |
| 5266 | if (initid->const_item) |
| 5267 | // Keep result of constant function |
| 5268 | g->Xchk = bsp; |
| 5269 | |
| 5270 | if (!bsp) { |
| 5271 | *is_null = 1; |
| 5272 | *error = 1; |
| 5273 | *res_length = 0; |
| 5274 | } else |
| 5275 | *res_length = sizeof(BSON); |
| 5276 | |
| 5277 | return (char*)bsp; |
| 5278 | } // end of jbin_object_add |
| 5279 | |
| 5280 | void jbin_object_add_deinit(UDF_INIT* initid) |
| 5281 | { |
nothing calls this directly
no test coverage detected