MCPcopy Create free account
hub / github.com/MariaDB/server / jbin_array_delete

Function jbin_array_delete

storage/connect/jsonudf.cpp:4980–5031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4978 } // end of jbin_array_delete_init
4979
4980char *jbin_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
4981 unsigned long *res_length, uchar *is_null, uchar *error)
4982{
4983 PJSON top = NULL;
4984 PGLOBAL g = (PGLOBAL)initid->ptr;
4985 PBSON bsp = (PBSON)g->Xchk;
4986
4987 if (bsp && !bsp->Changed) {
4988 // This constant function was recalled
4989 *res_length = sizeof(BSON);
4990 return (char*)bsp;
4991 } // endif bsp
4992
4993 if (!CheckMemory(g, initid, args, 1, false, false, true)) {
4994 int *x;
4995 uint n = 1;
4996 PJAR arp;
4997 PJVAL jvp = MakeTypedValue(g, args, 0, TYPE_JSON, &top);
4998
4999 if (CheckPath(g, args, top, jvp, 1))
5000 PUSH_WARNING(g->Message);
5001 else if (jvp && jvp->GetValType() == TYPE_JAR) {
5002 if ((x = GetIntArgPtr(g, args, n))) {
5003 arp = jvp->GetArray();
5004 arp->DeleteValue(*x);
5005 arp->InitArray(GetMemPtr(g, args, 0));
5006 } else
5007 PUSH_WARNING("Missing or null array index");
5008
5009 } else {
5010 PUSH_WARNING("First argument target is not an array");
5011// if (g->Mrr) *error = 1;
5012 } // endif jvp
5013
5014 } // endif CheckMemory
5015
5016 // In case of error unchanged argument will be returned
5017 bsp = MakeBinResult(g, args, top, initid->max_length);
5018
5019 if (initid->const_item)
5020 // Keep result of constant function
5021 g->Xchk = bsp;
5022
5023 if (!bsp) {
5024 *is_null = 1;
5025 *error = 1;
5026 *res_length = 0;
5027 } else
5028 *res_length = sizeof(BSON);
5029
5030 return (char*)bsp;
5031} // end of jbin_array_delete
5032
5033void jbin_array_delete_deinit(UDF_INIT* initid)
5034{

Callers

nothing calls this directly

Calls 10

CheckMemoryFunction · 0.85
MakeTypedValueFunction · 0.85
CheckPathFunction · 0.85
GetMemPtrFunction · 0.85
MakeBinResultFunction · 0.85
GetValTypeMethod · 0.80
InitArrayMethod · 0.80
GetIntArgPtrFunction · 0.70
GetArrayMethod · 0.45
DeleteValueMethod · 0.45

Tested by

no test coverage detected