| 5047 | } // end of jbin_object_init |
| 5048 | |
| 5049 | char *jbin_object(UDF_INIT *initid, UDF_ARGS *args, char *result, |
| 5050 | unsigned long *res_length, uchar *is_null, uchar *error) |
| 5051 | { |
| 5052 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 5053 | PBSON bsp = (PBSON)g->Xchk; |
| 5054 | |
| 5055 | if (!bsp || bsp->Changed) { |
| 5056 | if (!CheckMemory(g, initid, args, args->arg_count, true)) { |
| 5057 | PJOB objp; |
| 5058 | |
| 5059 | if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) { |
| 5060 | for (uint i = 0; i < args->arg_count; i++) |
| 5061 | objp->SetKeyValue(g, MakeValue(g, args, i), MakeKey(g, args, i)); |
| 5062 | |
| 5063 | |
| 5064 | if ((bsp = JbinAlloc(g, args, initid->max_length, objp))) |
| 5065 | safe_strcat(bsp->Msg, sizeof(bsp->Msg), " object"); |
| 5066 | |
| 5067 | } else |
| 5068 | bsp = NULL; |
| 5069 | |
| 5070 | } else |
| 5071 | if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) |
| 5072 | strmake(bsp->Msg, g->Message, BMX-1); |
| 5073 | |
| 5074 | // Keep result of constant function |
| 5075 | g->Xchk = (initid->const_item) ? bsp : NULL; |
| 5076 | } // endif bsp |
| 5077 | |
| 5078 | if (!bsp) { |
| 5079 | *is_null = 1; |
| 5080 | *error = 1; |
| 5081 | *res_length = 0; |
| 5082 | } else |
| 5083 | *res_length = sizeof(BSON); |
| 5084 | |
| 5085 | return (char*)bsp; |
| 5086 | } // end of jbin_object |
| 5087 | |
| 5088 | void jbin_object_deinit(UDF_INIT* initid) |
| 5089 | { |
nothing calls this directly
no test coverage detected