| 4814 | } // end of jbin_array_add_values_init |
| 4815 | |
| 4816 | char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result, |
| 4817 | unsigned long *res_length, uchar *is_null, uchar *error) |
| 4818 | { |
| 4819 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 4820 | PBSON bsp = (PBSON)g->Xchk; |
| 4821 | |
| 4822 | if (!bsp || bsp->Changed) { |
| 4823 | if (!CheckMemory(g, initid, args, args->arg_count, true)) { |
| 4824 | PJSON top; |
| 4825 | PJAR arp; |
| 4826 | PJVAL jvp = MakeTypedValue(g, args, 0, TYPE_JAR, &top); |
| 4827 | PGLOBAL gb = GetMemPtr(g, args, 0); |
| 4828 | |
| 4829 | if (jvp->GetValType() != TYPE_JAR) { |
| 4830 | if ((arp = (PJAR)JsonNew(gb, TYPE_JAR))) { |
| 4831 | arp->AddArrayValue(gb, jvp); |
| 4832 | top = arp; |
| 4833 | } // endif arp |
| 4834 | |
| 4835 | } else |
| 4836 | arp = jvp->GetArray(); |
| 4837 | |
| 4838 | for (uint i = 1; i < args->arg_count; i++) |
| 4839 | arp->AddArrayValue(gb, MakeValue(gb, args, i)); |
| 4840 | |
| 4841 | arp->InitArray(gb); |
| 4842 | |
| 4843 | if ((bsp = JbinAlloc(g, args, initid->max_length, top))) { |
| 4844 | safe_strcat(bsp->Msg, sizeof(bsp->Msg), " array"); |
| 4845 | bsp->Jsp = arp; |
| 4846 | } // endif bsp |
| 4847 | |
| 4848 | } else |
| 4849 | if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) |
| 4850 | strmake(bsp->Msg, g->Message, BMX-1); |
| 4851 | |
| 4852 | // Keep result of constant function |
| 4853 | g->Xchk = (initid->const_item) ? bsp : NULL; |
| 4854 | } // endif bsp |
| 4855 | |
| 4856 | if (!bsp) { |
| 4857 | *is_null = 1; |
| 4858 | *error = 1; |
| 4859 | *res_length = 0; |
| 4860 | } else |
| 4861 | *res_length = sizeof(BSON); |
| 4862 | |
| 4863 | return (char*)bsp; |
| 4864 | } // end of jbin_array_add_values |
| 4865 | |
| 4866 | void jbin_array_add_values_deinit(UDF_INIT* initid) |
| 4867 | { |
nothing calls this directly
no test coverage detected