diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2021-05-01 22:29:38 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2021-05-01 22:29:38 +0200 |
commit | ef0829ef40eb4136eed4282057baa4126dd66b69 (patch) | |
tree | 9d68776c559eaed1c6f4dd1764ebe21cd22c7bb2 /storage/connect/json.cpp | |
parent | 4df6952ce3e778c8f4d1d638350d4155281c1618 (diff) | |
download | mariadb-git-ef0829ef40eb4136eed4282057baa4126dd66b69.tar.gz |
- Major update of the json/bson/mongo table types programs.
Fix several bugs, chiefly concerning CURL operations.
modified: storage/connect/bson.cpp
modified: storage/connect/cmgfam.cpp
modified: storage/connect/cmgoconn.cpp
modified: storage/connect/cmgoconn.h
modified: storage/connect/colblk.h
modified: storage/connect/ha_connect.cc
modified: storage/connect/jmgfam.cpp
modified: storage/connect/jmgoconn.cpp
modified: storage/connect/jmgoconn.h
modified: storage/connect/json.cpp
modified: storage/connect/json.h
modified: storage/connect/mysql-test/connect/r/bson_mongo_c.result
modified: storage/connect/mysql-test/connect/r/json_mongo_c.result
modified: storage/connect/mysql-test/connect/r/mongo_c.result
modified: storage/connect/mysql-test/connect/r/mongo_java_2.result
modified: storage/connect/mysql-test/connect/r/mongo_java_3.result
modified: storage/connect/mysql-test/connect/std_data/Mongo2.jar
modified: storage/connect/mysql-test/connect/std_data/Mongo3.jar
modified: storage/connect/tabbson.cpp
modified: storage/connect/tabbson.h
modified: storage/connect/tabcmg.cpp
modified: storage/connect/tabcmg.h
modified: storage/connect/tabjmg.cpp
modified: storage/connect/tabjmg.h
modified: storage/connect/tabjson.cpp
modified: storage/connect/tabjson.h
Diffstat (limited to 'storage/connect/json.cpp')
-rw-r--r-- | storage/connect/json.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index f65294429db..b1f9f10957b 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -78,6 +78,24 @@ bool IsNum(PSZ s) } // end of IsNum /***********************************************************************/ +/* IsArray: check whether this is a Mongo array path. */ +/***********************************************************************/ +bool IsArray(PSZ s) +{ + char* p = s; + + if (!p || !*p) + return false; + else for (; *p; p++) + if (*p == '.') + break; + else if (!isdigit(*p)) + return false; + + return true; +} // end of IsArray + +/***********************************************************************/ /* NextChr: return the first found '[' or Sep pointer. */ /***********************************************************************/ char* NextChr(PSZ s, char sep) @@ -1326,9 +1344,9 @@ bool JARRAY::Merge(PGLOBAL g, PJSON jsp) } // end of Merge /***********************************************************************/ -/* Set the nth Value of the Array Value list. */ +/* Set the nth Value of the Array Value list or add it. */ /***********************************************************************/ -bool JARRAY::SetArrayValue(PGLOBAL g, PJVAL jvp, int n) +void JARRAY::SetArrayValue(PGLOBAL g, PJVAL jvp, int n) { int i = 0; PJVAL jp, *jpp = &First; @@ -1339,7 +1357,6 @@ bool JARRAY::SetArrayValue(PGLOBAL g, PJVAL jvp, int n) *jpp = jvp; jvp->Next = (jp ? jp->Next : NULL); - return false; } // end of SetValue /***********************************************************************/ @@ -1417,7 +1434,7 @@ bool JARRAY::IsNull(void) /***********************************************************************/ JVALUE::JVALUE(PJSON jsp) : JSON() { - if (jsp->GetType() == TYPE_JVAL) { + if (jsp && jsp->GetType() == TYPE_JVAL) { PJVAL jvp = (PJVAL)jsp; // Val = ((PJVAL)jsp)->GetVal(); @@ -1434,7 +1451,7 @@ JVALUE::JVALUE(PJSON jsp) : JSON() } else { Jsp = jsp; // Val = NULL; - DataType = TYPE_JSON; + DataType = Jsp ? TYPE_JSON : TYPE_NULL; Nd = 0; } // endif Type |