| 4220 | } // end of jsoncontains_path_init |
| 4221 | |
| 4222 | long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, uchar *, uchar *error) |
| 4223 | { |
| 4224 | char *p, *path; |
| 4225 | long long n; |
| 4226 | PJSON jsp; |
| 4227 | PJSNX jsx; |
| 4228 | PJVAL jvp; |
| 4229 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 4230 | |
| 4231 | if (g->N) { |
| 4232 | if (!g->Activityp) { |
| 4233 | return 0LL; |
| 4234 | } else |
| 4235 | return *(long long*)g->Activityp; |
| 4236 | |
| 4237 | } else if (initid->const_item) |
| 4238 | g->N = 1; |
| 4239 | |
| 4240 | if (!g->Xchk) { |
| 4241 | if (CheckMemory(g, initid, args, 1, true)) { |
| 4242 | PUSH_WARNING("CheckMemory error"); |
| 4243 | goto err; |
| 4244 | } else |
| 4245 | jvp = MakeValue(g, args, 0); |
| 4246 | |
| 4247 | if ((p = jvp->GetString(g))) { |
| 4248 | if (!(jsp = ParseJson(g, p, strlen(p)))) { |
| 4249 | PUSH_WARNING(g->Message); |
| 4250 | goto err; |
| 4251 | } // endif jsp |
| 4252 | |
| 4253 | } else |
| 4254 | jsp = jvp->GetJson(); |
| 4255 | |
| 4256 | if (g->Mrr) { // First argument is a constant |
| 4257 | g->Xchk = jsp; |
| 4258 | JsonMemSave(g); |
| 4259 | } // endif Mrr |
| 4260 | |
| 4261 | } else |
| 4262 | jsp = (PJSON)g->Xchk; |
| 4263 | |
| 4264 | path = MakePSZ(g, args, 1); |
| 4265 | jsx = JsnxNew(g, jsp, TYPE_BIGINT); |
| 4266 | |
| 4267 | if (!jsx || jsx->SetJpath(g, path)) { |
| 4268 | PUSH_WARNING(g->Message); |
| 4269 | goto err; |
| 4270 | } // endif SetJpath |
| 4271 | |
| 4272 | n = (jsx->CheckPath(g)) ? 1LL : 0LL; |
| 4273 | |
| 4274 | if (initid->const_item) { |
| 4275 | // Keep result of constant function |
| 4276 | long long *np = (long long*)PlgDBSubAlloc(g, NULL, sizeof(long long)); |
| 4277 | |
| 4278 | if (np) { |
| 4279 | *np = n; |
nothing calls this directly
no test coverage detected