| 5102 | } // end of jbin_object_nonull_init |
| 5103 | |
| 5104 | char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, |
| 5105 | unsigned long *res_length, uchar *is_null, uchar *error) |
| 5106 | { |
| 5107 | PGLOBAL g = (PGLOBAL)initid->ptr; |
| 5108 | PBSON bsp = (PBSON)g->Xchk; |
| 5109 | |
| 5110 | if (!bsp || bsp->Changed) { |
| 5111 | if (!CheckMemory(g, initid, args, args->arg_count, false, true)) { |
| 5112 | PJVAL jvp; |
| 5113 | PJOB objp; |
| 5114 | |
| 5115 | if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) { |
| 5116 | for (uint i = 0; i < args->arg_count; i++) |
| 5117 | if (!(jvp = MakeValue(g, args, i))->IsNull()) |
| 5118 | objp->SetKeyValue(g, jvp, MakeKey(g, args, i)); |
| 5119 | |
| 5120 | if ((bsp = JbinAlloc(g, args, initid->max_length, objp))) |
| 5121 | safe_strcat(bsp->Msg, sizeof(bsp->Msg), " object"); |
| 5122 | |
| 5123 | } else |
| 5124 | bsp = NULL; |
| 5125 | |
| 5126 | } else |
| 5127 | if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) |
| 5128 | strmake(bsp->Msg, g->Message, BMX-1); |
| 5129 | |
| 5130 | // Keep result of constant function |
| 5131 | g->Xchk = (initid->const_item) ? bsp : NULL; |
| 5132 | } // endif bsp |
| 5133 | |
| 5134 | if (!bsp) { |
| 5135 | *is_null = 1; |
| 5136 | *error = 1; |
| 5137 | *res_length = 0; |
| 5138 | } else |
| 5139 | *res_length = sizeof(BSON); |
| 5140 | |
| 5141 | return (char*)bsp; |
| 5142 | } // end of jbin_object_nonull |
| 5143 | |
| 5144 | void jbin_object_nonull_deinit(UDF_INIT* initid) |
| 5145 | { |
nothing calls this directly
no test coverage detected