mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fix memory error when a plain string argument is parsed.
Parsing memory, not added in CalcLen, is added in CheckMemory. modified: storage/connect/jsonudf.cpp
This commit is contained in:
@@ -1263,7 +1263,7 @@ static int IsJson(UDF_ARGS *args, uint i)
|
|||||||
static PGLOBAL GetMemPtr(PGLOBAL g, UDF_ARGS *args, uint i)
|
static PGLOBAL GetMemPtr(PGLOBAL g, UDF_ARGS *args, uint i)
|
||||||
{
|
{
|
||||||
return (IsJson(args, i) == 3) ? ((PBSON)args->args[i])->G : g;
|
return (IsJson(args, i) == 3) ? ((PBSON)args->args[i])->G : g;
|
||||||
} // end of IsJson
|
} // end of GetMemPtr
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/* GetFileLength: returns file size in number of bytes. */
|
/* GetFileLength: returns file size in number of bytes. */
|
||||||
@@ -1408,18 +1408,23 @@ static my_bool CalcLen(UDF_ARGS *args, my_bool obj,
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/* Check if the calculated memory is enough. */
|
/* Check if the calculated memory is enough. */
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args,
|
static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
|
||||||
uint n, my_bool obj, my_bool mod = false)
|
my_bool m, my_bool obj = false, my_bool mod = false)
|
||||||
{
|
{
|
||||||
unsigned long rl, ml;
|
unsigned long rl, ml;
|
||||||
|
my_bool b = false;
|
||||||
|
|
||||||
n = MY_MIN(n, args->arg_count);
|
n = MY_MIN(n, args->arg_count);
|
||||||
|
|
||||||
for (uint i = 0; i < n; i++)
|
for (uint i = 0; i < n; i++)
|
||||||
if (IsJson(args, i) == 2) {
|
if (IsJson(args, i) == 2 ||
|
||||||
|
(b == (m && !i && args->arg_type[0] == STRING_RESULT && !IsJson(args, 0)))) {
|
||||||
if (CalcLen(args, obj, rl, ml, mod))
|
if (CalcLen(args, obj, rl, ml, mod))
|
||||||
return true;
|
return true;
|
||||||
else if (ml > g->Sarea_Size) {
|
else if (b)
|
||||||
|
ml += args->lengths[0] * M; // Was not done in CalcLen
|
||||||
|
|
||||||
|
if (ml > g->Sarea_Size) {
|
||||||
free(g->Sarea);
|
free(g->Sarea);
|
||||||
|
|
||||||
if (!(g->Sarea = PlugAllocMem(g, ml))) {
|
if (!(g->Sarea = PlugAllocMem(g, ml))) {
|
||||||
@@ -1794,7 +1799,7 @@ char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
if (!CheckMemory(g, initid, args, args->arg_count, false)) {
|
if (!CheckMemory(g, initid, args, args->arg_count, true)) {
|
||||||
char *p;
|
char *p;
|
||||||
PJSON top;
|
PJSON top;
|
||||||
PJAR arp;
|
PJAR arp;
|
||||||
@@ -1878,7 +1883,7 @@ char *json_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
goto fin;
|
goto fin;
|
||||||
} // endif Xchk
|
} // endif Xchk
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 2, false, true)) {
|
if (!CheckMemory(g, initid, args, 2, false, false, true)) {
|
||||||
int *x;
|
int *x;
|
||||||
uint n = 2;
|
uint n = 2;
|
||||||
PJSON jsp, top;
|
PJSON jsp, top;
|
||||||
@@ -1960,7 +1965,7 @@ char *json_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
goto fin;
|
goto fin;
|
||||||
} // endif Xchk
|
} // endif Xchk
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false, true)) {
|
if (!CheckMemory(g, initid, args, 1, false, false, true)) {
|
||||||
int *x;
|
int *x;
|
||||||
uint n = 1;
|
uint n = 1;
|
||||||
PJSON top;
|
PJSON top;
|
||||||
@@ -2025,7 +2030,7 @@ char *json_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
if (!CheckMemory(g, initid, args, args->arg_count, true)) {
|
if (!CheckMemory(g, initid, args, args->arg_count, false, false, true)) {
|
||||||
PJOB objp = new(g)JOBJECT;
|
PJOB objp = new(g)JOBJECT;
|
||||||
|
|
||||||
for (uint i = 0; i < args->arg_count; i++)
|
for (uint i = 0; i < args->arg_count; i++)
|
||||||
@@ -2070,7 +2075,7 @@ char *json_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
if (!CheckMemory(g, initid, args, args->arg_count, true)) {
|
if (!CheckMemory(g, initid, args, args->arg_count, false, true)) {
|
||||||
PJVAL jvp;
|
PJVAL jvp;
|
||||||
PJOB objp = new(g)JOBJECT;
|
PJOB objp = new(g)JOBJECT;
|
||||||
|
|
||||||
@@ -2121,7 +2126,7 @@ char *json_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
if (!CheckMemory(g, initid, args, args->arg_count, true)) {
|
if (!CheckMemory(g, initid, args, args->arg_count, false, true)) {
|
||||||
PJOB objp = new(g)JOBJECT;
|
PJOB objp = new(g)JOBJECT;
|
||||||
|
|
||||||
for (uint i = 0; i < args->arg_count; i += 2)
|
for (uint i = 0; i < args->arg_count; i += 2)
|
||||||
@@ -2161,7 +2166,7 @@ my_bool json_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
strcpy(message, "First argument must be a json item");
|
strcpy(message, "First argument must be a json item");
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
CalcLen(args, false, reslen, memlen, true);
|
CalcLen(args, true, reslen, memlen, true);
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
} // end of json_object_add_init
|
} // end of json_object_add_init
|
||||||
@@ -2178,7 +2183,7 @@ char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
goto fin;
|
goto fin;
|
||||||
} // endif Xchk
|
} // endif Xchk
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 2, false, true)) {
|
if (!CheckMemory(g, initid, args, 2, false, true, true)) {
|
||||||
PJOB jobp;
|
PJOB jobp;
|
||||||
PJVAL jvp;
|
PJVAL jvp;
|
||||||
PJSON jsp, top;
|
PJSON jsp, top;
|
||||||
@@ -2243,7 +2248,7 @@ my_bool json_object_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
strcpy(message, "Second argument must be a key string");
|
strcpy(message, "Second argument must be a key string");
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
CalcLen(args, false, reslen, memlen, true);
|
CalcLen(args, true, reslen, memlen, true);
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
} // end of json_object_delete_init
|
} // end of json_object_delete_init
|
||||||
@@ -2260,7 +2265,7 @@ char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
goto fin;
|
goto fin;
|
||||||
} // endif Xchk
|
} // endif Xchk
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false, true)) {
|
if (!CheckMemory(g, initid, args, 1, false, true, true)) {
|
||||||
char *key;
|
char *key;
|
||||||
PJOB jobp;
|
PJOB jobp;
|
||||||
PJSON jsp, top;
|
PJSON jsp, top;
|
||||||
@@ -2332,7 +2337,7 @@ char *json_object_list(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (!g->N) {
|
if (!g->N) {
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
if (!CheckMemory(g, initid, args, 1, true, true)) {
|
||||||
char *p;
|
char *p;
|
||||||
PJSON jsp;
|
PJSON jsp;
|
||||||
PJVAL jvp = MakeValue(g, args, 0);
|
PJVAL jvp = MakeValue(g, args, 0);
|
||||||
@@ -2560,7 +2565,7 @@ char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
goto fin;
|
goto fin;
|
||||||
} // endif Xchk
|
} // endif Xchk
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 2, false, true)) {
|
if (!CheckMemory(g, initid, args, 2, false, false, true)) {
|
||||||
PJSON top;
|
PJSON top;
|
||||||
PJVAL jvp;
|
PJVAL jvp;
|
||||||
PJSON jsp[2] = {NULL, NULL};
|
PJSON jsp[2] = {NULL, NULL};
|
||||||
@@ -2648,7 +2653,10 @@ my_bool json_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *)
|
unsigned long *res_length, char *is_null, char *)
|
||||||
{
|
{
|
||||||
char *str = NULL;
|
char *p, *path, *str = NULL;
|
||||||
|
PJSON jsp;
|
||||||
|
PJVAL jvp;
|
||||||
|
PJSNX jsx;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
@@ -2657,13 +2665,12 @@ char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p, *path;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
PJVAL jvp = MakeValue(g, args, 0);
|
if (CheckMemory(g, initid, args, 1, true, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
goto fin;
|
||||||
|
} else
|
||||||
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||||
@@ -2700,8 +2707,6 @@ char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Activityp = (PACTIVITY)str;
|
g->Activityp = (PACTIVITY)str;
|
||||||
|
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
if (!str) {
|
if (!str) {
|
||||||
*is_null = 1;
|
*is_null = 1;
|
||||||
@@ -2762,8 +2767,11 @@ my_bool jsonget_string_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *)
|
unsigned long *res_length, char *is_null, char *)
|
||||||
{
|
{
|
||||||
|
char *p, *path, *str = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
char *str = NULL;
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
|
PJVAL jvp;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
@@ -2772,12 +2780,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p, *path;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
PJVAL jvp;
|
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||||
@@ -2792,6 +2794,10 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} // endif rc
|
} // endif rc
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
goto err;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
@@ -2830,7 +2836,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
if (!str) {
|
if (!str) {
|
||||||
@@ -2875,6 +2880,11 @@ my_bool jsonget_int_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args,
|
long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args,
|
||||||
char *is_null, char *error)
|
char *is_null, char *error)
|
||||||
{
|
{
|
||||||
|
char *p, *path;
|
||||||
|
long long n;
|
||||||
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
|
PJVAL jvp;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
@@ -2887,14 +2897,13 @@ long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p, *path;
|
|
||||||
long long n;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
PJVAL jvp;
|
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
if (g->Mrr) *error = 1;
|
||||||
|
*is_null = 1;
|
||||||
|
return 0LL;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
@@ -2928,7 +2937,6 @@ long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args,
|
|||||||
jsx->ReadValue(g);
|
jsx->ReadValue(g);
|
||||||
|
|
||||||
if (jsx->GetValue()->IsNull()) {
|
if (jsx->GetValue()->IsNull()) {
|
||||||
// PUSH_WARNING("Value not found");
|
|
||||||
*is_null = 1;
|
*is_null = 1;
|
||||||
return 0;
|
return 0;
|
||||||
} // endif IsNull
|
} // endif IsNull
|
||||||
@@ -2943,11 +2951,6 @@ long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args,
|
|||||||
} // endif const_item
|
} // endif const_item
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
if (g->Mrr) *error = 1;
|
|
||||||
*is_null = 1;
|
|
||||||
return 0LL;
|
|
||||||
} // end of jsonget_int
|
} // end of jsonget_int
|
||||||
|
|
||||||
void jsonget_int_deinit(UDF_INIT* initid)
|
void jsonget_int_deinit(UDF_INIT* initid)
|
||||||
@@ -2992,6 +2995,11 @@ my_bool jsonget_real_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
double jsonget_real(UDF_INIT *initid, UDF_ARGS *args,
|
double jsonget_real(UDF_INIT *initid, UDF_ARGS *args,
|
||||||
char *is_null, char *error)
|
char *is_null, char *error)
|
||||||
{
|
{
|
||||||
|
char *p, *path;
|
||||||
|
double d;
|
||||||
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
|
PJVAL jvp;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
@@ -3004,14 +3012,13 @@ double jsonget_real(UDF_INIT *initid, UDF_ARGS *args,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p, *path;
|
|
||||||
double d;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
PJVAL jvp;
|
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
if (g->Mrr) *error = 1;
|
||||||
|
*is_null = 1;
|
||||||
|
return 0.0;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
@@ -3044,7 +3051,6 @@ double jsonget_real(UDF_INIT *initid, UDF_ARGS *args,
|
|||||||
jsx->ReadValue(g);
|
jsx->ReadValue(g);
|
||||||
|
|
||||||
if (jsx->GetValue()->IsNull()) {
|
if (jsx->GetValue()->IsNull()) {
|
||||||
// PUSH_WARNING("Value not found");
|
|
||||||
*is_null = 1;
|
*is_null = 1;
|
||||||
return 0.0;
|
return 0.0;
|
||||||
} // endif IsNull
|
} // endif IsNull
|
||||||
@@ -3059,11 +3065,6 @@ double jsonget_real(UDF_INIT *initid, UDF_ARGS *args,
|
|||||||
} // endif const_item
|
} // endif const_item
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
if (g->Mrr) *error = 1;
|
|
||||||
*is_null = 1;
|
|
||||||
return 0.0;
|
|
||||||
} // end of jsonget_real
|
} // end of jsonget_real
|
||||||
|
|
||||||
void jsonget_real_deinit(UDF_INIT* initid)
|
void jsonget_real_deinit(UDF_INIT* initid)
|
||||||
@@ -3105,7 +3106,11 @@ my_bool jsonlocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
char *path = NULL;
|
char *p, *path = NULL;
|
||||||
|
int k, rc;
|
||||||
|
PJVAL jvp, jvp2;
|
||||||
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
@@ -3122,13 +3127,6 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p;
|
|
||||||
int k, rc;
|
|
||||||
PJVAL jvp, jvp2;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||||
@@ -3145,6 +3143,11 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} // endif rc
|
} // endif rc
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
*error = 1;
|
||||||
|
goto err;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
@@ -3186,11 +3189,6 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
*res_length = strlen(path);
|
*res_length = strlen(path);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
*error = 1;
|
|
||||||
*is_null = 1;
|
|
||||||
return NULL;
|
|
||||||
} // end of jsonlocate
|
} // end of jsonlocate
|
||||||
|
|
||||||
void jsonlocate_deinit(UDF_INIT* initid)
|
void jsonlocate_deinit(UDF_INIT* initid)
|
||||||
@@ -3232,7 +3230,11 @@ my_bool json_locate_all_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
char *path = NULL;
|
char *p, *path = NULL;
|
||||||
|
int rc, mx = 10;
|
||||||
|
PJVAL jvp, jvp2;
|
||||||
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
@@ -3250,13 +3252,6 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p;
|
|
||||||
int rc, mx = 10;
|
|
||||||
PJVAL jvp, jvp2;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||||
@@ -3273,6 +3268,11 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} // endif rc
|
} // endif rc
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
*error = 1;
|
||||||
|
goto err;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
@@ -3315,11 +3315,6 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
*res_length = strlen(path);
|
*res_length = strlen(path);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
*error = 1;
|
|
||||||
*is_null = 1;
|
|
||||||
return NULL;
|
|
||||||
} // end of json_locate_all
|
} // end of json_locate_all
|
||||||
|
|
||||||
void json_locate_all_deinit(UDF_INIT* initid)
|
void json_locate_all_deinit(UDF_INIT* initid)
|
||||||
@@ -3416,6 +3411,11 @@ my_bool jsoncontains_path_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
|
char *p, *path;
|
||||||
|
long long n;
|
||||||
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
|
PJVAL jvp;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
@@ -3428,22 +3428,17 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p, *path;
|
|
||||||
long long n;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
PJVAL jvp;
|
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
goto err;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
if (g->Mrr) *error = 1;
|
goto err;
|
||||||
*is_null = 1;
|
|
||||||
return 0;
|
|
||||||
} // endif jsp
|
} // endif jsp
|
||||||
|
|
||||||
} else
|
} else
|
||||||
@@ -3462,8 +3457,7 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
|
|
||||||
if (jsx->SetJpath(g, path)) {
|
if (jsx->SetJpath(g, path)) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
*is_null = 1;
|
goto err;
|
||||||
return 0;
|
|
||||||
} // endif SetJpath
|
} // endif SetJpath
|
||||||
|
|
||||||
n = (jsx->CheckPath(g)) ? 1LL : 0LL;
|
n = (jsx->CheckPath(g)) ? 1LL : 0LL;
|
||||||
@@ -3476,8 +3470,8 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} // endif const_item
|
} // endif const_item
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
|
err:
|
||||||
if (g->Mrr) *error = 1;
|
if (g->Mrr) *error = 1;
|
||||||
*is_null = 1;
|
*is_null = 1;
|
||||||
return 0LL;
|
return 0LL;
|
||||||
@@ -3522,10 +3516,14 @@ my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
|
char *p, *path, *str = NULL;
|
||||||
int w, rc;
|
int w, rc;
|
||||||
my_bool b = true;
|
my_bool b = true;
|
||||||
char *str = NULL;
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
|
PJVAL jvp;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
PGLOBAL gb = GetMemPtr(g, args, 0);
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
str = (char*)g->Activityp;
|
str = (char*)g->Activityp;
|
||||||
@@ -3540,18 +3538,11 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
else
|
else
|
||||||
w = 0;
|
w = 0;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p, *path;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
PJVAL jvp;
|
|
||||||
PGLOBAL gb = GetMemPtr(g, args, 0);
|
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||||
*is_null = 1;
|
*error = 1;
|
||||||
return NULL;
|
goto fin;
|
||||||
} // endif jump_level
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||||
@@ -3561,6 +3552,10 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} // endif rc
|
} // endif rc
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true, false, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
goto err;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
@@ -3612,7 +3607,6 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
if (!str) {
|
if (!str) {
|
||||||
@@ -3807,7 +3801,7 @@ my_bool jfile_make_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
char *jfile_make(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jfile_make(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *)
|
unsigned long *res_length, char *is_null, char *)
|
||||||
{
|
{
|
||||||
char *p, *str, *msg, *fn = NULL;
|
char *p, *msg, *str = NULL, *fn = NULL;
|
||||||
int n, pretty = 2;
|
int n, pretty = 2;
|
||||||
PJSON jsp;
|
PJSON jsp;
|
||||||
PJVAL jvp;
|
PJVAL jvp;
|
||||||
@@ -3831,6 +3825,10 @@ char *jfile_make(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
fn = args->args[0];
|
fn = args->args[0];
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
goto fin;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
@@ -3838,7 +3836,7 @@ char *jfile_make(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
// Is this a file name?
|
// Is this a file name?
|
||||||
if (!(p = GetJsonFile(g, p))) {
|
if (!(p = GetJsonFile(g, p))) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
return NULL;
|
goto fin;
|
||||||
} else
|
} else
|
||||||
fn = jvp->GetString();
|
fn = jvp->GetString();
|
||||||
|
|
||||||
@@ -3846,7 +3844,7 @@ char *jfile_make(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
|
|
||||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
return NULL;
|
goto fin;
|
||||||
} // endif jsp
|
} // endif jsp
|
||||||
|
|
||||||
jvp->SetValue(jsp);
|
jvp->SetValue(jsp);
|
||||||
@@ -3965,7 +3963,7 @@ char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PBSON bsp = (PBSON)g->Xchk;
|
PBSON bsp = (PBSON)g->Xchk;
|
||||||
|
|
||||||
if (!bsp || bsp->Changed) {
|
if (!bsp || bsp->Changed) {
|
||||||
if (!CheckMemory(g, initid, args, args->arg_count, false)) {
|
if (!CheckMemory(g, initid, args, args->arg_count, true)) {
|
||||||
char *p;
|
char *p;
|
||||||
PJSON top;
|
PJSON top;
|
||||||
PJAR arp;
|
PJAR arp;
|
||||||
@@ -4042,7 +4040,7 @@ char *jbin_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
return (char*)bsp;
|
return (char*)bsp;
|
||||||
} // endif bsp
|
} // endif bsp
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 2, false, true)) {
|
if (!CheckMemory(g, initid, args, 2, false, false, true)) {
|
||||||
int *x = NULL;
|
int *x = NULL;
|
||||||
uint n = 2;
|
uint n = 2;
|
||||||
// PJSON jsp;
|
// PJSON jsp;
|
||||||
@@ -4111,7 +4109,7 @@ char *jbin_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
return (char*)bsp;
|
return (char*)bsp;
|
||||||
} // endif bsp
|
} // endif bsp
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false, true)) {
|
if (!CheckMemory(g, initid, args, 1, false, false, true)) {
|
||||||
int *x;
|
int *x;
|
||||||
uint n = 1;
|
uint n = 1;
|
||||||
PJAR arp;
|
PJAR arp;
|
||||||
@@ -4224,7 +4222,7 @@ char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PBSON bsp = (PBSON)g->Xchk;
|
PBSON bsp = (PBSON)g->Xchk;
|
||||||
|
|
||||||
if (!bsp || bsp->Changed) {
|
if (!bsp || bsp->Changed) {
|
||||||
if (!CheckMemory(g, initid, args, args->arg_count, true)) {
|
if (!CheckMemory(g, initid, args, args->arg_count, false, true)) {
|
||||||
PJVAL jvp;
|
PJVAL jvp;
|
||||||
PJOB objp = new(g)JOBJECT;
|
PJOB objp = new(g)JOBJECT;
|
||||||
|
|
||||||
@@ -4281,7 +4279,7 @@ char *jbin_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PBSON bsp = (PBSON)g->Xchk;
|
PBSON bsp = (PBSON)g->Xchk;
|
||||||
|
|
||||||
if (!bsp || bsp->Changed) {
|
if (!bsp || bsp->Changed) {
|
||||||
if (!CheckMemory(g, initid, args, args->arg_count, true)) {
|
if (!CheckMemory(g, initid, args, args->arg_count, false, true)) {
|
||||||
PJOB objp = new(g)JOBJECT;
|
PJOB objp = new(g)JOBJECT;
|
||||||
|
|
||||||
for (uint i = 0; i < args->arg_count; i += 2)
|
for (uint i = 0; i < args->arg_count; i += 2)
|
||||||
@@ -4335,7 +4333,7 @@ char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
return (char*)bsp;
|
return (char*)bsp;
|
||||||
} // endif bsp
|
} // endif bsp
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 2, false, true)) {
|
if (!CheckMemory(g, initid, args, 2, false, true, true)) {
|
||||||
char *key;
|
char *key;
|
||||||
PJOB jobp;
|
PJOB jobp;
|
||||||
PJVAL jvp = MakeValue(g, args, 0, &top);
|
PJVAL jvp = MakeValue(g, args, 0, &top);
|
||||||
@@ -4401,7 +4399,7 @@ char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
return (char*)bsp;
|
return (char*)bsp;
|
||||||
} // endif bsp
|
} // endif bsp
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false, true)) {
|
if (!CheckMemory(g, initid, args, 1, false, true, true)) {
|
||||||
char *key;
|
char *key;
|
||||||
PJOB jobp;
|
PJOB jobp;
|
||||||
PJVAL jvp = MakeValue(g, args, 0, &top);
|
PJVAL jvp = MakeValue(g, args, 0, &top);
|
||||||
@@ -4458,7 +4456,7 @@ char *jbin_object_list(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PBSON bsp = (PBSON)g->Xchk;
|
PBSON bsp = (PBSON)g->Xchk;
|
||||||
|
|
||||||
if (!bsp || bsp->Changed) {
|
if (!bsp || bsp->Changed) {
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
if (!CheckMemory(g, initid, args, 1, true, true)) {
|
||||||
char *p;
|
char *p;
|
||||||
PJSON jsp;
|
PJSON jsp;
|
||||||
PJVAL jvp = MakeValue(g, args, 0);
|
PJVAL jvp = MakeValue(g, args, 0);
|
||||||
@@ -4514,8 +4512,12 @@ my_bool jbin_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
char *p, *path;
|
||||||
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
|
PJVAL jvp;
|
||||||
PBSON bsp = NULL;
|
PBSON bsp = NULL;
|
||||||
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
bsp = (PBSON)g->Activityp;
|
bsp = (PBSON)g->Activityp;
|
||||||
@@ -4523,19 +4525,17 @@ char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p, *path;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
PJVAL jvp;
|
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
goto fin;
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
return NULL;
|
goto fin;
|
||||||
} // endif jsp
|
} // endif jsp
|
||||||
|
|
||||||
} else
|
} else
|
||||||
@@ -4554,8 +4554,7 @@ char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
|
|
||||||
if (jsx->SetJpath(g, path, false)) {
|
if (jsx->SetJpath(g, path, false)) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
*is_null = 1;
|
goto fin;
|
||||||
return NULL;
|
|
||||||
} // endif SetJpath
|
} // endif SetJpath
|
||||||
|
|
||||||
// Get the json tree
|
// Get the json tree
|
||||||
@@ -4573,8 +4572,6 @@ char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Activityp = (PACTIVITY)bsp;
|
g->Activityp = (PACTIVITY)bsp;
|
||||||
|
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
if (!bsp) {
|
if (!bsp) {
|
||||||
*is_null = 1;
|
*is_null = 1;
|
||||||
@@ -4611,7 +4608,7 @@ char *jbin_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
return (char*)bsp;
|
return (char*)bsp;
|
||||||
} // endif bsp
|
} // endif bsp
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 2, false, true)) {
|
if (!CheckMemory(g, initid, args, 2, false, false, true)) {
|
||||||
PJVAL jvp;
|
PJVAL jvp;
|
||||||
PJSON jsp[2] = {NULL, NULL};
|
PJSON jsp[2] = {NULL, NULL};
|
||||||
PGLOBAL gb = GetMemPtr(g, args, 0);
|
PGLOBAL gb = GetMemPtr(g, args, 0);
|
||||||
@@ -4666,10 +4663,15 @@ my_bool jbin_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
|
char *p, *path;
|
||||||
int w;
|
int w;
|
||||||
my_bool b = true;
|
my_bool b = true;
|
||||||
|
PJSON jsp;
|
||||||
|
PJSNX jsx;
|
||||||
|
PJVAL jvp;
|
||||||
PBSON bsp = NULL;
|
PBSON bsp = NULL;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
PGLOBAL gb = GetMemPtr(g, args, 0);
|
||||||
|
|
||||||
if (g->N) {
|
if (g->N) {
|
||||||
bsp = (PBSON)g->Activityp;
|
bsp = (PBSON)g->Activityp;
|
||||||
@@ -4684,20 +4686,16 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
else
|
else
|
||||||
w = 0;
|
w = 0;
|
||||||
|
|
||||||
if (!CheckMemory(g, initid, args, 1, false)) {
|
|
||||||
char *p, *path;
|
|
||||||
PJSON jsp;
|
|
||||||
PJSNX jsx;
|
|
||||||
PJVAL jvp;
|
|
||||||
PGLOBAL gb = GetMemPtr(g, args, 0);
|
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
|
if (CheckMemory(g, initid, args, 1, true, false, true)) {
|
||||||
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
return NULL;
|
goto fin;
|
||||||
} // endif jsp
|
} // endif jsp
|
||||||
|
|
||||||
} else
|
} else
|
||||||
@@ -4740,8 +4738,6 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Activityp = (PACTIVITY)bsp;
|
g->Activityp = (PACTIVITY)bsp;
|
||||||
|
|
||||||
} // endif CheckMemory
|
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
if (!bsp) {
|
if (!bsp) {
|
||||||
*is_null = 1;
|
*is_null = 1;
|
||||||
|
Reference in New Issue
Block a user