summaryrefslogtreecommitdiff
path: root/storage/connect/tabjson.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2017-10-15 16:13:23 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2017-10-15 16:13:23 +0200
commitbcfb5b2de94e31ebcff165d60ec25e5d49a6045c (patch)
tree937c1623162dbada1fca1e4fee2fa8103e9f3de4 /storage/connect/tabjson.cpp
parentbf34e9db7be5baf64d131ce7c793be77172e4ed2 (diff)
downloadmariadb-git-bcfb5b2de94e31ebcff165d60ec25e5d49a6045c.tar.gz
- Update version number
modified: storage/connect/ha_connect.cc - Include MONGO in all Java enabled distributions Mongo will be enabled only for 10.2 and 10.3 modified: storage/connect/CMakeLists.txt - Change JDBC_SUPPORT to JAVA_SUPPORT which also replaces MONGO_SUPPORT MONGO_SUPPORT is now just used to enable the MONGO table type modified: storage/connect/filter.cpp modified: storage/connect/ha_connect.cc modified: storage/connect/ha_connect.h modified: storage/connect/mongo.cpp modified: storage/connect/mycat.cc modified: storage/connect/plgdbutl.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h - Move MakeSelector function from FILTER to mongo.cpp modified: storage/connect/filter.cpp modified: storage/connect/filter.h modified: storage/connect/cmgoconn.cpp modified: storage/connect/jmgoconn.cpp modified: storage/connect/mongo.cpp - Do mongo_init only on first use of the MongoDB C Driver This will permit to delay load the mongo lib on Windows modified: storage/connect/cmgoconn.cpp modified: storage/connect/cmgoconn.h modified: storage/connect/ha_connect.cc - Replace NEW_VAR by a test on MYSQL_VERSION_ID modified: storage/connect/ha_connect.cc - Suppress enable_mongo session variable modified: storage/connect/ha_connect.cc modified: storage/connect/mycat.cc - Make some function headers identical in .h and .cc file (replacing const char* by PCSZ) modified: storage/connect/ha_connect.cc modified: storage/connect/ha_connect.h - Change a parameter type from uchar* to const uchar* (for ScanRecord and CheckRecord) modified: storage/connect/ha_connect.cc modified: storage/connect/ha_connect.h - Changes on LIKE and NOT LIKE does not fix a bug yet modified: storage/connect/ha_connect.cc - Suppress PIVOT_SUPPORT (PIVOT type is unconditionnal) modified: storage/connect/ha_connect.cc modified: storage/connect/mycat.cc - Change the strz function from inline to static modified: storage/connect/ha_connect.cc modified: storage/connect/ha_connect.h - export the JavaConn class and the MgoColumns and IsNum functions modified: storage/connect/javaconn.h modified: storage/connect/json.h modified: storage/connect/mongo.h - Fix MDEV-13924 modified: storage/connect/jdbconn.cpp - Make a temporary fix for the compiler bug in CalculateArray modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjson.cpp - Typo modified: storage/connect/jdbccat.h modified: storage/connect/reldef.h modified: storage/connect/tabext.h modified: storage/connect/tabjmg.cpp modified: storage/connect/tabxml.h modified: storage/connect/valblk.h modified: storage/connect/value.h modified: storage/connect/xtable.h - Fix a bug in MONGO tests by changing 'MONGO' to $TYPE modified: storage/connect/mysql-test/connect/t/mongo_test.inc - Record test results to reflect all changes modified: storage/connect/mysql-test/connect/r/json_java_2.result modified: storage/connect/mysql-test/connect/r/json_java_3.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
Diffstat (limited to 'storage/connect/tabjson.cpp')
-rw-r--r--storage/connect/tabjson.cpp66
1 files changed, 31 insertions, 35 deletions
diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp
index 401441520da..94c089aeeb6 100644
--- a/storage/connect/tabjson.cpp
+++ b/storage/connect/tabjson.cpp
@@ -31,14 +31,12 @@
#if defined(ZIP_SUPPORT)
#include "filamzip.h"
#endif // ZIP_SUPPORT
-#if defined(MONGO_SUPPORT)
-#if defined(JDBC_SUPPORT)
+#if defined(JAVA_SUPPORT)
#include "jmgfam.h"
-#endif // JDBC_SUPPORT
+#endif // JAVA_SUPPORT
#if defined(CMGO_SUPPORT)
#include "cmgfam.h"
#endif // CMGO_SUPPORT
-#endif // MONGO_SUPPORT
#include "tabmul.h"
#include "checklvl.h"
#include "resource.h"
@@ -149,7 +147,7 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
tdp->Fn, tdp->Objname, tdp->Pretty, lvl);
if (tdp->Uri) {
-#if defined(MONGO_SUPPORT)
+#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
tdp->Collname = GetStringTableOption(g, topt, "Name", NULL);
tdp->Collname = GetStringTableOption(g, topt, "Tabname", tdp->Collname);
tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test");
@@ -157,10 +155,8 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false);
tdp->Driver = (PSZ)GetStringTableOption(g, topt, "Driver", NULL);
tdp->Version = GetIntegerTableOption(g, topt, "Version", 3);
-#if defined(JDBC_SUPPORT)
tdp->Wrapname = (PSZ)GetStringTableOption(g, topt, "Wrapper",
(tdp->Version == 2) ? "Mongo2Interface" : "Mongo3Interface");
-#endif // JDBC_SUPPORT
tdp->Pretty = 0;
#else // !MONGO_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
@@ -201,7 +197,6 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
return NULL;
#endif // !ZIP_SUPPORT
} else if (tdp->Uri) {
-#if defined(MONGO_SUPPORT)
if (tdp->Driver && toupper(*tdp->Driver) == 'C') {
#if defined(CMGO_SUPPORT)
tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp));
@@ -210,7 +205,7 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
return NULL;
#endif
} else if (tdp->Driver && toupper(*tdp->Driver) == 'J') {
-#if defined(JDBC_SUPPORT)
+#if defined(JAVA_SUPPORT)
tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp));
#else
sprintf(g->Message, "Mongo %s Driver not available", "Java");
@@ -219,14 +214,14 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
} else { // Driver not specified
#if defined(CMGO_SUPPORT)
tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp));
-#else
+#elif defined(JAVA_SUPPORT)
tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp));
+#else
+ sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
+ return NULL;
#endif
} // endif Driver
-#else
- sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
- return NULL;
-#endif // MONGO_SUPPORT
+
} else
tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp));
@@ -497,16 +492,12 @@ JSONDEF::JSONDEF(void)
Base = 0;
Strict = false;
Sep = '.';
-#if defined(MONGO_SUPPORT)
Uri = NULL;
Collname = Options = Filter = NULL;
Pipe = false;
Driver = NULL;
Version = 0;
-#if defined(JDBC_SUPPORT)
Wrapname = NULL;
-#endif // JDBC_SUPPORT
-#endif // MONGO_SUPPORT
} // end of JSONDEF constructor
/***********************************************************************/
@@ -524,7 +515,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
Sep = *GetStringCatInfo(g, "Separator", ".");
if (Uri = GetStringCatInfo(g, "Connect", NULL)) {
-#if defined(MONGO_SUPPORT)
+#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
Collname = GetStringCatInfo(g, "Name",
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
Collname = GetStringCatInfo(g, "Tabname", Collname);
@@ -534,12 +525,12 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
Driver = GetStringCatInfo(g, "Driver", NULL);
Version = GetIntCatInfo("Version", 3);
Pretty = 0;
-#if defined(JDBC_SUPPORT)
+#if defined(JAVA_SUPPORT)
if (Version == 2)
Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo2Interface");
else
Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo3Interface");
-#endif // JDBC_SUPPORT
+#endif // JAVA_SUPPORT
#else // !MONGO_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
return true;
@@ -569,7 +560,6 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
(m == MODE_UPDATE || m == MODE_DELETE));
if (Uri) {
-#if defined(MONGO_SUPPORT)
if (Driver && toupper(*Driver) == 'C') {
#if defined(CMGO_SUPPORT)
txfp = new(g) CMGFAM(this);
@@ -578,7 +568,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
return NULL;
#endif
} else if (Driver && toupper(*Driver) == 'J') {
-#if defined(JDBC_SUPPORT)
+#if defined(JAVA_SUPPORT)
txfp = new(g) JMGFAM(this);
#else
sprintf(g->Message, "Mongo %s Driver not available", "Java");
@@ -587,14 +577,14 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
} else { // Driver not specified
#if defined(CMGO_SUPPORT)
txfp = new(g) CMGFAM(this);
-#else
+#elif defined(JAVA_SUPPORT)
txfp = new(g) JMGFAM(this);
-#endif
+#else // !MONGO_SUPPORT
+ sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
+ return NULL;
+#endif // !MONGO_SUPPORT
} // endif Driver
-#else
- sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
- return NULL;
-#endif // MONGO_SUPPORT
+
} else if (Zipped) {
#if defined(ZIP_SUPPORT)
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
@@ -1591,8 +1581,7 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n)
/***********************************************************************/
PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
{
-//int i, ars, nv = 0, nextsame = Tjp->NextSame;
- int i, nv = 0, nextsame = Tjp->NextSame;
+ int i, ars, nv = 0, nextsame = Tjp->NextSame;
bool err;
OPVAL op = Nodes[n].Op;
PVAL val[2], vp = Nodes[n].Valp;
@@ -1600,12 +1589,20 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
JVALUE jval;
vp->Reset();
-//ars = MY_MIN(Tjp->Limit, arp->size());
+ ars = MY_MIN(Tjp->Limit, arp->size());
+
+ if (trace)
+ htrc("CalculateArray size=%d\n", ars);
+ else // This is temporary until we find a better way to fix the compiler
+ htrc(""); // bug sometime causing the next loop to be executed only once.
-//for (i = 0; i < ars; i++) {
- for (i = 0; i < arp->size(); i++) {
+ for (i = 0; i < ars; i++) {
jvrp = arp->GetValue(i);
+ if (trace)
+ htrc("i=%d Value %s null=%d nv=%d\n",
+ i, jvrp->GetString(g), jvrp->IsNull() ? 1 : 0, nv);
+
if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do {
if (jvrp->IsNull()) {
jvrp->Value = AllocateValue(g, GetJsonNull(), TYPE_STRING);
@@ -1623,7 +1620,6 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
} else
SetJsonValue(g, MulVal, jvp, n);
-// if (!MulVal->IsZero()) {
if (!MulVal->IsNull()) {
switch (op) {
case OP_CNC: