Commit 7ab30f5d authored by Olivier Bertrand's avatar Olivier Bertrand

Update bson_get_item modified: bsonudf.cpp

parent 848a1a61
...@@ -3693,8 +3693,8 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3693,8 +3693,8 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
{ {
char *path, *str = NULL; char *path, *str = NULL;
PBVAL jvp; PBVAL jvp;
PBJNX bxp = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
BJNX bnx(g, NULL, TYPE_STRING, initid->max_length);
if (g->N) { if (g->N) {
str = (char*)g->Activityp; str = (char*)g->Activityp;
...@@ -3707,8 +3707,6 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3707,8 +3707,6 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
PUSH_WARNING("CheckMemory error"); PUSH_WARNING("CheckMemory error");
goto fin; goto fin;
} else { } else {
BJNX bnx(g);
jvp = bnx.MakeValue(args, 0, true); jvp = bnx.MakeValue(args, 0, true);
if (g->Mrr) { // First argument is a constant if (g->Mrr) { // First argument is a constant
...@@ -3722,16 +3720,16 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3722,16 +3720,16 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
jvp = (PBVAL)g->Xchk; jvp = (PBVAL)g->Xchk;
path = MakePSZ(g, args, 1); path = MakePSZ(g, args, 1);
bxp = new(g) BJNX(g, jvp, TYPE_STRING, initid->max_length);
if (bxp->SetJpath(g, path, true)) { if (bnx.SetJpath(g, path, true)) {
PUSH_WARNING(g->Message);
goto fin; goto fin;
} else } else
bxp->ReadValue(g); jvp = bnx.GetRowValue(g, jvp, 0);
if (!bxp->GetValue()->IsNull()) if (!bnx.IsJson(jvp)) {
str = bxp->GetValue()->GetCharValue(); strcpy(g->Message, "Not a Json item");
} else
str = bnx.Serialize(g, jvp, NULL, 0);
if (initid->const_item) if (initid->const_item)
// Keep result of constant function // Keep result of constant function
...@@ -3739,6 +3737,7 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3739,6 +3737,7 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
fin: fin:
if (!str) { if (!str) {
PUSH_WARNING(g->Message);
*is_null = 1; *is_null = 1;
*res_length = 0; *res_length = 0;
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment