summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2021-01-29 15:45:08 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2021-01-29 15:45:08 +0100
commit7ab30f5d95e1214e52b631d01a21494c6eb33c2f (patch)
tree7799f0c6797a6a7bf0cd0e04108ca247103ad79c
parent848a1a613c103209e4f2fb5d02572237d46832a1 (diff)
downloadmariadb-git-7ab30f5d95e1214e52b631d01a21494c6eb33c2f.tar.gz
Update bson_get_item modified: bsonudf.cpp
-rw-r--r--storage/connect/bsonudf.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/storage/connect/bsonudf.cpp b/storage/connect/bsonudf.cpp
index b8f4f9699d4..0a9d3813aeb 100644
--- a/storage/connect/bsonudf.cpp
+++ b/storage/connect/bsonudf.cpp
@@ -3693,8 +3693,8 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
{
char *path, *str = NULL;
PBVAL jvp;
- PBJNX bxp = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr;
+ BJNX bnx(g, NULL, TYPE_STRING, initid->max_length);
if (g->N) {
str = (char*)g->Activityp;
@@ -3707,8 +3707,6 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
PUSH_WARNING("CheckMemory error");
goto fin;
} else {
- BJNX bnx(g);
-
jvp = bnx.MakeValue(args, 0, true);
if (g->Mrr) { // First argument is a constant
@@ -3722,16 +3720,16 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
jvp = (PBVAL)g->Xchk;
path = MakePSZ(g, args, 1);
- bxp = new(g) BJNX(g, jvp, TYPE_STRING, initid->max_length);
- if (bxp->SetJpath(g, path, true)) {
- PUSH_WARNING(g->Message);
+ if (bnx.SetJpath(g, path, true)) {
goto fin;
} else
- bxp->ReadValue(g);
+ jvp = bnx.GetRowValue(g, jvp, 0);
- if (!bxp->GetValue()->IsNull())
- str = bxp->GetValue()->GetCharValue();
+ if (!bnx.IsJson(jvp)) {
+ strcpy(g->Message, "Not a Json item");
+ } else
+ str = bnx.Serialize(g, jvp, NULL, 0);
if (initid->const_item)
// Keep result of constant function
@@ -3739,6 +3737,7 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
fin:
if (!str) {
+ PUSH_WARNING(g->Message);
*is_null = 1;
*res_length = 0;
} else