Commit 678fb208 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'connect/10.2' into 10.2

parents 58b56f14 60fa113f
...@@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h) ...@@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
# Definitions that are shared for all OSes # Definitions that are shared for all OSes
# #
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS) add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT ) add_definitions( -DNEW_MAR -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT )
# #
...@@ -247,11 +247,8 @@ ENDIF(CONNECT_WITH_ODBC) ...@@ -247,11 +247,8 @@ ENDIF(CONNECT_WITH_ODBC)
# #
# JDBC and MongoDB Java Driver # JDBC and MongoDB Java Driver
# #
IF(APPLE) OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON)
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine without JDBC support" OFF) OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON)
ELSE()
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON)
ENDIF()
IF(CONNECT_WITH_JDBC) IF(CONNECT_WITH_JDBC)
FIND_PACKAGE(Java 1.6) FIND_PACKAGE(Java 1.6)
...@@ -263,12 +260,9 @@ IF(CONNECT_WITH_JDBC) ...@@ -263,12 +260,9 @@ IF(CONNECT_WITH_JDBC)
# SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY}) will be dynamically linked # SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY}) will be dynamically linked
SET(CONNECT_SOURCES ${CONNECT_SOURCES} SET(CONNECT_SOURCES ${CONNECT_SOURCES}
javaconn.cpp jdbconn.cpp tabjdbc.cpp javaconn.cpp jdbconn.cpp tabjdbc.cpp
jmgoconn.cpp jmgfam.cpp mongo.cpp tabjmg.cpp
jdbccat.h javaconn.h jdbconn.h tabjdbc.h jdbccat.h javaconn.h jdbconn.h tabjdbc.h
jmgoconn.h jmgfam.h mongo.h tabjmg.h
JdbcInterface.java ApacheInterface.java MariadbInterface.java JdbcInterface.java ApacheInterface.java MariadbInterface.java
MysqlInterface.java OracleInterface.java PostgresqlInterface.java MysqlInterface.java OracleInterface.java PostgresqlInterface.java
Mongo2Interface.java Mongo3Interface.java
JavaWrappers.jar) JavaWrappers.jar)
# TODO: Find how to compile and install the java wrapper classes # TODO: Find how to compile and install the java wrapper classes
# Find required libraries and include directories # Find required libraries and include directories
...@@ -278,6 +272,13 @@ IF(CONNECT_WITH_JDBC) ...@@ -278,6 +272,13 @@ IF(CONNECT_WITH_JDBC)
${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
add_definitions(-DJDBC_SUPPORT) add_definitions(-DJDBC_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)
ENDIF()
ELSE() ELSE()
SET(JDBC_LIBRARY "") SET(JDBC_LIBRARY "")
ENDIF() ENDIF()
...@@ -299,8 +300,6 @@ ENDIF(CONNECT_WITH_ZIP) ...@@ -299,8 +300,6 @@ ENDIF(CONNECT_WITH_ZIP)
# MONGO C Driver (CMAKE NOT YET WORKING) # MONGO C Driver (CMAKE NOT YET WORKING)
# #
#OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON)
#IF(CONNECT_WITH_MONGO) #IF(CONNECT_WITH_MONGO)
# IF(WIN32) # IF(WIN32)
# # Adding some typical places to search in # # Adding some typical places to search in
...@@ -311,17 +310,18 @@ ENDIF(CONNECT_WITH_ZIP) ...@@ -311,17 +310,18 @@ ENDIF(CONNECT_WITH_ZIP)
# C:/mongo-c-driver/lib # C:/mongo-c-driver/lib
# D:/mongo-c-driver/lib) # D:/mongo-c-driver/lib)
# ENDIF(WIN32) # ENDIF(WIN32)
# FIND_PACKAGE(libmongoc) # FIND_PACKAGE(libmongoc 1.7)
# IF (MONGO_FOUND) # IF (MONGO_FOUND)
# INCLUDE_DIRECTORIES(${MONGO_INCLUDE_DIR}) # INCLUDE_DIRECTORIES(${MONGO_INCLUDE_DIR})
# SET(MONGO_LIBRARY ${MONGO_LIBRARIES}) # SET(MONGO_LIBRARY ${MONGO_LIBRARIES})
# SET(CONNECT_SOURCES ${CONNECT_SOURCES} # SET(CONNECT_SOURCES ${CONNECT_SOURCES}
# cmgoconn.cpp mongofam.cpp tabmgo.cpp # cmgoconn.cpp cmgfam.cpp tabcmg.cpp
# cmgoconn.h mongofam.h tabmgo.h) # cmgoconn.h cmgfam.h tabcmg.h)
# add_definitions(-DCMGO_SUPPORT)
# IF (NOT JAVA_FOUND AND JNI_FOUND) # IF (NOT JAVA_FOUND AND JNI_FOUND)
# SET(CONNECT_SOURCES ${CONNECT_SOURCES} mongo.cpp mongo.h) # SET(CONNECT_SOURCES ${CONNECT_SOURCES} mongo.cpp mongo.h)
# add_definitions(-DMONGO_SUPPORT)
# ENDIF (NOT JAVA_FOUND AND JNI_FOUND) # ENDIF (NOT JAVA_FOUND AND JNI_FOUND)
# add_definitions(-DMONGO_SUPPORT)
# ENDIF(MONGO_FOUND) # ENDIF(MONGO_FOUND)
#ENDIF(CONNECT_WITH_MONGO) #ENDIF(CONNECT_WITH_MONGO)
......
This diff was suppressed by a .gitattributes entry.
/************ MONGO FAM C++ Program Source Code File (.CPP) ************/ /************** CMGFAM C++ Program Source Code File (.CPP) *************/
/* PROGRAM NAME: mongofam.cpp */ /* PROGRAM NAME: cmgfam.cpp */
/* ------------- */ /* ------------- */
/* Version 1.3 */ /* Version 1.4 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
...@@ -30,18 +30,18 @@ ...@@ -30,18 +30,18 @@
#include "filamtxt.h" #include "filamtxt.h"
#include "tabdos.h" #include "tabdos.h"
#include "tabjson.h" #include "tabjson.h"
#include "mongofam.h" #include "cmgfam.h"
#if defined(UNIX) || defined(UNIV_LINUX) #if defined(UNIX) || defined(UNIV_LINUX)
#include "osutil.h" #include "osutil.h"
#endif #endif
/* --------------------------- Class MGOFAM -------------------------- */ /* --------------------------- Class CMGFAM -------------------------- */
/***********************************************************************/ /***********************************************************************/
/* Constructors. */ /* Constructors. */
/***********************************************************************/ /***********************************************************************/
MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL) CMGFAM::CMGFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
{ {
Cmgp = NULL; Cmgp = NULL;
Pcg.Tdbp = NULL; Pcg.Tdbp = NULL;
...@@ -66,20 +66,20 @@ MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL) ...@@ -66,20 +66,20 @@ MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
Mode = MODE_ANY; Mode = MODE_ANY;
Done = false; Done = false;
Lrecl = tdp->Lrecl + tdp->Ending; Lrecl = tdp->Lrecl + tdp->Ending;
} // end of MGOFAM standard constructor } // end of CMGFAM standard constructor
MGOFAM::MGOFAM(PMGOFAM tdfp) : DOSFAM(tdfp) CMGFAM::CMGFAM(PCMGFAM tdfp) : DOSFAM(tdfp)
{ {
Pcg = tdfp->Pcg; Pcg = tdfp->Pcg;
To_Fbt = tdfp->To_Fbt; To_Fbt = tdfp->To_Fbt;
Mode = tdfp->Mode; Mode = tdfp->Mode;
Done = tdfp->Done; Done = tdfp->Done;
} // end of MGOFAM copy constructor } // end of CMGFAM copy constructor
/***********************************************************************/ /***********************************************************************/
/* Reset: reset position values at the beginning of file. */ /* Reset: reset position values at the beginning of file. */
/***********************************************************************/ /***********************************************************************/
void MGOFAM::Reset(void) void CMGFAM::Reset(void)
{ {
TXTFAM::Reset(); TXTFAM::Reset();
Fpos = Tpos = Spos = 0; Fpos = Tpos = Spos = 0;
...@@ -88,7 +88,7 @@ void MGOFAM::Reset(void) ...@@ -88,7 +88,7 @@ void MGOFAM::Reset(void)
/***********************************************************************/ /***********************************************************************/
/* MGO GetFileLength: returns file size in number of bytes. */ /* MGO GetFileLength: returns file size in number of bytes. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::GetFileLength(PGLOBAL g) int CMGFAM::GetFileLength(PGLOBAL g)
{ {
return 0; return 0;
} // end of GetFileLength } // end of GetFileLength
...@@ -98,7 +98,7 @@ int MGOFAM::GetFileLength(PGLOBAL g) ...@@ -98,7 +98,7 @@ int MGOFAM::GetFileLength(PGLOBAL g)
/* This function can be called with a null argument to test the */ /* This function can be called with a null argument to test the */
/* availability of Cardinality implementation (1 yes, 0 no). */ /* availability of Cardinality implementation (1 yes, 0 no). */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::Cardinality(PGLOBAL g) int CMGFAM::Cardinality(PGLOBAL g)
{ {
if (!g) if (!g)
return 1; return 1;
...@@ -109,7 +109,7 @@ int MGOFAM::Cardinality(PGLOBAL g) ...@@ -109,7 +109,7 @@ int MGOFAM::Cardinality(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Note: This function is not really implemented yet. */ /* Note: This function is not really implemented yet. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::MaxBlkSize(PGLOBAL, int s) int CMGFAM::MaxBlkSize(PGLOBAL, int s)
{ {
return s; return s;
} // end of MaxBlkSize } // end of MaxBlkSize
...@@ -117,7 +117,7 @@ int MGOFAM::MaxBlkSize(PGLOBAL, int s) ...@@ -117,7 +117,7 @@ int MGOFAM::MaxBlkSize(PGLOBAL, int s)
/***********************************************************************/ /***********************************************************************/
/* Init: initialize MongoDB processing. */ /* Init: initialize MongoDB processing. */
/***********************************************************************/ /***********************************************************************/
bool MGOFAM::Init(PGLOBAL g) bool CMGFAM::Init(PGLOBAL g)
{ {
if (Done) if (Done)
return false; return false;
...@@ -141,7 +141,7 @@ bool MGOFAM::Init(PGLOBAL g) ...@@ -141,7 +141,7 @@ bool MGOFAM::Init(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* OpenTableFile: Open a MongoDB table. */ /* OpenTableFile: Open a MongoDB table. */
/***********************************************************************/ /***********************************************************************/
bool MGOFAM::OpenTableFile(PGLOBAL g) bool CMGFAM::OpenTableFile(PGLOBAL g)
{ {
Mode = Tdbp->GetMode(); Mode = Tdbp->GetMode();
...@@ -165,7 +165,7 @@ bool MGOFAM::OpenTableFile(PGLOBAL g) ...@@ -165,7 +165,7 @@ bool MGOFAM::OpenTableFile(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* GetRowID: return the RowID of last read record. */ /* GetRowID: return the RowID of last read record. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::GetRowID(void) int CMGFAM::GetRowID(void)
{ {
return Rows; return Rows;
} // end of GetRowID } // end of GetRowID
...@@ -173,7 +173,7 @@ int MGOFAM::GetRowID(void) ...@@ -173,7 +173,7 @@ int MGOFAM::GetRowID(void)
/***********************************************************************/ /***********************************************************************/
/* GetPos: return the position of last read record. */ /* GetPos: return the position of last read record. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::GetPos(void) int CMGFAM::GetPos(void)
{ {
return Fpos; return Fpos;
} // end of GetPos } // end of GetPos
...@@ -181,7 +181,7 @@ int MGOFAM::GetPos(void) ...@@ -181,7 +181,7 @@ int MGOFAM::GetPos(void)
/***********************************************************************/ /***********************************************************************/
/* GetNextPos: return the position of next record. */ /* GetNextPos: return the position of next record. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::GetNextPos(void) int CMGFAM::GetNextPos(void)
{ {
return Fpos; // TODO return Fpos; // TODO
} // end of GetNextPos } // end of GetNextPos
...@@ -189,7 +189,7 @@ int MGOFAM::GetNextPos(void) ...@@ -189,7 +189,7 @@ int MGOFAM::GetNextPos(void)
/***********************************************************************/ /***********************************************************************/
/* SetPos: Replace the table at the specified position. */ /* SetPos: Replace the table at the specified position. */
/***********************************************************************/ /***********************************************************************/
bool MGOFAM::SetPos(PGLOBAL g, int pos) bool CMGFAM::SetPos(PGLOBAL g, int pos)
{ {
Fpos = pos; Fpos = pos;
Placed = true; Placed = true;
...@@ -199,25 +199,25 @@ bool MGOFAM::SetPos(PGLOBAL g, int pos) ...@@ -199,25 +199,25 @@ bool MGOFAM::SetPos(PGLOBAL g, int pos)
/***********************************************************************/ /***********************************************************************/
/* Record file position in case of UPDATE or DELETE. */ /* Record file position in case of UPDATE or DELETE. */
/***********************************************************************/ /***********************************************************************/
bool MGOFAM::RecordPos(PGLOBAL g) bool CMGFAM::RecordPos(PGLOBAL g)
{ {
strcpy(g->Message, "MGOFAM::RecordPos NIY"); strcpy(g->Message, "CMGFAM::RecordPos NIY");
return true; return true;
} // end of RecordPos } // end of RecordPos
/***********************************************************************/ /***********************************************************************/
/* Initialize Fpos and the current position for indexed DELETE. */ /* Initialize Fpos and the current position for indexed DELETE. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::InitDelete(PGLOBAL g, int fpos, int spos) int CMGFAM::InitDelete(PGLOBAL g, int fpos, int spos)
{ {
strcpy(g->Message, "MGOFAM::InitDelete NIY"); strcpy(g->Message, "CMGFAM::InitDelete NIY");
return RC_FX; return RC_FX;
} // end of InitDelete } // end of InitDelete
/***********************************************************************/ /***********************************************************************/
/* Skip one record in file. */ /* Skip one record in file. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::SkipRecord(PGLOBAL g, bool header) int CMGFAM::SkipRecord(PGLOBAL g, bool header)
{ {
return RC_OK; // Dummy return RC_OK; // Dummy
} // end of SkipRecord } // end of SkipRecord
...@@ -225,7 +225,7 @@ int MGOFAM::SkipRecord(PGLOBAL g, bool header) ...@@ -225,7 +225,7 @@ int MGOFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/ /***********************************************************************/
/* ReadBuffer: Get next document from a collection. */ /* ReadBuffer: Get next document from a collection. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::ReadBuffer(PGLOBAL g) int CMGFAM::ReadBuffer(PGLOBAL g)
{ {
int rc = Cmgp->ReadNext(g); int rc = Cmgp->ReadNext(g);
...@@ -239,7 +239,7 @@ int MGOFAM::ReadBuffer(PGLOBAL g) ...@@ -239,7 +239,7 @@ int MGOFAM::ReadBuffer(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* WriteBuffer: File write routine for MGO access method. */ /* WriteBuffer: File write routine for MGO access method. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::WriteBuffer(PGLOBAL g) int CMGFAM::WriteBuffer(PGLOBAL g)
{ {
return Cmgp->Write(g); return Cmgp->Write(g);
} // end of WriteBuffer } // end of WriteBuffer
...@@ -247,7 +247,7 @@ int MGOFAM::WriteBuffer(PGLOBAL g) ...@@ -247,7 +247,7 @@ int MGOFAM::WriteBuffer(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Data Base delete line routine for MGO and BLK access methods. */ /* Data Base delete line routine for MGO and BLK access methods. */
/***********************************************************************/ /***********************************************************************/
int MGOFAM::DeleteRecords(PGLOBAL g, int irc) int CMGFAM::DeleteRecords(PGLOBAL g, int irc)
{ {
return (irc == RC_OK) ? WriteBuffer(g) : RC_OK; return (irc == RC_OK) ? WriteBuffer(g) : RC_OK;
} // end of DeleteRecords } // end of DeleteRecords
...@@ -255,7 +255,7 @@ int MGOFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -255,7 +255,7 @@ int MGOFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
/* Table file close routine for MGO access method. */ /* Table file close routine for MGO access method. */
/***********************************************************************/ /***********************************************************************/
void MGOFAM::CloseTableFile(PGLOBAL g, bool) void CMGFAM::CloseTableFile(PGLOBAL g, bool)
{ {
Cmgp->Close(); Cmgp->Close();
Done = false; Done = false;
...@@ -264,7 +264,7 @@ void MGOFAM::CloseTableFile(PGLOBAL g, bool) ...@@ -264,7 +264,7 @@ void MGOFAM::CloseTableFile(PGLOBAL g, bool)
/***********************************************************************/ /***********************************************************************/
/* Rewind routine for MGO access method. */ /* Rewind routine for MGO access method. */
/***********************************************************************/ /***********************************************************************/
void MGOFAM::Rewind(void) void CMGFAM::Rewind(void)
{ {
Cmgp->Rewind(); Cmgp->Rewind();
} // end of Rewind } // end of Rewind
......
/************** MongoFam H Declares Source Code File (.H) **************/ /*************** CMGFam H Declares Source Code File (.H) ***************/
/* Name: mongofam.h Version 1.4 */ /* Name: cmgfam.h Version 1.5 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2017 */ /* (C) Copyright to the author Olivier BERTRAND 2017 */
/* */ /* */
...@@ -8,19 +8,19 @@ ...@@ -8,19 +8,19 @@
#include "cmgoconn.h" #include "cmgoconn.h"
typedef class TXTFAM *PTXF; typedef class TXTFAM *PTXF;
typedef class MGOFAM *PMGOFAM; typedef class CMGFAM *PCMGFAM;
typedef class MGODEF *PMGODEF; typedef class MGODEF *PMGODEF;
typedef class TDBMGO *PTDBMGO; typedef class TDBCMG *PTDBCMG;
/***********************************************************************/ /***********************************************************************/
/* This is the MongoDB Access Method class declaration. */ /* This is the MongoDB Access Method class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport MGOFAM : public DOSFAM { class DllExport CMGFAM : public DOSFAM {
friend void mongo_init(bool); friend void mongo_init(bool);
public: public:
// Constructor // Constructor
MGOFAM(PJDEF tdp); CMGFAM(PJDEF tdp);
MGOFAM(PMGOFAM txfp); CMGFAM(PCMGFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) { return TYPE_AM_MGO; } virtual AMT GetAmType(void) { return TYPE_AM_MGO; }
...@@ -28,7 +28,7 @@ class DllExport MGOFAM : public DOSFAM { ...@@ -28,7 +28,7 @@ class DllExport MGOFAM : public DOSFAM {
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
void SetTdbp(PTDBDOS tdbp) { Tdbp = tdbp; } void SetTdbp(PTDBDOS tdbp) { Tdbp = tdbp; }
virtual PTXF Duplicate(PGLOBAL g) { return (PTXF)new(g) MGOFAM(this); } virtual PTXF Duplicate(PGLOBAL g) { return (PTXF)new(g) CMGFAM(this); }
void SetLrecl(int lrecl) { Lrecl = lrecl; } void SetLrecl(int lrecl) { Lrecl = lrecl; }
// Methods // Methods
...@@ -61,5 +61,5 @@ class DllExport MGOFAM : public DOSFAM { ...@@ -61,5 +61,5 @@ class DllExport MGOFAM : public DOSFAM {
PFBLOCK To_Fbt; // Pointer to temp file block PFBLOCK To_Fbt; // Pointer to temp file block
MODE Mode; MODE Mode;
bool Done; // Init done bool Done; // Init done
}; // end of class MGOFAM }; // end of class CMGFAM
...@@ -92,6 +92,32 @@ void INCOL::AddCol(PGLOBAL g, PCOL colp, char *jp) ...@@ -92,6 +92,32 @@ void INCOL::AddCol(PGLOBAL g, PCOL colp, char *jp)
} // end of AddCol } // end of AddCol
/***********************************************************************/
/* Clear. */
/***********************************************************************/
void INCOL::Init(void)
{
bson_init(Child);
for (PKC kp = Klist; kp; kp = kp->Next)
if (kp->Incolp)
kp->Incolp->Init();
} // end of init
/***********************************************************************/
/* Destroy. */
/***********************************************************************/
void INCOL::Destroy(void)
{
bson_destroy(Child);
for (PKC kp = Klist; kp; kp = kp->Next)
if (kp->Incolp)
kp->Incolp->Destroy();
} // end of Destroy
/* -------------------------- Class CMgoConn ------------------------- */ /* -------------------------- Class CMgoConn ------------------------- */
/***********************************************************************/ /***********************************************************************/
...@@ -109,6 +135,7 @@ CMgoConn::CMgoConn(PGLOBAL g, PCPARM pcg) ...@@ -109,6 +135,7 @@ CMgoConn::CMgoConn(PGLOBAL g, PCPARM pcg)
Query = NULL; Query = NULL;
Opts = NULL; Opts = NULL;
Fpc = NULL; Fpc = NULL;
fp = NULL;
m_Connected = false; m_Connected = false;
} // end of CMgoConn standard constructor } // end of CMgoConn standard constructor
...@@ -149,6 +176,24 @@ bool CMgoConn::Connect(PGLOBAL g) ...@@ -149,6 +176,24 @@ bool CMgoConn::Connect(PGLOBAL g)
return true; return true;
} // endif Collection } // endif Collection
/*********************************************************************/
/* Link a Fblock. This make possible to automatically close it */
/* in case of error (throw). */
/*********************************************************************/
PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr;
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
fp->Type = TYPE_FB_MONGO;
fp->Fname = NULL;
fp->Next = dbuserp->Openlist;
dbuserp->Openlist = fp;
fp->Count = 1;
fp->Length = 0;
fp->Memory = NULL;
fp->Mode = MODE_ANY;
fp->File = this;
fp->Handle = 0;
m_Connected = true; m_Connected = true;
return false; return false;
} // end of Connect } // end of Connect
...@@ -493,19 +538,19 @@ bool CMgoConn::DocWrite(PGLOBAL g, PINCOL icp) ...@@ -493,19 +538,19 @@ bool CMgoConn::DocWrite(PGLOBAL g, PINCOL icp)
bool isdoc = !kp->Incolp->Array; bool isdoc = !kp->Incolp->Array;
if (isdoc) if (isdoc)
BSON_APPEND_DOCUMENT_BEGIN(&icp->Child, kp->Key, &kp->Incolp->Child); BSON_APPEND_DOCUMENT_BEGIN(icp->Child, kp->Key, kp->Incolp->Child);
else else
BSON_APPEND_ARRAY_BEGIN(&icp->Child, kp->Key, &kp->Incolp->Child); BSON_APPEND_ARRAY_BEGIN(icp->Child, kp->Key, kp->Incolp->Child);
if (DocWrite(g, kp->Incolp)) if (DocWrite(g, kp->Incolp))
return true; return true;
if (isdoc) if (isdoc)
bson_append_document_end(&icp->Child, &kp->Incolp->Child); bson_append_document_end(icp->Child, kp->Incolp->Child);
else else
bson_append_array_end(&icp->Child, &kp->Incolp->Child); bson_append_array_end(icp->Child, kp->Incolp->Child);
} else if (AddValue(g, kp->Colp, &icp->Child, kp->Key, false)) } else if (AddValue(g, kp->Colp, icp->Child, kp->Key, false))
return true; return true;
return false; return false;
...@@ -520,19 +565,19 @@ int CMgoConn::Write(PGLOBAL g) ...@@ -520,19 +565,19 @@ int CMgoConn::Write(PGLOBAL g)
PTDB tp = Pcg->Tdbp; PTDB tp = Pcg->Tdbp;
if (tp->GetMode() == MODE_INSERT) { if (tp->GetMode() == MODE_INSERT) {
bson_init(&Fpc->Child); Fpc->Init();
if (DocWrite(g, Fpc)) if (DocWrite(g, Fpc))
return RC_FX; return RC_FX;
if (trace) { if (trace) {
char *str = bson_as_json(&Fpc->Child, NULL); char *str = bson_as_json(Fpc->Child, NULL);
htrc("Inserting: %s\n", str); htrc("Inserting: %s\n", str);
bson_free(str); bson_free(str);
} // endif trace } // endif trace
if (!mongoc_collection_insert(Collection, MONGOC_INSERT_NONE, if (!mongoc_collection_insert(Collection, MONGOC_INSERT_NONE,
&Fpc->Child, NULL, &Error)) { Fpc->Child, NULL, &Error)) {
sprintf(g->Message, "Mongo insert: %s", Error.message); sprintf(g->Message, "Mongo insert: %s", Error.message);
rc = RC_FX; rc = RC_FX;
} // endif insert } // endif insert
...@@ -641,6 +686,8 @@ void CMgoConn::Close(void) ...@@ -641,6 +686,8 @@ void CMgoConn::Close(void)
if (Client) mongoc_client_pool_push(Pool, Client); if (Client) mongoc_client_pool_push(Pool, Client);
if (Pool) mongoc_client_pool_destroy(Pool); if (Pool) mongoc_client_pool_destroy(Pool);
if (Uri) mongoc_uri_destroy(Uri); if (Uri) mongoc_uri_destroy(Uri);
if (Fpc) Fpc->Destroy();
if (fp) fp->Count = 0;
} // end of Close } // end of Close
/***********************************************************************/ /***********************************************************************/
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <mongoc.h> #include <mongoc.h>
// C connection to a MongoDB data source // C connection to a MongoDB data source
class TDBMGO; class TDBCMG;
class MGOCOL; class MGOCOL;
/***********************************************************************/ /***********************************************************************/
...@@ -18,7 +18,7 @@ class MGOCOL; ...@@ -18,7 +18,7 @@ class MGOCOL;
/***********************************************************************/ /***********************************************************************/
typedef class INCOL *PINCOL; typedef class INCOL *PINCOL;
typedef class MGODEF *PMGODEF; typedef class MGODEF *PMGODEF;
typedef class TDBMGO *PTDBMGO; typedef class TDBCMG *PTDBCMG;
typedef class MGOCOL *PMGOCOL; typedef class MGOCOL *PMGOCOL;
typedef struct mongo_parms { typedef struct mongo_parms {
...@@ -48,23 +48,25 @@ typedef struct KEYCOL { ...@@ -48,23 +48,25 @@ typedef struct KEYCOL {
class INCOL : public BLOCK { class INCOL : public BLOCK {
public: public:
// Constructor // Constructor
INCOL(bool ar) { Klist = NULL; Array = ar; } INCOL(bool ar) { Child = bson_new(); Klist = NULL; Array = ar; }
// Methods // Methods
void AddCol(PGLOBAL g, PCOL colp, char *jp); void AddCol(PGLOBAL g, PCOL colp, char *jp);
void Init(void);
void Destroy(void);
//Members //Members
bson_t Child; bson_t *Child;
PKC Klist; PKC Klist;
bool Array; bool Array;
}; // end of INCOL; }; // end of INCOL;
/***********************************************************************/ /***********************************************************************/
/* CMgoConn class. */ /* CMgoConn class. */
/***********************************************************************/ /***********************************************************************/
class CMgoConn : public BLOCK { class CMgoConn : public BLOCK {
friend class TDBMGO; friend class TDBCMG;
friend class MGODISC; friend class CMGDISC;
public: public:
// Constructor // Constructor
CMgoConn(PGLOBAL g, PCPARM pcg); CMgoConn(PGLOBAL g, PCPARM pcg);
...@@ -108,5 +110,6 @@ class CMgoConn : public BLOCK { ...@@ -108,5 +110,6 @@ class CMgoConn : public BLOCK {
bson_iter_t Iter; // Used to retrieve column value bson_iter_t Iter; // Used to retrieve column value
bson_iter_t Desc; // Descendant iter bson_iter_t Desc; // Descendant iter
PINCOL Fpc; // To insert INCOL classes PINCOL Fpc; // To insert INCOL classes
PFBLOCK fp;
bool m_Connected; bool m_Connected;
}; // end of class CMgoConn }; // end of class CMgoConn
...@@ -66,8 +66,10 @@ PGLOBAL CntExit(PGLOBAL g) ...@@ -66,8 +66,10 @@ PGLOBAL CntExit(PGLOBAL g)
if (g) { if (g) {
CntEndDB(g); CntEndDB(g);
if (g->Activityp) if (g->Activityp) {
delete g->Activityp; delete g->Activityp;
g->Activityp = NULL;
} // endif Activityp
PlugExit(g); PlugExit(g);
g= NULL; g= NULL;
...@@ -80,7 +82,7 @@ PGLOBAL CntExit(PGLOBAL g) ...@@ -80,7 +82,7 @@ PGLOBAL CntExit(PGLOBAL g)
/* CntEndDB: DB termination semantic routine. */ /* CntEndDB: DB termination semantic routine. */
/***********************************************************************/ /***********************************************************************/
void CntEndDB(PGLOBAL g) void CntEndDB(PGLOBAL g)
{ {
PDBUSER dbuserp= PlgGetUser(g); PDBUSER dbuserp= PlgGetUser(g);
if (dbuserp) { if (dbuserp) {
...@@ -88,9 +90,14 @@ void CntEndDB(PGLOBAL g) ...@@ -88,9 +90,14 @@ void CntEndDB(PGLOBAL g)
delete dbuserp->Catalog; delete dbuserp->Catalog;
free(dbuserp); free(dbuserp);
} // endif dbuserp
} // end of CntEndDB if (trace)
htrc("CntEndDB: Freeing Dup\n");
g->Activityp->Aptr = NULL;
} // endif dbuserp
} // end of CntEndDB
/***********************************************************************/ /***********************************************************************/
/* CntCheckDB: Initialize a DB application session. */ /* CntCheckDB: Initialize a DB application session. */
......
...@@ -290,6 +290,9 @@ void ZIPUTIL::close() ...@@ -290,6 +290,9 @@ void ZIPUTIL::close()
zipfile = NULL; zipfile = NULL;
} // endif zipfile } // endif zipfile
if (fp)
fp->Count = 0;
} // end of close } // end of close
/***********************************************************************/ /***********************************************************************/
...@@ -493,6 +496,9 @@ void UNZIPUTL::close() ...@@ -493,6 +496,9 @@ void UNZIPUTL::close()
zipfile = NULL; zipfile = NULL;
} // endif zipfile } // endif zipfile
if (fp)
fp->Count = 0;
} // end of close } // end of close
/***********************************************************************/ /***********************************************************************/
......
...@@ -1406,7 +1406,7 @@ PFIL FILTER::Copy(PTABS t) ...@@ -1406,7 +1406,7 @@ PFIL FILTER::Copy(PTABS t)
} // end of Copy } // end of Copy
#endif // 0 #endif // 0
#if defined(MONGO_SUPPORT) || defined(JDBC_SUPPORT) #if defined(MONGO_SUPPORT)
/***********************************************************************/ /***********************************************************************/
/* Make selector json representation for Mongo tables. */ /* Make selector json representation for Mongo tables. */
/***********************************************************************/ /***********************************************************************/
...@@ -1484,7 +1484,7 @@ bool FILTER::MakeSelector(PGLOBAL g, PSTRG s) ...@@ -1484,7 +1484,7 @@ bool FILTER::MakeSelector(PGLOBAL g, PSTRG s)
s->Append('}'); s->Append('}');
return false; return false;
} // end of MakeSelector } // end of MakeSelector
#endif // MONGO_SUPPORT || JDBC_SUPPORT #endif // MONGO_SUPPORT
/*********************************************************************/ /*********************************************************************/
/* Make file output of FILTER contents. */ /* Make file output of FILTER contents. */
......
...@@ -61,9 +61,9 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */ ...@@ -61,9 +61,9 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */
//virtual PXOB CheckSubQuery(PGLOBAL, PSQL); //virtual PXOB CheckSubQuery(PGLOBAL, PSQL);
//virtual bool CheckLocal(PTDB); //virtual bool CheckLocal(PTDB);
//virtual int CheckSpcCol(PTDB tdbp, int n); //virtual int CheckSpcCol(PTDB tdbp, int n);
#if defined(MONGO_SUPPORT) || defined(JDBC_SUPPORT) #if defined(MONGO_SUPPORT)
bool MakeSelector(PGLOBAL g, PSTRG s); bool MakeSelector(PGLOBAL g, PSTRG s);
#endif // MONGO_SUPPORT || JDBC_SUPPORT #endif // MONGO_SUPPORT
virtual void Printf(PGLOBAL g, FILE *f, uint n); virtual void Printf(PGLOBAL g, FILE *f, uint n);
virtual void Prints(PGLOBAL g, char *ps, uint z); virtual void Prints(PGLOBAL g, char *ps, uint z);
// PFIL Linearize(bool nosep); // PFIL Linearize(bool nosep);
......
...@@ -58,31 +58,10 @@ ...@@ -58,31 +58,10 @@
/* Miscellaneous Constants */ /* Miscellaneous Constants */
/***********************************************************************/ /***********************************************************************/
#define NO_IVAL -95684275 /* Used by GetIntegerOption */ #define NO_IVAL -95684275 /* Used by GetIntegerOption */
#define VMLANG 370 /* Size of olf VM lang blocks */
#define MAX_JUMP 24 /* Maximum jump level number */ #define MAX_JUMP 24 /* Maximum jump level number */
#define MAX_STR 4160 /* Maximum message length */ #define MAX_STR 4160 /* Maximum message length */
#define STR_SIZE 501 /* Length of char strings. */
#define STD_INPUT 0 /* Standard language input */
#define STD_OUTPUT 1 /* Standard language output */
#define ERROR_OUTPUT 2 /* Error message output */
#define DEBUG_OUTPUT 3 /* Debug info output */
#define PROMPT_OUTPUT 4 /* Prompt message output */
#define COPY_OUTPUT 5 /* Copy of language input */
#define STD_MSG 6 /* System message file */
#define DEBUG_MSG 7 /* Debug message file */
#define DUMMY 0 /* Dummy file index in Ldm block */
#define STDIN 1 /* stdin file index in Ldm block */
#define STDOUT 2 /* stdout file index in Ldm block */
#define STDERR 3 /* stderr file index in Ldm block */
#define STDEBUG 4 /* debug file index in Ldm block */
#define STDPRN 5 /* stdprn file index in Ldm block */
#define STDFREE 6 /* Free file index in Ldm block */
#define TYPE_SEM -2 /* Returned semantic function */
#define TYPE_DFONC -2 /* Indirect sem ref in FPARM */
#define TYPE_VOID -1 #define TYPE_VOID -1
#define TYPE_SBPAR -1 /* Phrase reference in FPARM */
#define TYPE_SEMX 0 /* Initial semantic function type? */
#define TYPE_ERROR 0 #define TYPE_ERROR 0
#define TYPE_STRING 1 #define TYPE_STRING 1
#define TYPE_DOUBLE 2 #define TYPE_DOUBLE 2
...@@ -96,22 +75,6 @@ ...@@ -96,22 +75,6 @@
#define TYPE_BIN 10 #define TYPE_BIN 10
#define TYPE_PCHAR 11 #define TYPE_PCHAR 11
#if defined(OS32)
#define SYS_STAMP "OS32"
#elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
#define SYS_STAMP "UNIX"
#elif defined(OS16)
#define SYS_STAMP "OS16"
#elif defined(DOSR)
#define SYS_STAMP "DOSR"
#elif defined(WIN)
#define SYS_STAMP "WIN1"
#elif defined(__WIN__)
#define SYS_STAMP "WIN2"
#else
#define SYS_STAMP "XXXX"
#endif
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
...@@ -119,11 +82,6 @@ extern "C" { ...@@ -119,11 +82,6 @@ extern "C" {
/***********************************************************************/ /***********************************************************************/
/* Static variables */ /* Static variables */
/***********************************************************************/ /***********************************************************************/
#if defined(STORAGE)
char sys_stamp[5] = SYS_STAMP;
#else
extern char sys_stamp[];
#endif
/***********************************************************************/ /***********************************************************************/
/* File-Selection Indicators */ /* File-Selection Indicators */
......
This diff is collapsed.
...@@ -166,8 +166,8 @@ class ha_connect: public handler ...@@ -166,8 +166,8 @@ class ha_connect: public handler
~ha_connect(); ~ha_connect();
// CONNECT Implementation // CONNECT Implementation
static bool connect_init(void); //static bool connect_init(void);
static bool connect_end(void); //static bool connect_end(void);
TABTYPE GetRealType(PTOS pos= NULL); TABTYPE GetRealType(PTOS pos= NULL);
char *GetRealString(PCSZ s); char *GetRealString(PCSZ s);
PCSZ GetStringOption(PCSZ opname, PCSZ sdef= NULL); PCSZ GetStringOption(PCSZ opname, PCSZ sdef= NULL);
......
...@@ -124,6 +124,7 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper) ...@@ -124,6 +124,7 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper)
m_Wrap = strcat(strcpy(wn, "wrappers/"), m_Wrap); m_Wrap = strcat(strcpy(wn, "wrappers/"), m_Wrap);
} // endif m_Wrap } // endif m_Wrap
fp = NULL;
m_Opened = false; m_Opened = false;
m_Connected = false; m_Connected = false;
m_Rows = 0; m_Rows = 0;
...@@ -567,6 +568,24 @@ bool JAVAConn::Open(PGLOBAL g) ...@@ -567,6 +568,24 @@ bool JAVAConn::Open(PGLOBAL g)
return true; return true;
} // endif Check } // endif Check
/*********************************************************************/
/* Link a Fblock. This make possible to automatically close it */
/* in case of error (throw). */
/*********************************************************************/
PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr;
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
fp->Type = TYPE_FB_JAVA;
fp->Fname = NULL;
fp->Next = dbuserp->Openlist;
dbuserp->Openlist = fp;
fp->Count = 1;
fp->Length = 0;
fp->Memory = NULL;
fp->Mode = MODE_ANY;
fp->File = this;
fp->Handle = 0;
m_Opened = true; m_Opened = true;
return false; return false;
} // end of Open } // end of Open
...@@ -595,5 +614,8 @@ void JAVAConn::Close() ...@@ -595,5 +614,8 @@ void JAVAConn::Close()
if ((rc = jvm->DetachCurrentThread()) != JNI_OK) if ((rc = jvm->DetachCurrentThread()) != JNI_OK)
printf("DetachCurrentThread: rc=%d\n", (int)rc); printf("DetachCurrentThread: rc=%d\n", (int)rc);
if (fp)
fp->Count = 0;
m_Opened = false; m_Opened = false;
} // end of Close } // end of Close
...@@ -25,18 +25,16 @@ ...@@ -25,18 +25,16 @@
//efine MAX_DNAME_LEN 256 // Max size of Recordset names //efine MAX_DNAME_LEN 256 // Max size of Recordset names
//efine MAX_CONNECT_LEN 512 // Max size of Connect string //efine MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name //efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE 0 // TYPE_NULL //efine DEFAULT_FIELD_TYPE 0 // TYPE_NULL
#if !defined(__WIN__) #if !defined(__WIN__)
typedef unsigned char *PUCHAR; typedef unsigned char *PUCHAR;
#endif // !__WIN__ #endif // !__WIN__
enum JCATINFO { enum JCATINFO {
CAT_TAB = 1, // JDBC Tables JCAT_TAB = 1, // JDBC Tables
CAT_COL = 2, // JDBC Columns JCAT_COL = 2, // JDBC Columns
CAT_KEY = 3, // JDBC PrimaryKeys JCAT_KEY = 3, // JDBC PrimaryKeys
//CAT_STAT = 4, // SQLStatistics
//CAT_SPC = 5 // SQLSpecialColumns
}; };
/***********************************************************************/ /***********************************************************************/
...@@ -63,6 +61,7 @@ class JAVAConn; ...@@ -63,6 +61,7 @@ class JAVAConn;
/***********************************************************************/ /***********************************************************************/
class JAVAConn : public BLOCK { class JAVAConn : public BLOCK {
friend class TDBJMG; friend class TDBJMG;
friend class JMGDISC;
private: private:
JAVAConn(); // Standard (unused) constructor JAVAConn(); // Standard (unused) constructor
...@@ -120,6 +119,7 @@ class JAVAConn : public BLOCK { ...@@ -120,6 +119,7 @@ class JAVAConn : public BLOCK {
jclass jdi; // Pointer to the java wrapper class jclass jdi; // Pointer to the java wrapper class
jobject job; // The java wrapper class object jobject job; // The java wrapper class object
jmethodID errid; // The GetErrmsg method ID jmethodID errid; // The GetErrmsg method ID
PFBLOCK fp;
bool m_Opened; bool m_Opened;
bool m_Connected; bool m_Connected;
PCSZ DiscFunc; PCSZ DiscFunc;
......
...@@ -110,12 +110,13 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v) ...@@ -110,12 +110,13 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
int type; int type;
switch (stp) { switch (stp) {
case -1: // LONGVARCHAR case -1: // LONGVARCHAR, TEXT
case -16: // LONGNVARCHAR (unicode) case -16: // LONGNVARCHAR, NTEXT (unicode)
if (GetTypeConv() != TPC_YES) if (GetTypeConv() != TPC_YES)
return TYPE_ERROR; return TYPE_ERROR;
else else
len = MY_MIN(abs(len), GetConvSize()); len = MY_MIN(abs(len), GetConvSize());
// Pass through
case 12: // VARCHAR case 12: // VARCHAR
case -9: // NVARCHAR (unicode) case -9: // NVARCHAR (unicode)
v = 'V'; v = 'V';
...@@ -289,7 +290,7 @@ PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat, ...@@ -289,7 +290,7 @@ PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat,
if (trace) if (trace)
htrc("Getting col results ncol=%d\n", qrp->Nbcol); htrc("Getting col results ncol=%d\n", qrp->Nbcol);
if (!(cap = AllocCatInfo(g, CAT_COL, db, table, qrp))) if (!(cap = AllocCatInfo(g, JCAT_COL, db, table, qrp)))
return NULL; return NULL;
// Colpat cannot be null or empty for some drivers // Colpat cannot be null or empty for some drivers
...@@ -410,7 +411,7 @@ PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat, PCSZ tabtyp, ...@@ -410,7 +411,7 @@ PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat, PCSZ tabtyp,
return qrp; return qrp;
// Tabpat cannot be null or empty for some drivers // Tabpat cannot be null or empty for some drivers
if (!(cap = AllocCatInfo(g, CAT_TAB, db, if (!(cap = AllocCatInfo(g, JCAT_TAB, db,
(tabpat && *tabpat) ? tabpat : PlugDup(g, "%"), qrp))) (tabpat && *tabpat) ? tabpat : PlugDup(g, "%"), qrp)))
return NULL; return NULL;
...@@ -465,7 +466,7 @@ PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info) ...@@ -465,7 +466,7 @@ PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info)
if (!info) { if (!info) {
jcp = new(g) JDBConn(g, NULL); jcp = new(g) JDBConn(g, NULL);
if (jcp->Open(NULL) != RC_OK) if (jcp->Open(g) != RC_OK)
return NULL; return NULL;
if (!maxres) if (!maxres)
...@@ -803,9 +804,10 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -803,9 +804,10 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
switch (ctyp) { switch (ctyp) {
case 12: // VARCHAR case 12: // VARCHAR
case -9: // NVARCHAR case -9: // NVARCHAR
case -1: // LONGVARCHAR case -1: // LONGVARCHAR, TEXT
case 1: // CHAR case 1: // CHAR
case -15: // NCHAR case -15: // NCHAR
case -16: // LONGNVARCHAR, NTEXT
case 3: // DECIMAL case 3: // DECIMAL
case -8: // ROWID case -8: // ROWID
if (jb && ctyp != 3) if (jb && ctyp != 3)
...@@ -1226,7 +1228,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1226,7 +1228,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
case 5: crp->Name = "Nullable"; break; case 5: crp->Name = "Nullable"; break;
} // endswitch i } // endswitch i
// Build the java string array // Build the java int array
jintArray val = env->NewIntArray(4); jintArray val = env->NewIntArray(4);
if (val == nullptr) { if (val == nullptr) {
...@@ -1407,28 +1409,19 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1407,28 +1409,19 @@ bool JDBConn::SetParam(JDBCCOL *colp)
// Now do call the proper JDBC API // Now do call the proper JDBC API
switch (cap->Id) { switch (cap->Id) {
case CAT_COL: case JCAT_COL:
fnc = "GetColumns"; fnc = "GetColumns";
break; break;
case CAT_TAB: case JCAT_TAB:
fnc = "GetTables"; fnc = "GetTables";
break; break;
#if 0 #if 0
case CAT_KEY: case JCAT_KEY:
fnc = "SQLPrimaryKeys"; fnc = "SQLPrimaryKeys";
rc = SQLPrimaryKeys(hstmt, name.ptr(2), name.length(2), rc = SQLPrimaryKeys(hstmt, name.ptr(2), name.length(2),
name.ptr(1), name.length(1), name.ptr(1), name.length(1),
name.ptr(0), name.length(0)); name.ptr(0), name.length(0));
break; break;
case CAT_STAT:
fnc = "SQLStatistics";
rc = SQLStatistics(hstmt, name.ptr(2), name.length(2),
name.ptr(1), name.length(1),
name.ptr(0), name.length(0),
cap->Unique, cap->Accuracy);
break;
case CAT_SPC:
ThrowDJX("SQLSpecialColumns not available yet");
#endif // 0 #endif // 0
default: default:
sprintf(g->Message, "Invalid SQL function id"); sprintf(g->Message, "Invalid SQL function id");
......
...@@ -110,8 +110,8 @@ JMgoConn::JMgoConn(PGLOBAL g, PCSZ collname, PCSZ wrapper) ...@@ -110,8 +110,8 @@ JMgoConn::JMgoConn(PGLOBAL g, PCSZ collname, PCSZ wrapper)
deleteid = gcollid = countid = rewindid = nullptr; deleteid = gcollid = countid = rewindid = nullptr;
DiscFunc = "MongoDisconnect"; DiscFunc = "MongoDisconnect";
Fpc = NULL; Fpc = NULL;
m_Version = 0;
m_Fetch = 0; m_Fetch = 0;
m_Ncol = 0;
m_Version = 0; m_Version = 0;
} // end of JMgoConn } // end of JMgoConn
...@@ -122,13 +122,13 @@ void JMgoConn::AddJars(PSTRG jpop, char sep) ...@@ -122,13 +122,13 @@ void JMgoConn::AddJars(PSTRG jpop, char sep)
{ {
#if defined(DEVELOPMENT) #if defined(DEVELOPMENT)
if (m_Version == 2) { if (m_Version == 2) {
//jpop->Append(sep); jpop->Append(sep);
//jpop->Append("C:/Eclipse/workspace/MongoWrap2/bin"); jpop->Append("C:/Eclipse/workspace/MongoWrap2/bin");
jpop->Append(sep); jpop->Append(sep);
jpop->Append("C:/mongo-java-driver/mongo-java-driver-2.13.3.jar"); jpop->Append("C:/mongo-java-driver/mongo-java-driver-2.13.3.jar");
} else { } else {
//jpop->Append(sep); jpop->Append(sep);
//jpop->Append("C:/Eclipse/workspace/MongoWrap3/bin"); jpop->Append("C:/Eclipse/workspace/MongoWrap3/bin");
jpop->Append(sep); jpop->Append(sep);
jpop->Append("C:/mongo-java-driver/mongo-java-driver-3.4.2.jar"); jpop->Append("C:/mongo-java-driver/mongo-java-driver-3.4.2.jar");
} // endif m_Version } // endif m_Version
...@@ -495,13 +495,15 @@ int JMgoConn::Fetch(int pos) ...@@ -495,13 +495,15 @@ int JMgoConn::Fetch(int pos)
//else //else
// m_Fetch++; // m_Fetch++;
m_Rows += (int)rc; m_Ncol = (int)rc;
rc = MY_MIN(rc, 1);
m_Rows += rc;
} else } else
sprintf(g->Message, "Fetch: %s", Msg); sprintf(g->Message, "Fetch: %s", Msg);
//} // endif pos //} // endif pos
return (int)rc; return rc;
} // end of Fetch } // end of Fetch
/***********************************************************************/ /***********************************************************************/
...@@ -730,7 +732,7 @@ int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp) ...@@ -730,7 +732,7 @@ int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp)
return RC_FX; return RC_FX;
if (env->CallBooleanMethod(job, docaddid, updlist, jkey, val)) if (env->CallBooleanMethod(job, docaddid, updlist, jkey, val))
return NULL; return RC_OK;
env->DeleteLocalRef(jkey); env->DeleteLocalRef(jkey);
} // endfor colp } // endfor colp
...@@ -740,7 +742,7 @@ int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp) ...@@ -740,7 +742,7 @@ int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp)
jkey = env->NewStringUTF("$set"); jkey = env->NewStringUTF("$set");
if (env->CallBooleanMethod(job, docaddid, upd, jkey, updlist)) if (env->CallBooleanMethod(job, docaddid, upd, jkey, updlist))
return NULL; return RC_OK;
env->DeleteLocalRef(jkey); env->DeleteLocalRef(jkey);
......
...@@ -19,31 +19,6 @@ typedef class MGODEF *PMGODEF; ...@@ -19,31 +19,6 @@ typedef class MGODEF *PMGODEF;
typedef class TDBJMG *PTDBJMG; typedef class TDBJMG *PTDBJMG;
typedef class JMGCOL *PJMGCOL; typedef class JMGCOL *PJMGCOL;
#if 0
/***********************************************************************/
/* Class used to get the columns of a mongo collection. */
/***********************************************************************/
class MGODISC : public BLOCK {
public:
// Constructor
MGODISC(PGLOBAL g, int *lg);
// Functions
int GetColumns(PGLOBAL g, char *db, PTOS topt);
bool FindInDoc(PGLOBAL g, bson_iter_t *iter, const bson_t *doc,
char *pcn, char *pfmt, int i, int k, bool b);
// Members
BCOL bcol;
PBCOL bcp, fbcp, pbcp;
PMGODEF tdp;
TDBJMG *tmgp;
int *length;
int n, k, lvl;
bool all;
}; // end of MGODISC
#endif // 0
typedef struct JKCOL { typedef struct JKCOL {
JKCOL *Next; JKCOL *Next;
PJNCOL Jncolp; PJNCOL Jncolp;
...@@ -73,6 +48,7 @@ class JNCOL : public BLOCK { ...@@ -73,6 +48,7 @@ class JNCOL : public BLOCK {
/***********************************************************************/ /***********************************************************************/
class JMgoConn : public JAVAConn { class JMgoConn : public JAVAConn {
friend class TDBJMG; friend class TDBJMG;
friend class JMGDISC;
//friend class TDBXJDC; //friend class TDBXJDC;
//friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&); //friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
private: private:
...@@ -132,5 +108,6 @@ class JMgoConn : public JAVAConn { ...@@ -132,5 +108,6 @@ class JMgoConn : public JAVAConn {
jmethodID deleteid; // The CollDelete method ID jmethodID deleteid; // The CollDelete method ID
PJNCOL Fpc; // To JNCOL classes PJNCOL Fpc; // To JNCOL classes
int m_Fetch; int m_Fetch;
int m_Ncol;
int m_Version; // Java driver version (2 or 3) int m_Version; // Java driver version (2 or 3)
}; // end of JMgoConn class definition }; // end of JMgoConn class definition
/*************** json CPP Declares Source Code File (.H) ***************/ /*************** json CPP Declares Source Code File (.H) ***************/
/* Name: json.cpp Version 1.3 */ /* Name: json.cpp Version 1.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
/* */ /* */
...@@ -53,6 +53,8 @@ void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp) ...@@ -53,6 +53,8 @@ void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp)
char *GetExceptionDesc(PGLOBAL g, unsigned int e); char *GetExceptionDesc(PGLOBAL g, unsigned int e);
#endif // SE_CATCH #endif // SE_CATCH
char *GetJsonNull(void);
/***********************************************************************/ /***********************************************************************/
/* IsNum: check whether this string is all digits. */ /* IsNum: check whether this string is all digits. */
/***********************************************************************/ /***********************************************************************/
...@@ -963,6 +965,25 @@ return false; ...@@ -963,6 +965,25 @@ return false;
/* -------------------------- Class JOBJECT -------------------------- */ /* -------------------------- Class JOBJECT -------------------------- */
/***********************************************************************/
/* Return the number of pairs in this object. */
/***********************************************************************/
int JOBJECT::GetSize(bool b)
{
if (b) {
// Return only non null pairs
int n = 0;
for (PJPR jpp = First; jpp; jpp = jpp->Next)
if (jpp->Val && !jpp->Val->IsNull())
n++;
return n;
} else
return Size;
} // end of GetSize
/***********************************************************************/ /***********************************************************************/
/* Add a new pair to an Object. */ /* Add a new pair to an Object. */
/***********************************************************************/ /***********************************************************************/
...@@ -1046,7 +1067,7 @@ PSZ JOBJECT::GetText(PGLOBAL g, PSZ text) ...@@ -1046,7 +1067,7 @@ PSZ JOBJECT::GetText(PGLOBAL g, PSZ text)
PlugSubAlloc(g, NULL, strlen(text) + 1); PlugSubAlloc(g, NULL, strlen(text) + 1);
return text + n; return text + n;
} // end of GetValue; } // end of GetText;
/***********************************************************************/ /***********************************************************************/
/* Merge two objects. */ /* Merge two objects. */
...@@ -1087,7 +1108,7 @@ void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PCSZ key) ...@@ -1087,7 +1108,7 @@ void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PCSZ key)
} // end of SetValue } // end of SetValue
/***********************************************************************/ /***********************************************************************/
/* Delete a value corresponding to the given key. */ /* Delete a value corresponding to the given key. */
/***********************************************************************/ /***********************************************************************/
void JOBJECT::DeleteKey(PCSZ key) void JOBJECT::DeleteKey(PCSZ key)
{ {
...@@ -1117,6 +1138,25 @@ bool JOBJECT::IsNull(void) ...@@ -1117,6 +1138,25 @@ bool JOBJECT::IsNull(void)
/* -------------------------- Class JARRAY --------------------------- */ /* -------------------------- Class JARRAY --------------------------- */
/***********************************************************************/
/* Return the number of values in this object. */
/***********************************************************************/
int JARRAY::GetSize(bool b)
{
if (b) {
// Return only non null values
int n = 0;
for (PJVAL jvp = First; jvp; jvp = jvp->Next)
if (!jvp->IsNull())
n++;
return n;
} else
return Size;
} // end of GetSize
/***********************************************************************/ /***********************************************************************/
/* Make the array of values from the values list. */ /* Make the array of values from the values list. */
/***********************************************************************/ /***********************************************************************/
...@@ -1225,18 +1265,42 @@ bool JARRAY::SetValue(PGLOBAL g, PJVAL jvp, int n) ...@@ -1225,18 +1265,42 @@ bool JARRAY::SetValue(PGLOBAL g, PJVAL jvp, int n)
return false; return false;
} // end of SetValue } // end of SetValue
/***********************************************************************/
/* Return the text corresponding to all values. */
/***********************************************************************/
PSZ JARRAY::GetText(PGLOBAL g, PSZ text)
{
int n;
PJVAL jp;
if (!text) {
text = (char*)PlugSubAlloc(g, NULL, 0);
text[0] = 0;
n = 1;
} else
n = 0;
for (jp = First; jp; jp = jp->Next)
jp->GetText(g, text);
if (n)
PlugSubAlloc(g, NULL, strlen(text) + 1);
return text + n;
} // end of GetText;
/***********************************************************************/ /***********************************************************************/
/* Delete a Value from the Arrays Value list. */ /* Delete a Value from the Arrays Value list. */
/***********************************************************************/ /***********************************************************************/
bool JARRAY::DeleteValue(int n) bool JARRAY::DeleteValue(int n)
{ {
PJVAL jvp = GetValue(n); PJVAL jvp = GetValue(n);
if (jvp) { if (jvp) {
jvp->Del = true; jvp->Del = true;
return false; return false;
} else } else
return true; return true;
} // end of DeleteValue } // end of DeleteValue
...@@ -1286,7 +1350,7 @@ JTYP JVALUE::GetValType(void) ...@@ -1286,7 +1350,7 @@ JTYP JVALUE::GetValType(void)
else if (Value) else if (Value)
return (JTYP)Value->GetType(); return (JTYP)Value->GetType();
else else
return (JTYP)TYPE_VOID; return TYPE_NULL;
} // end of GetValType } // end of GetValType
...@@ -1339,10 +1403,20 @@ double JVALUE::GetFloat(void) ...@@ -1339,10 +1403,20 @@ double JVALUE::GetFloat(void)
/***********************************************************************/ /***********************************************************************/
/* Return the Value's String value. */ /* Return the Value's String value. */
/***********************************************************************/ /***********************************************************************/
PSZ JVALUE::GetString(void) PSZ JVALUE::GetString(PGLOBAL g)
{ {
char buf[32]; char *p;
return (Value) ? Value->GetCharString(buf) : NULL;
if (Value) {
char buf[32];
if ((p = Value->GetCharString(buf)) == buf)
p = PlugDup(g, buf);
} else
p = NULL;
return p;
} // end of GetString } // end of GetString
/***********************************************************************/ /***********************************************************************/
...@@ -1350,7 +1424,7 @@ PSZ JVALUE::GetString(void) ...@@ -1350,7 +1424,7 @@ PSZ JVALUE::GetString(void)
/***********************************************************************/ /***********************************************************************/
PSZ JVALUE::GetText(PGLOBAL g, PSZ text) PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
{ {
if (Jsp && Jsp->GetType() == TYPE_JOB) if (Jsp)
return Jsp->GetText(g, text); return Jsp->GetText(g, text);
char buf[32]; char buf[32];
...@@ -1358,8 +1432,8 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text) ...@@ -1358,8 +1432,8 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
if (s) if (s)
strcat(strcat(text, " "), s); strcat(strcat(text, " "), s);
else else if (GetJsonNull())
strcat(text, " <null>"); strcat(strcat(text, " "), GetJsonNull());
return text; return text;
} // end of GetText } // end of GetText
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#define X #define X
#endif #endif
enum JTYP {TYPE_STRG = TYPE_STRING, enum JTYP {TYPE_NULL = TYPE_VOID,
TYPE_STRG = TYPE_STRING,
TYPE_DBL = TYPE_DOUBLE, TYPE_DBL = TYPE_DOUBLE,
TYPE_BOOL = TYPE_TINY, TYPE_BOOL = TYPE_TINY,
TYPE_BINT = TYPE_BIGINT, TYPE_BINT = TYPE_BIGINT,
...@@ -52,6 +53,8 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty); ...@@ -52,6 +53,8 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty);
bool SerializeArray(JOUT *js, PJAR jarp, bool b); bool SerializeArray(JOUT *js, PJAR jarp, bool b);
bool SerializeObject(JOUT *js, PJOB jobp); bool SerializeObject(JOUT *js, PJOB jobp);
bool SerializeValue(JOUT *js, PJVAL jvp); bool SerializeValue(JOUT *js, PJVAL jvp);
bool IsNum(PSZ s);
char *NextChr(PSZ s, char sep);
/***********************************************************************/ /***********************************************************************/
/* Class JOUT. Used by Serialize. */ /* Class JOUT. Used by Serialize. */
...@@ -146,6 +149,7 @@ class JSON : public BLOCK { ...@@ -146,6 +149,7 @@ class JSON : public BLOCK {
JSON(void) {Size = 0;} JSON(void) {Size = 0;}
int size(void) {return Size;} int size(void) {return Size;}
virtual int GetSize(bool b) {return Size;}
virtual void Clear(void) {Size = 0;} virtual void Clear(void) {Size = 0;}
virtual JTYP GetType(void) {return TYPE_JSON;} virtual JTYP GetType(void) {return TYPE_JSON;}
virtual JTYP GetValType(void) {X return TYPE_JSON;} virtual JTYP GetValType(void) {X return TYPE_JSON;}
...@@ -163,7 +167,7 @@ class JSON : public BLOCK { ...@@ -163,7 +167,7 @@ class JSON : public BLOCK {
virtual PJPR GetFirst(void) {X return NULL;} virtual PJPR GetFirst(void) {X return NULL;}
virtual int GetInteger(void) {X return 0;} virtual int GetInteger(void) {X return 0;}
virtual double GetFloat() {X return 0.0;} virtual double GetFloat() {X return 0.0;}
virtual PSZ GetString() {X return NULL;} virtual PSZ GetString(PGLOBAL g) {X return NULL;}
virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;} virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;}
virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; } virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; }
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; } virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; }
...@@ -193,10 +197,11 @@ class JOBJECT : public JSON { ...@@ -193,10 +197,11 @@ class JOBJECT : public JSON {
using JSON::GetValue; using JSON::GetValue;
using JSON::SetValue; using JSON::SetValue;
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JOB;} virtual JTYP GetType(void) {return TYPE_JOB;}
virtual PJPR GetFirst(void) {return First;} virtual PJPR GetFirst(void) {return First;}
virtual PJPR AddPair(PGLOBAL g, PCSZ key); virtual int GetSize(bool b);
virtual PJPR AddPair(PGLOBAL g, PCSZ key);
virtual PJOB GetObject(void) {return this;} virtual PJOB GetObject(void) {return this;}
virtual PJVAL GetValue(const char* key); virtual PJVAL GetValue(const char* key);
virtual PJAR GetKeyList(PGLOBAL g); virtual PJAR GetKeyList(PGLOBAL g);
...@@ -222,11 +227,13 @@ class JARRAY : public JSON { ...@@ -222,11 +227,13 @@ class JARRAY : public JSON {
using JSON::GetValue; using JSON::GetValue;
using JSON::SetValue; using JSON::SetValue;
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JAR;} virtual JTYP GetType(void) {return TYPE_JAR;}
virtual PJAR GetArray(void) {return this;} virtual PJAR GetArray(void) {return this;}
PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL); virtual int GetSize(bool b);
PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL);
virtual void InitArray(PGLOBAL g); virtual void InitArray(PGLOBAL g);
virtual PJVAL GetValue(int i); virtual PJVAL GetValue(int i);
virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual bool Merge(PGLOBAL g, PJSON jsp); virtual bool Merge(PGLOBAL g, PJSON jsp);
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i); virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i);
virtual bool DeleteValue(int n); virtual bool DeleteValue(int n);
...@@ -246,20 +253,20 @@ class JARRAY : public JSON { ...@@ -246,20 +253,20 @@ class JARRAY : public JSON {
class JVALUE : public JSON { class JVALUE : public JSON {
friend class JARRAY; friend class JARRAY;
friend class JSNX; friend class JSNX;
friend class JSONCOL;
friend PJVAL ParseValue(PGLOBAL, int&, STRG&, bool*); friend PJVAL ParseValue(PGLOBAL, int&, STRG&, bool*);
friend bool SerializeValue(JOUT *, PJVAL); friend bool SerializeValue(JOUT *, PJVAL);
public: public:
JVALUE(void) : JSON() JVALUE(void) : JSON() {Clear();}
{Jsp = NULL; Value = NULL; Next = NULL; Del = false;}
JVALUE(PJSON jsp) : JSON() JVALUE(PJSON jsp) : JSON()
{Jsp = jsp; Value = NULL; Next = NULL; Del = false;} {Jsp = jsp; Value = NULL; Next = NULL; Del = false; Size = 1;}
JVALUE(PGLOBAL g, PVAL valp); JVALUE(PGLOBAL g, PVAL valp);
JVALUE(PGLOBAL g, PCSZ strp); JVALUE(PGLOBAL g, PCSZ strp);
using JSON::GetValue; using JSON::GetValue;
using JSON::SetValue; using JSON::SetValue;
virtual void Clear(void) virtual void Clear(void)
{Jsp = NULL; Value = NULL; Next = NULL; Del = false; Size = 0;} {Jsp = NULL; Value = NULL; Next = NULL; Del = false; Size = 1;}
virtual JTYP GetType(void) {return TYPE_JVAL;} virtual JTYP GetType(void) {return TYPE_JVAL;}
virtual JTYP GetValType(void); virtual JTYP GetValType(void);
virtual PJOB GetObject(void); virtual PJOB GetObject(void);
...@@ -270,7 +277,7 @@ class JVALUE : public JSON { ...@@ -270,7 +277,7 @@ class JVALUE : public JSON {
virtual int GetInteger(void); virtual int GetInteger(void);
virtual long long GetBigint(void); virtual long long GetBigint(void);
virtual double GetFloat(void); virtual double GetFloat(void);
virtual PSZ GetString(void); virtual PSZ GetString(PGLOBAL g);
virtual PSZ GetText(PGLOBAL g, PSZ text); virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual void SetValue(PJSON jsp); virtual void SetValue(PJSON jsp);
virtual void SetValue(PVAL valp) { Value = valp; Jsp = NULL; } virtual void SetValue(PVAL valp) { Value = valp; Jsp = NULL; }
......
This diff is collapsed.
...@@ -53,6 +53,18 @@ extern "C" { ...@@ -53,6 +53,18 @@ extern "C" {
DllExport char *json_array_delete(UDF_EXEC_ARGS); DllExport char *json_array_delete(UDF_EXEC_ARGS);
DllExport void json_array_delete_deinit(UDF_INIT*); DllExport void json_array_delete_deinit(UDF_INIT*);
DllExport my_bool jsonsum_int_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long jsonsum_int(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void jsonsum_int_deinit(UDF_INIT*);
DllExport my_bool jsonsum_real_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport double jsonsum_real(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void jsonsum_real_deinit(UDF_INIT*);
DllExport my_bool jsonavg_real_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport double jsonavg_real(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void jsonavg_real_deinit(UDF_INIT*);
DllExport my_bool json_make_object_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_make_object_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_make_object(UDF_EXEC_ARGS); DllExport char *json_make_object(UDF_EXEC_ARGS);
DllExport void json_make_object_deinit(UDF_INIT*); DllExport void json_make_object_deinit(UDF_INIT*);
......
This diff is collapsed.
...@@ -25,15 +25,43 @@ typedef struct _bncol { ...@@ -25,15 +25,43 @@ typedef struct _bncol {
bool Found; bool Found;
} BCOL, *PBCOL; } BCOL, *PBCOL;
/***********************************************************************/
/* Class used to get the columns of a mongo collection. */
/***********************************************************************/
class MGODISC : public BLOCK {
public:
// Constructor
MGODISC(PGLOBAL g, int *lg);
// Methods
virtual bool Init(PGLOBAL g) { return false; }
virtual void GetDoc(void) {}
virtual bool Find(PGLOBAL g) = 0;
// Functions
int GetColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt);
void AddColumn(PGLOBAL g, PCSZ colname, PCSZ fmt, int k);
// Members
BCOL bcol;
PBCOL bcp, fbcp, pbcp;
PMGODEF tdp;
PTDB tmgp;
PCSZ drv;
int *length;
int i, ncol, lvl;
bool all;
}; // end of MGODISC
/***********************************************************************/ /***********************************************************************/
/* MongoDB table. */ /* MongoDB table. */
/***********************************************************************/ /***********************************************************************/
class DllExport MGODEF : public EXTDEF { /* Table description */ class DllExport MGODEF : public EXTDEF { /* Table description */
friend class TDBMGO; friend class TDBCMG;
friend class TDBJMG; friend class TDBJMG;
friend class TDBGOL; friend class TDBGOL;
friend class TDBJGL; friend class TDBJGL;
friend class MGOFAM; friend class CMGFAM;
friend class MGODISC; friend class MGODISC;
friend PQRYRES MGOColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool); friend PQRYRES MGOColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool);
public: public:
......
...@@ -96,9 +96,9 @@ ...@@ -96,9 +96,9 @@
#if defined(XML_SUPPORT) #if defined(XML_SUPPORT)
#include "tabxml.h" #include "tabxml.h"
#endif // XML_SUPPORT #endif // XML_SUPPORT
#if defined(MONGO_SUPPORT) || defined(JDBC_SUPPORT) #if defined(MONGO_SUPPORT)
#include "mongo.h" #include "mongo.h"
#endif // MONGO_SUPPORT || JDBC_SUPPORT #endif // MONGO_SUPPORT
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
#include "tabzip.h" #include "tabzip.h"
#endif // ZIP_SUPPORT #endif // ZIP_SUPPORT
...@@ -164,7 +164,7 @@ TABTYPE GetTypeID(const char *type) ...@@ -164,7 +164,7 @@ TABTYPE GetTypeID(const char *type)
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
: (!stricmp(type, "ZIP")) ? TAB_ZIP : (!stricmp(type, "ZIP")) ? TAB_ZIP
#endif #endif
#if defined(MONGO_SUPPORT) || defined(JDBC_SUPPORT) #if defined(MONGO_SUPPORT)
: (!stricmp(type, "MONGO")) ? TAB_MONGO : (!stricmp(type, "MONGO")) ? TAB_MONGO
#endif #endif
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY; : (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
...@@ -557,9 +557,9 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) ...@@ -557,9 +557,9 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
#endif // PIVOT_SUPPORT #endif // PIVOT_SUPPORT
case TAB_VIR: tdp= new(g) VIRDEF; break; case TAB_VIR: tdp= new(g) VIRDEF; break;
case TAB_JSON: tdp= new(g) JSONDEF; break; case TAB_JSON: tdp= new(g) JSONDEF; break;
#if defined(MONGO_SUPPORT) || defined(JDBC_SUPPORT) #if defined(MONGO_SUPPORT)
case TAB_MONGO: tdp = new(g) MGODEF; break; case TAB_MONGO: tdp = new(g) MGODEF; break;
#endif // MONGO_SUPPORT || JDBC_SUPPORT #endif // MONGO_SUPPORT
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
case TAB_ZIP: tdp= new(g) ZIPDEF; break; case TAB_ZIP: tdp= new(g) ZIPDEF; break;
#endif // ZIP_SUPPORT #endif // ZIP_SUPPORT
......
...@@ -139,7 +139,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, ...@@ -139,7 +139,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
unsigned int length[] = {0, 4, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0}; unsigned int length[] = {0, 4, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
PCSZ fmt; PCSZ fmt;
char *fld, *colname, *chset, v, buf[128], uns[16], zero[16]; char *fld, *colname, *chset, v, buf[128], uns[16], zero[16];
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int); int i, n, nf = 0, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec, rc, k = 0; int len, type, prec, rc, k = 0;
bool b; bool b;
PQRYRES qrp; PQRYRES qrp;
...@@ -160,7 +160,9 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, ...@@ -160,7 +160,9 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
/* Do an evaluation of the result size. */ /* Do an evaluation of the result size. */
/********************************************************************/ /********************************************************************/
STRING cmd(g, 64, "SHOW FULL COLUMNS FROM "); STRING cmd(g, 64, "SHOW FULL COLUMNS FROM ");
b = cmd.Append((PSZ)table); b = cmd.Append('`');
b |= cmd.Append((PSZ)table);
b |= cmd.Append('`');
b |= cmd.Append(" FROM "); b |= cmd.Append(" FROM ");
b |= cmd.Append((PSZ)(db ? db : PlgGetUser(g)->DBName)); b |= cmd.Append((PSZ)(db ? db : PlgGetUser(g)->DBName));
......
...@@ -13,5 +13,9 @@ jdbc : Variable settings depend on machine configuration ...@@ -13,5 +13,9 @@ jdbc : Variable settings depend on machine configuration
jdbc_new : Variable settings depend on machine configuration jdbc_new : Variable settings depend on machine configuration
jdbc_oracle : Variable settings depend on machine configuration jdbc_oracle : Variable settings depend on machine configuration
jdbc_postgresql : Variable settings depend on machine configuration jdbc_postgresql : Variable settings depend on machine configuration
json_mgo : Need MongoDB running and its C Driver installed json_mongo_c : Need MongoDB running and its C Driver installed
mongo : Need MongoDB running and its C Driver installed json_java_2 : Need MongoDB running and its Java Driver installed
json_java_3 : Need MongoDB running and its Java Driver installed
mongo_c : Need MongoDB running and its C Driver installed
mongo_java_2 : Need MongoDB running and its Java Driver installed
mongo_java_3 : Need MongoDB running and its Java Driver installed
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -608,7 +608,7 @@ JsonGet_String(Json_File('test/fx.json'), '1.*') ...@@ -608,7 +608,7 @@ JsonGet_String(Json_File('test/fx.json'), '1.*')
{"_id":6,"type":"car","item":"roadster","mileage":56000,"ratings":[6,9]} {"_id":6,"type":"car","item":"roadster","mileage":56000,"ratings":[6,9]}
SELECT JsonGet_String(Json_File('test/fx.json'), '1'); SELECT JsonGet_String(Json_File('test/fx.json'), '1');
JsonGet_String(Json_File('test/fx.json'), '1') JsonGet_String(Json_File('test/fx.json'), '1')
6 car roadster 56000 <null> 6 car roadster 56000 6 9
SELECT JsonGet_Int(Json_File('test/fx.json'), '1.mileage') AS Mileage; SELECT JsonGet_Int(Json_File('test/fx.json'), '1.mileage') AS Mileage;
Mileage Mileage
56000 56000
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -17,7 +17,7 @@ ERROR HY000: (1049) Unknown database 'unknown' ...@@ -17,7 +17,7 @@ ERROR HY000: (1049) Unknown database 'unknown'
CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL OPTION_LIST='host=localhost,user=root,port=PORT' DBNAME='unknown' TABNAME='t1'; CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL OPTION_LIST='host=localhost,user=root,port=PORT' DBNAME='unknown' TABNAME='t1';
ERROR HY000: (1049) Unknown database 'unknown' ERROR HY000: (1049) Unknown database 'unknown'
CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='unknown' OPTION_LIST='host=localhost,user=root,port=PORT'; CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='unknown' OPTION_LIST='host=localhost,user=root,port=PORT';
ERROR HY000: (1146) Table 'test.unknown' doesn't exist [SHOW FULL COLUMNS FROM unknown FROM test] ERROR HY000: (1146) Table 'test.unknown' doesn't exist [SHOW FULL COLUMNS FROM `unknown` FROM test]
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
ERROR 42S02: Table 'test.t2' doesn't exist ERROR 42S02: Table 'test.t2' doesn't exist
CREATE TABLE t2 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=PORT'; CREATE TABLE t2 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=PORT';
......
...@@ -29,7 +29,7 @@ OPTION_LIST='host=127.0.0.1,user=root,port=SLAVE_PORT' DBNAME='unknown' TABNAME= ...@@ -29,7 +29,7 @@ OPTION_LIST='host=127.0.0.1,user=root,port=SLAVE_PORT' DBNAME='unknown' TABNAME=
ERROR HY000: (1049) Unknown database 'unknown' ERROR HY000: (1049) Unknown database 'unknown'
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/unknown'; CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/unknown';
ERROR HY000: (1146) Table 'test.unknown' doesn't exist [SHOW FULL COLUMNS FROM unknown FROM test] ERROR HY000: (1146) Table 'test.unknown' doesn't exist [SHOW FULL COLUMNS FROM `unknown` FROM test]
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
ERROR 42S02: Table 'test.t1' doesn't exist ERROR 42S02: Table 'test.t1' doesn't exist
CREATE TABLE t1 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL CREATE TABLE t1 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL
......
...@@ -141,22 +141,3 @@ DROP TABLE t1; ...@@ -141,22 +141,3 @@ DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t3; DROP TABLE t3;
DROP TABLE t4; DROP TABLE t4;
#
# Checking thread TBL tables
#
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 11 as v';
SELECT * FROM t1;
v
11
CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 22 as v';
SELECT * FROM t2;
v
22
CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=PORT';;
SELECT * FROM total order by v desc;
v
22
11
DROP TABLE total;
DROP TABLE t1;
DROP TABLE t2;
This diff is collapsed.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff is collapsed.
-- source jdbconn.inc
-- source mongo.inc
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo2.jar';
let $DRV= Java;
let $VERS= 2;
let $TYPE= JSON;
let $CONN= CONNECTION='mongodb://localhost:27017' LRECL=4096;
-- source mongo_test.inc
-- source jdbconn_cleanup.inc
-- source jdbconn.inc
-- source mongo.inc
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo3.jar';
let $DRV= Java;
let $VERS= 3;
let $TYPE= JSON;
let $CONN= CONNECTION='mongodb://localhost:27017' LRECL=4096;
-- source mongo_test.inc
-- source jdbconn_cleanup.inc
-- source mongo.inc
let $DRV= C;
let $VERS= 0;
let $PROJ= {"projection":;
let $ENDP= };
let $TYPE= JSON;
let $CONN= CONNECTION='mongodb://localhost:27017' LRECL=1024;
-- source mongo_test.inc
let $MONGO= C:/PROGRA~1/MongoDB/Server/3.4/bin/mongo;
let $MONGOIMPORT= C:/PROGRA~1/MongoDB/Server/3.4/bin/mongoimport;
-- source mongo.inc
let $DRV= C;
let $VERS= 0;
let $PROJ= {"projection":;
let $ENDP= };
let $TYPE= MONGO;
-- source mongo_test.inc
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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