Skip to content

Commit

Permalink
- Update version number
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
Buggynours committed Oct 17, 2017
1 parent 3da90fd commit c07064d
Show file tree
Hide file tree
Showing 36 changed files with 403 additions and 448 deletions.
24 changes: 9 additions & 15 deletions storage/connect/CMakeLists.txt
Expand Up @@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
# Definitions that are shared for all OSes
#
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT )
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT )


#
Expand Down Expand Up @@ -245,9 +245,9 @@ int main() {
ENDIF(CONNECT_WITH_ODBC)

#
# JDBC with MongoDB Java Driver included but disabled
# JDBC with MongoDB Java Driver included but disabled if without MONGO
#
OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON)
# OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON)
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON)

IF(CONNECT_WITH_JDBC)
Expand All @@ -260,17 +260,16 @@ IF(CONNECT_WITH_JDBC)
# SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY}) will be dynamically linked
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
javaconn.cpp jdbconn.cpp tabjdbc.cpp
jmgfam.cpp jmgoconn.cpp mongo.cpp tabjmg.cpp
jdbccat.h javaconn.h jdbconn.h tabjdbc.h
jmgfam.h jmgoconn.h mongo.h tabjmg.h
JdbcInterface.java ApacheInterface.java MariadbInterface.java
MysqlInterface.java OracleInterface.java PostgresqlInterface.java
Mongo2Interface.java Mongo3Interface.java
JavaWrappers.jar)
add_definitions(-DJDBC_SUPPORT)
add_definitions(-DJAVA_SUPPORT)
IF(CONNECT_WITH_MONGO)
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
jmgfam.cpp jmgoconn.cpp mongo.cpp tabjmg.cpp
jmgfam.h jmgoconn.h mongo.h tabjmg.h
Mongo2Interface.java Mongo3Interface.java)
add_definitions(-DMONGO_SUPPORT -DMONGO_ENABLED=0)
add_definitions(-DMONGO_SUPPORT)
ENDIF()
ELSE()
SET(JDBC_LIBRARY "")
Expand Down Expand Up @@ -313,10 +312,7 @@ IF(CONNECT_WITH_MONGO)
add_definitions(-DCMGO_SUPPORT)
IF (NOT JAVA_FOUND AND JNI_FOUND)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} mongo.cpp mongo.h)
add_definitions(-DMONGO_SUPPORT -DMONGO_ENABLED=1)
ELSE ()
remove_definitions(-DMONGO_ENABLED=0)
add_definitions(-DMONGO_ENABLED=1)
add_definitions(-DMONGO_SUPPORT)
ENDIF (NOT JAVA_FOUND AND JNI_FOUND)
ENDIF(libmongoc-1.0_FOUND)
ENDIF(CONNECT_WITH_MONGO)
Expand Down Expand Up @@ -371,5 +367,3 @@ IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND)
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
ENDIF()



65 changes: 42 additions & 23 deletions storage/connect/cmgoconn.cpp
Expand Up @@ -22,17 +22,10 @@
#include "filter.h"
#include "cmgoconn.h"

bool IsNum(PSZ s);

// Required to initialize libmongoc's internals
void mongo_init(bool init)
{
if (init)
mongoc_init();
else
mongoc_cleanup();
bool CMgoConn::IsInit = false;

} // end of mongo_init
bool IsNum(PSZ s);
bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);

/* --------------------------- Class INCOL --------------------------- */

Expand Down Expand Up @@ -139,11 +132,36 @@ CMgoConn::CMgoConn(PGLOBAL g, PCPARM pcg)
m_Connected = false;
} // end of CMgoConn standard constructor

/***********************************************************************/
/* Required to initialize libmongoc's internals. */
/***********************************************************************/
void CMgoConn::mongo_init(bool init)
{
if (init)
mongoc_init();
else if (IsInit)
mongoc_cleanup();

IsInit = init;
} // end of mongo_init

/***********************************************************************/
/* Connect to the MongoDB server and get the collection. */
/***********************************************************************/
bool CMgoConn::Connect(PGLOBAL g)
{
if (!IsInit)
#if defined(__WIN__)
__try {
mongo_init(true);
} __except (EXCEPTION_EXECUTE_HANDLER) {
strcpy(g->Message, "Cannot load MongoDB C driver");
return true;
} // end try/except
#else // !__WIN__
mongo_init(true);
#endif // !__WIN__

Uri = mongoc_uri_new(Pcg->Uristr);

if (!Uri) {
Expand Down Expand Up @@ -240,12 +258,13 @@ int CMgoConn::CollSize(PGLOBAL g)
/***********************************************************************/
bool CMgoConn::MakeCursor(PGLOBAL g)
{
const char *p;
bool id, b = false, all = false;
PCSZ options = Pcg->Options;
PTDB tp = Pcg->Tdbp;
PCOL cp;
PSTRG s = NULL;
const char *p;
bool id, b = false, all = false;
PCSZ options = Pcg->Options;
PTDB tp = Pcg->Tdbp;
PCOL cp;
PSTRG s = NULL;
PFIL filp = tp->GetFilter();

id = (tp->GetMode() != MODE_READ);

Expand Down Expand Up @@ -274,10 +293,10 @@ bool CMgoConn::MakeCursor(PGLOBAL g)

s = new(g) STRING(g, 1023, (PSZ)options);

if (tp->GetFilter()) {
if (filp) {
s->Append(",{\"$match\":");

if (tp->GetFilter()->MakeSelector(g, s)) {
if (MakeSelector(g, filp, s)) {
strcpy(g->Message, "Failed making selector");
return true;
} else
Expand Down Expand Up @@ -330,27 +349,27 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
} // endif error

} else {
if (Pcg->Filter || tp->GetFilter()) {
if (Pcg->Filter || filp) {
if (trace) {
if (Pcg->Filter)
htrc("Filter: %s\n", Pcg->Filter);

if (tp->GetFilter()) {
if (filp) {
char buf[512];

tp->GetFilter()->Prints(g, buf, 511);
filp->Prints(g, buf, 511);
htrc("To_Filter: %s\n", buf);
} // endif To_Filter

} // endif trace

s = new(g) STRING(g, 1023, (PSZ)Pcg->Filter);

if (tp->GetFilter()) {
if (filp) {
if (Pcg->Filter)
s->Append(',');

if (tp->GetFilter()->MakeSelector(g, s)) {
if (MakeSelector(g, filp, s)) {
strcpy(g->Message, "Failed making selector");
return NULL;
} // endif Selector
Expand Down
2 changes: 2 additions & 0 deletions storage/connect/cmgoconn.h
Expand Up @@ -93,6 +93,7 @@ class CMgoConn : public BLOCK {
PSZ Mini(PGLOBAL g, PCOL colp, const bson_t *bson, bool b);
void GetColumnValue(PGLOBAL g, PCOL colp);
bool AddValue(PGLOBAL g, PCOL colp, bson_t *doc, char *key, bool upd);
static void mongo_init(bool init);

protected:
// Members
Expand All @@ -112,4 +113,5 @@ class CMgoConn : public BLOCK {
PINCOL Fpc; // To insert INCOL classes
PFBLOCK fp;
bool m_Connected;
static bool IsInit;
}; // end of class CMgoConn
85 changes: 1 addition & 84 deletions storage/connect/filter.cpp
Expand Up @@ -10,7 +10,7 @@
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
#include "sql_class.h"
//#include "sql_class.h"
//#include "sql_time.h"

#if defined(__WIN__)
Expand All @@ -35,9 +35,6 @@
#include "array.h"
#include "filter.h"
#include "xindex.h"
#if defined(MONGO_SUPPORT) || defined(JDBC_SUPPORT)
#include "tabext.h"
#endif // MONGO_SUPPORT || JDBC_SUPPORT

/***********************************************************************/
/* Utility routines. */
Expand Down Expand Up @@ -1406,86 +1403,6 @@ PFIL FILTER::Copy(PTABS t)
} // end of Copy
#endif // 0

#if defined(MONGO_SUPPORT)
/***********************************************************************/
/* Make selector json representation for Mongo tables. */
/***********************************************************************/
bool FILTER::MakeSelector(PGLOBAL g, PSTRG s)
{
s->Append('{');

if (Opc == OP_AND || Opc == OP_OR) {
if (GetArgType(0) != TYPE_FILTER || GetArgType(1) != TYPE_FILTER)
return true;

s->Append("\"$");
s->Append(Opc == OP_AND ? "and" : "or");
s->Append("\":[");

if (((PFIL)Arg(0))->MakeSelector(g, s))
return true;

s->Append(',');

if (((PFIL)Arg(1))->MakeSelector(g, s))
return true;

s->Append(']');
} else {
if (GetArgType(0) != TYPE_COLBLK)
return true;

s->Append('"');
s->Append(((PCOL)Arg(0))->GetJpath(g, false));
s->Append("\":{\"$");

switch (Opc) {
case OP_EQ:
s->Append("eq");
break;
case OP_NE:
s->Append("ne");
break;
case OP_GT:
s->Append("gt");
break;
case OP_GE:
s->Append("gte");
break;
case OP_LT:
s->Append("lt");
break;
case OP_LE:
s->Append("lte");
break;
case OP_NULL:
case OP_LIKE:
case OP_EXIST:
default:
return true;
} // endswitch Opc

s->Append("\":");

if (GetArgType(1) == TYPE_COLBLK) {
s->Append("\"$");
s->Append(((PEXTCOL)Arg(1))->GetJpath(g, false));
s->Append('"');
} else {
char buf[501];

Arg(1)->Prints(g, buf, 500);
s->Append(buf);
} // endif Type

s->Append('}');
} // endif Opc

s->Append('}');
return false;
} // end of MakeSelector
#endif // MONGO_SUPPORT

/*********************************************************************/
/* Make file output of FILTER contents. */
/*********************************************************************/
Expand Down
3 changes: 0 additions & 3 deletions storage/connect/filter.h
Expand Up @@ -61,9 +61,6 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */
//virtual PXOB CheckSubQuery(PGLOBAL, PSQL);
//virtual bool CheckLocal(PTDB);
//virtual int CheckSpcCol(PTDB tdbp, int n);
#if defined(MONGO_SUPPORT)
bool MakeSelector(PGLOBAL g, PSTRG s);
#endif // MONGO_SUPPORT
virtual void Printf(PGLOBAL g, FILE *f, uint n);
virtual void Prints(PGLOBAL g, char *ps, uint z);
// PFIL Linearize(bool nosep);
Expand Down

0 comments on commit c07064d

Please sign in to comment.