Commit b9aab7d9 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'connect/10.2' into 10.2

parents a76c05bb a9d32010
......@@ -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 -DUSE_TRY )
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT )
#
......@@ -245,7 +245,7 @@ int main() {
ENDIF(CONNECT_WITH_ODBC)
#
# JDBC
# JDBC and MongoDB Java Driver
#
IF(APPLE)
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine without JDBC support" OFF)
......@@ -262,9 +262,13 @@ IF(CONNECT_WITH_JDBC)
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2})
# SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY}) will be dynamically linked
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h
javaconn.cpp jdbconn.cpp tabjdbc.cpp
jmgoconn.cpp jmgfam.cpp mongo.cpp tabjmg.cpp
jdbccat.h javaconn.h jdbconn.h tabjdbc.h
jmgoconn.h jmgfam.h mongo.h tabjmg.h
JdbcInterface.java ApacheInterface.java MariadbInterface.java
MysqlInterface.java OracleInterface.java PostgresqlInterface.java
Mongo2Interface.java Mongo3Interface.java
JavaWrappers.jar)
# TODO: Find how to compile and install the java wrapper classes
# Find required libraries and include directories
......@@ -291,6 +295,36 @@ IF(CONNECT_WITH_ZIP)
add_definitions(-DZIP_SUPPORT -DNOCRYPT)
ENDIF(CONNECT_WITH_ZIP)
#
# MONGO C Driver (CMAKE NOT YET WORKING)
#
#OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON)
#IF(CONNECT_WITH_MONGO)
# IF(WIN32)
# # Adding some typical places to search in
# SET(PC_MONGO_INCLUDE_DIRS
# C:/mongo-c-driver/include
# D:/mongo-c-driver/include)
# SET(PC_MONGO_LIBRARY_DIRS
# C:/mongo-c-driver/lib
# D:/mongo-c-driver/lib)
# ENDIF(WIN32)
# FIND_PACKAGE(libmongoc)
# IF (MONGO_FOUND)
# INCLUDE_DIRECTORIES(${MONGO_INCLUDE_DIR})
# SET(MONGO_LIBRARY ${MONGO_LIBRARIES})
# SET(CONNECT_SOURCES ${CONNECT_SOURCES}
# cmgoconn.cpp mongofam.cpp tabmgo.cpp
# cmgoconn.h mongofam.h tabmgo.h)
# IF (NOT JAVA_FOUND AND JNI_FOUND)
# SET(CONNECT_SOURCES ${CONNECT_SOURCES} mongo.cpp mongo.h)
# ENDIF (NOT JAVA_FOUND AND JNI_FOUND)
# add_definitions(-DMONGO_SUPPORT)
# ENDIF(MONGO_FOUND)
#ENDIF(CONNECT_WITH_MONGO)
#
# XMAP
......@@ -310,6 +344,8 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
STORAGE_ENGINE
COMPONENT connect-engine
RECOMPILE_FOR_EMBEDDED
# LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} $(MONGO_LIBRARY)
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY})
This diff was suppressed by a .gitattributes entry.
package wrappers;
import java.util.Date;
import java.util.List;
import java.util.Set;
import com.mongodb.AggregationOptions;
import com.mongodb.BasicDBList;
import com.mongodb.BasicDBObject;
import com.mongodb.Cursor;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.MongoException;
import com.mongodb.WriteConcernException;
import com.mongodb.WriteResult;
import com.mongodb.util.JSON;
public class Mongo2Interface {
boolean DEBUG = false;
String Errmsg = "No error";
Set<String> Colnames = null;
Cursor cursor = null;
MongoClient client = null;
DB db = null;
DBCollection coll = null;
BasicDBObject doc = null;
BasicDBObject dbq = null;
BasicDBObject dbf = null;
List<DBObject> pip = null;
AggregationOptions aop = null;
// === Constructors/finalize =========================================
public Mongo2Interface() {
this(false);
} // end of default constructor
public Mongo2Interface(boolean b) {
DEBUG = b;
} // end of constructor
protected void SetErrmsg(String str) {
if (DEBUG)
System.out.println(str);
Errmsg = str;
} // end of SetErrmsg
protected void SetErrmsg(Exception e) {
if (DEBUG)
System.out.println(e.getMessage());
Errmsg = e.toString();
} // end of SetErrmsg
public String GetErrmsg() {
String err = Errmsg;
Errmsg = "No error";
return err;
} // end of GetErrmsg
public int MongoConnect(String[] parms) {
int rc = 0;
if (DEBUG)
System.out.println("Mongo2: URI=" + parms[0] + " DB=" + parms[1]);
try {
MongoClientURI uri = new MongoClientURI(parms[0]);
client = new MongoClient(uri);
if (DEBUG)
System.out.println("Connection " + client.toString() + " established");
// Now connect to your databases
db = client.getDB(parms[1]);
if (parms[2] != null && !parms[2].isEmpty()) {
if (DEBUG)
System.out.println("user=" + parms[2] + " pwd=" + parms[3]);
@SuppressWarnings("deprecation")
boolean auth = db.authenticate(parms[2], parms[3].toCharArray());
if (DEBUG)
System.out.println("Authentication: " + auth);
} // endif user
} catch (MongoException me) {
SetErrmsg(me);
rc = -1;
} catch (Exception e) {
SetErrmsg(e);
rc = -3;
} // end try/catch
return rc;
} // end of MongoConnect
public int MongoDisconnect() {
int rc = 0;
try {
if (cursor != null) {
if (DEBUG)
System.out.println("Closing cursor");
cursor.close();
cursor = null;
} // endif client
if (client != null) {
if (DEBUG)
System.out.println("Closing connection");
client.close();
client = null;
} // endif client
} catch (MongoException se) {
SetErrmsg(se);
rc += 8;
} // end try/catch
return rc;
} // end of MongoDisconnect
public boolean GetCollection(String name) {
if (DEBUG)
System.out.println("GetCollection: name=" + name);
try {
coll = db.getCollection(name);
} catch (Exception e) {
SetErrmsg(e);
return true;
} // end try/catch
return false;
} // end of GetCollection
public long GetCollSize() {
return (coll != null) ? coll.count() : 0;
} // end of GetCollSize
public boolean FindColl(String query, String fields) {
if (DEBUG)
System.out.println("FindColl: query=" + query + " fields=" + fields);
try {
if (query != null || fields != null) {
dbq = (BasicDBObject) JSON.parse((query != null) ? query : "{}");
if (fields != null) {
dbf = (BasicDBObject) JSON.parse(fields);
cursor = coll.find(dbq, dbf);
} else
cursor = coll.find(dbq);
} else
cursor = coll.find();
} catch (Exception e) {
SetErrmsg(e);
return true;
} // end try/catch
return false;
} // end of FindColl
@SuppressWarnings("unchecked")
public boolean AggregateColl(String pipeline) {
if (DEBUG)
System.out.println("AggregateColl: pipeline=" + pipeline);
try {
DBObject pipe = (DBObject) JSON.parse(pipeline);
pip = (List<DBObject>) pipe.get("pipeline");
aop = AggregationOptions.builder().batchSize(0).allowDiskUse(true)
.outputMode(AggregationOptions.OutputMode.CURSOR).build();
cursor = coll.aggregate(pip, aop);
} catch (MongoException me) {
SetErrmsg(me);
return true;
} // end try/catch
return false;
} // end of AggregateColl
public boolean Rewind() {
if (cursor != null)
cursor.close();
if (pip == null) {
if (dbf != null)
cursor = coll.find(dbq, dbf);
else if (dbq != null)
cursor = coll.find(dbq);
else
cursor = coll.find();
} else
cursor = coll.aggregate(pip, aop);
return (cursor == null);
} // end of Rewind
public int ReadNext() {
try {
if (cursor.hasNext()) {
doc = (BasicDBObject) cursor.next();
if (DEBUG)
System.out.println("Class doc = " + doc.getClass());
Colnames = doc.keySet();
return 1;
} else
return 0;
} catch (MongoException me) {
SetErrmsg(me);
return -1;
} // end try/catch
} // end of ReadNext
public boolean Fetch(int row) {
if (cursor.hasNext()) {
doc = (BasicDBObject) cursor.next();
Colnames = doc.keySet();
return true;
} else
return false;
} // end of Fetch
public String GetDoc() {
return (doc != null) ? doc.toString() : null;
} // end of GetDoc
public Set<String> GetColumns() {
if (doc != null)
return doc.keySet();
else
return null;
} // end of GetColumns
public String ColumnDesc(int n, int[] val) {
// if (rsmd == null) {
// System.out.println("No result metadata");
// return null;
// } else try {
// val[0] = rsmd.getColumnType(n);
// val[1] = rsmd.getPrecision(n);
// val[2] = rsmd.getScale(n);
// val[3] = rsmd.isNullable(n);
// return rsmd.getColumnLabel(n);
// } catch (SQLException se) {
// SetErrmsg(se);
// } //end try/catch
return null;
} // end of ColumnDesc
protected Object GetFieldObject(String path) {
Object o = null;
BasicDBObject dob = null;
BasicDBList lst = null;
String[] names = null;
if (path == null || path.equals("*"))
return doc;
else if (doc instanceof BasicDBObject)
dob = doc;
// else if (o instanceof BasicDBList)
// lst = (BasicDBList) doc;
else
return doc;
try {
names = path.split("\\.");
for (String name : names) {
if (lst != null) {
o = lst.get(Integer.parseInt(name));
} else
o = dob.get(name);
if (o == null)
break;
if (DEBUG)
System.out.println("Class o = " + o.getClass());
if (o instanceof BasicDBObject) {
dob = (BasicDBObject) o;
lst = null;
} else if (o instanceof BasicDBList) {
lst = (BasicDBList) o;
} else
break;
} // endfor name
} catch (IndexOutOfBoundsException x) {
o = null;
} catch (MongoException se) {
SetErrmsg(se);
o = null;
} // end try/catch
return o;
} // end of GetFieldObject
public String GetField(String path) {
Object o = GetFieldObject(path);
if (o != null) {
if (o instanceof Date) {
Integer TS = (int) (((Date) o).getTime() / 1000);
return TS.toString();
} // endif Date
return o.toString();
} else
return null;
} // end of GetField
public Object MakeDocument() {
return new BasicDBObject();
} // end of MakeDocument
public boolean DocAdd(Object bdc, String key, Object val) {
try {
((BasicDBObject) bdc).append(key, val);
} catch (MongoException me) {
SetErrmsg(me);
return true;
} // end try/catch
return false;
} // end of DocAdd
public Object MakeArray() {
return new BasicDBList();
} // end of MakeArray
public boolean ArrayAdd(Object bar, int n, Object val) {
try {
((BasicDBList) bar).put(n, val);
} catch (MongoException me) {
SetErrmsg(me);
return true;
} catch (Exception ex) {
SetErrmsg(ex);
return true;
} // end try/catch
return false;
} // end of ArrayAdd
public boolean CollInsert(Object dob) {
try {
coll.insert((BasicDBObject) dob);
} catch (MongoException me) {
SetErrmsg(me);
return true;
} catch (Exception ex) {
SetErrmsg(ex);
return true;
} // end try/catch
return false;
} // end of CollInsert
public long CollUpdate(Object upd) {
long n = -1;
if (DEBUG)
System.out.println("upd: " + upd.toString());
try {
DBObject qry = new BasicDBObject("_id", doc.get("_id"));
WriteResult res = coll.update(qry, (DBObject) upd);
if (DEBUG)
System.out.println("CollUpdate: " + res.toString());
n = res.getN();
} catch (MongoException me) {
SetErrmsg(me);
} catch (Exception ex) {
SetErrmsg(ex);
} // end try/catch
return n;
} // end of CollUpdate
public long CollDelete(boolean all) {
long n = -1;
try {
WriteResult res;
BasicDBObject qry = new BasicDBObject();
if (!all)
qry.append("_id", doc.get("_id"));
res = coll.remove(qry);
if (DEBUG)
System.out.println("CollDelete: " + res.toString());
n = res.getN();
} catch (WriteConcernException wx) {
SetErrmsg(wx);
} catch (MongoException me) {
SetErrmsg(me);
} catch (UnsupportedOperationException ux) {
SetErrmsg(ux);
n = 0;
} // end try/catch
return n;
} // end of CollDelete
} // end of class MongoInterface
This diff is collapsed.
......@@ -520,7 +520,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
} else if (opc != OP_EXIST) {
sprintf(g->Message, MSG(MISSING_ARG), opc);
throw TYPE_ARRAY;
throw (int)TYPE_ARRAY;
} else // OP_EXIST
return Nval > 0;
......@@ -683,14 +683,14 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
{
if (Vblp == NULL) {
strcpy(g->Message, MSG(PREC_VBLP_NULL));
throw TYPE_ARRAY;
throw (int)TYPE_ARRAY;
} // endif Vblp
bool was = Vblp->IsCi();
if (was && !p) {
strcpy(g->Message, MSG(BAD_SET_CASE));
throw TYPE_ARRAY;
throw (int)TYPE_ARRAY;
} // endif Vblp
if (was || !p)
......@@ -701,7 +701,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
if (!was && Type == TYPE_STRING)
// Must be resorted to eliminate duplicate strings
if (Sort(g))
throw TYPE_ARRAY;
throw (int)TYPE_ARRAY;
} // end of SetPrecision
......@@ -975,7 +975,7 @@ int ARRAY::BlockTest(PGLOBAL, int opc, int opm,
PSZ ARRAY::MakeArrayList(PGLOBAL g)
{
char *p, *tp;
int i;
int i;
size_t z, len = 2;
if (Type == TYPE_LIST)
......@@ -1035,7 +1035,7 @@ void ARRAY::Printf(PGLOBAL g, FILE *f, uint n)
} else
fprintf(f, "%sVALLST: numval=%d\n", m, Nval);
} // end of Print
} // end of Printf
/***********************************************************************/
/* Make string output of ARRAY contents. */
......@@ -1047,7 +1047,7 @@ void ARRAY::Prints(PGLOBAL, char *ps, uint z)
sprintf(ps, "ARRAY: type=%d\n", Type);
// More to be implemented later
} // end of Print
} // end of Prints
/* -------------------------- Class MULAR ---------------------------- */
......
......@@ -65,7 +65,7 @@ void BLOCKFILTER::Printf(PGLOBAL, FILE *f, uint n)
fprintf(f, "%sBLOCKFILTER: at %p opc=%d opm=%d result=%d\n",
m, this, Opc, Opm, Result);
} // end of Print
} // end of Printf
/***********************************************************************/
/* Make string output of BLOCKFILTER contents. */
......@@ -73,7 +73,7 @@ void BLOCKFILTER::Printf(PGLOBAL, FILE *f, uint n)
void BLOCKFILTER::Prints(PGLOBAL, char *ps, uint z)
{
strncat(ps, "BlockFilter(s)", z);
} // end of Print
} // end of Prints
/* ---------------------- Class BLKFILLOG ---------------------------- */
......@@ -412,7 +412,7 @@ void BLKFILMR2::MakeValueBitmap(void)
Void = !Bmp[N]; // There are no good values in the file
for (i = 0; i < N; i++) {
Bxp[i] = ~0U;
Bxp[i] = ~0;
if (noteq)
Bmp[i] = Bxp[i];
......@@ -708,7 +708,7 @@ void BLKFILIN2::MakeValueBitmap(void)
Void = !Bmp[N]; // There are no good values in the file
for (i = 0; i < N; i++) {
Bxp[i] = ~0U;
Bxp[i] = ~0;
if (noteq) {
Bmp[i] = Bxp[i];
......@@ -828,7 +828,7 @@ BLKFILIN2::BLKFILIN2(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
Bxp[i] |= btp;
for (N = i--; i >= 0; i--)
Bxp[i] = ~0U;
Bxp[i] = ~0;
break;
} // endif Bmp
......@@ -1006,9 +1006,9 @@ void BLOCKINDEX::Printf(PGLOBAL g, FILE *f, UINT n)
m, this, Next, (Colp) ? Colp->GetName() : "Rowid", Kxp, Result);
if (Next)
Next->Print(g, f, n);
Next->Printf(g, f, n);
} // end of Print
} // end of Printf
/***********************************************************************/
/* Make string output of BLOCKINDEX contents. */
......@@ -1016,7 +1016,7 @@ void BLOCKINDEX::Printf(PGLOBAL g, FILE *f, UINT n)
void BLOCKINDEX::Prints(PGLOBAL g, char *ps, UINT z)
{
strncat(ps, "BlockIndex(es)", z);
} // end of Print
} // end of Prints
/* ------------------------------------------------------------------- */
......
This diff is collapsed.
/***********************************************************************/
/* CMgoConn.h : header file for the MongoDB connection classes. */
/***********************************************************************/
/***********************************************************************/
/* Include MongoDB library header files. */
/***********************************************************************/
#include <bson.h>
#include <bcon.h>
#include <mongoc.h>
// C connection to a MongoDB data source
class TDBMGO;
class MGOCOL;
/***********************************************************************/
/* Include MongoDB library header files. */
/***********************************************************************/
typedef class INCOL *PINCOL;
typedef class MGODEF *PMGODEF;
typedef class TDBMGO *PTDBMGO;
typedef class MGOCOL *PMGOCOL;
typedef struct mongo_parms {
PTDB Tdbp;
PCSZ Uristr; // Driver URI
PCSZ Db_name;
PCSZ Coll_name;
PCSZ Options;
PCSZ Filter;
bool Pipe;
//PCSZ User; // User connect info
//PCSZ Pwd; // Password connect info
//int Fsize; // Fetch size
//bool Scrollable; // Scrollable cursor
} CMGOPARM, *PCPARM;
typedef struct KEYCOL {
KEYCOL *Next;
PINCOL Incolp;
PCOL Colp;
char *Key;
} *PKC;
/***********************************************************************/
/* Used when inserting values in a MongoDB collection. */
/***********************************************************************/
class INCOL : public BLOCK {
public:
// Constructor
INCOL(bool ar) { Klist = NULL; Array = ar; }
// Methods
void AddCol(PGLOBAL g, PCOL colp, char *jp);
//Members
bson_t Child;
PKC Klist;
bool Array;
}; // end of INCOL;
/***********************************************************************/
/* CMgoConn class. */
/***********************************************************************/
class CMgoConn : public BLOCK {
friend class TDBMGO;
friend class MGODISC;
public:
// Constructor
CMgoConn(PGLOBAL g, PCPARM pcg);
//static void *mgo_alloc(size_t n);
//static void *mgo_calloc(size_t n, size_t sz);
//static void *mgo_realloc(void *m, size_t n);
//static void mgo_free(void *) {}
// Implementation
bool IsConnected(void) { return m_Connected; }
bool Connect(PGLOBAL g);
int CollSize(PGLOBAL g);
bool MakeCursor(PGLOBAL g);
int ReadNext(PGLOBAL g);
PSZ GetDocument(PGLOBAL g);
void ShowDocument(bson_iter_t *iter, const bson_t *doc, const char *k);
void MakeColumnGroups(PGLOBAL g);
bool DocWrite(PGLOBAL g, PINCOL icp);
int Write(PGLOBAL g);
bool DocDelete(PGLOBAL g);
void Rewind(void);
void Close(void);
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);
protected:
// Members
PCPARM Pcg;
mongoc_uri_t *Uri;
mongoc_client_pool_t *Pool; // Thread safe client pool
mongoc_client_t *Client; // The MongoDB client
mongoc_database_t *Database; // The MongoDB database
mongoc_collection_t *Collection; // The MongoDB collection
mongoc_cursor_t *Cursor;
const bson_t *Document;
bson_t *Query; // MongoDB cursor filter
bson_t *Opts; // MongoDB cursor options
bson_error_t Error;
bson_iter_t Iter; // Used to retrieve column value
bson_iter_t Desc; // Descendant iter
PINCOL Fpc; // To insert INCOL classes
bool m_Connected;
}; // end of class CMgoConn
......@@ -197,7 +197,7 @@ int COLBLK::GetLengthEx(void)
void COLBLK::ReadColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
throw TYPE_COLBLK;
throw (int)TYPE_COLBLK;
} // end of ReadColumn
/***********************************************************************/
......@@ -208,7 +208,7 @@ void COLBLK::ReadColumn(PGLOBAL g)
void COLBLK::WriteColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
throw TYPE_COLBLK;
throw (int)TYPE_COLBLK;
} // end of WriteColumn
/***********************************************************************/
......@@ -232,7 +232,7 @@ void COLBLK::Printf(PGLOBAL, FILE *f, uint n)
fprintf(f,
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n",
ColUse, Status, Buf_Type, Value, Name);
} // end of Print
} // end of Printf
/***********************************************************************/
/* Make string output of a column descriptor block. */
......@@ -240,7 +240,7 @@ void COLBLK::Printf(PGLOBAL, FILE *f, uint n)
void COLBLK::Prints(PGLOBAL, char *ps, uint)
{
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
} // end of Print
} // end of Prints
/***********************************************************************/
......@@ -262,7 +262,7 @@ SPCBLK::SPCBLK(PCOLUMN cp)
void SPCBLK::WriteColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
throw TYPE_COLBLK;
throw (int)TYPE_COLBLK;
} // end of WriteColumn
/***********************************************************************/
......@@ -412,4 +412,3 @@ void SIDBLK::ReadColumn(PGLOBAL)
// } // endif Sname
} // end of ReadColumn
......@@ -38,7 +38,8 @@ class DllExport COLBLK : public XOBJECT {
virtual PTDB GetTo_Tdb(void) {return To_Tdb;}
virtual int GetClustered(void) {return 0;}
virtual int IsClustered(void) {return FALSE;}
PCOL GetNext(void) {return Next;}
virtual PSZ GetJpath(PGLOBAL g, bool proj) {return NULL;}
PCOL GetNext(void) {return Next;}
PSZ GetName(void) {return Name;}
int GetIndex(void) {return Index;}
ushort GetColUse(void) {return ColUse;}
......
/* Copyright (C) Olivier Bertrand 2004 - 2017
/* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -185,10 +185,10 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
/***********************************************************************/
PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
{
PTDB tdbp;
PTDB tdbp = NULL;
PTABLE tabp;
PDBUSER dup = PlgGetUser(g);
volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over longjmp
volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over throw
if (trace)
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
......
/* Copyright (C) Olivier Bertrand 2004 - 2011
/* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -15,6 +15,7 @@
/**************** Cnt H Declares Source Code File (.H) *****************/
/* Name: CONNECT.H Version 2.4 */
/* Author Olivier BERTRAND bertrandop@gmail.com */
/* This file contains the some based classes declares. */
/***********************************************************************/
#include "filamtxt.h"
......
/* Copyright (C) MariaDB Corporation Ab */
#define MSG_ACCESS_VIOLATN "Access violation"
#define MSG_ADD_BAD_TYPE "Array add value type mismatch (%s -> %s)"
#define MSG_ALLOC_ERROR "Error allocating %s"
......
......@@ -696,7 +696,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
} // endif Headlen
/**************************************************************************/
/* Position the file at the beginning of the data. */
/* Position the file at the begining of the data. */
/**************************************************************************/
if (Tdbp->GetMode() == MODE_INSERT)
rc = fseek(Stream, 0, SEEK_END);
......@@ -1036,7 +1036,7 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
} // endif Headlen
/**************************************************************************/
/* Position the file at the beginning of the data. */
/* Position the file at the begining of the data. */
/**************************************************************************/
Fpos = Mempos = Memory + Headlen;
Top--; // Because of EOF marker
......
......@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......
......@@ -455,7 +455,7 @@ bool UNZIPUTL::WildMatch(PCSZ pat, PCSZ str) {
if (!*++pat) return TRUE;
goto loopStart;
default:
if (mapCaseTable[(uchar)*s] != mapCaseTable[(uchar)*p])
if (mapCaseTable[(uint)*s] != mapCaseTable[(uint)*p])
goto starCheck;
break;
} /* endswitch */
......
......@@ -33,11 +33,11 @@
#include "tabcol.h"
#include "xtable.h"
#include "array.h"
//#include "subquery.h"
#include "filter.h"
//#include "token.h"
//#include "select.h"
#include "xindex.h"
#if defined(MONGO_SUPPORT) || defined(JDBC_SUPPORT)
#include "tabext.h"
#endif // MONGO_SUPPORT || JDBC_SUPPORT
/***********************************************************************/
/* Utility routines. */
......@@ -87,7 +87,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
case OP_EXIST: bt = 0x00; break;
default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
throw TYPE_ARRAY;
throw (int)TYPE_ARRAY;
} // endswitch opc
return bt;
......@@ -1406,6 +1406,86 @@ PFIL FILTER::Copy(PTABS t)
} // end of Copy
#endif // 0
#if defined(MONGO_SUPPORT) || defined(JDBC_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 || JDBC_SUPPORT
/*********************************************************************/
/* Make file output of FILTER contents. */
/*********************************************************************/
......@@ -1437,7 +1517,7 @@ void FILTER::Printf(PGLOBAL g, FILE *f, uint n)
} // endfor fp
} // end of Print
} // end of Printf
/***********************************************************************/
/* Make string output of TABLE contents (z should be checked). */
......@@ -1579,7 +1659,7 @@ void FILTER::Prints(PGLOBAL g, char *ps, uint z)
bcp = bxp;
} while (bcp); // enddo
} // end of Print
} // end of Prints
/* -------------------- Derived Classes Functions -------------------- */
......@@ -1697,8 +1777,6 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
if (trace)
htrc("PrepareFilter: fp=%p having=%d\n", fp, having);
//if (fp)
// fp->Print(g, debug, 0);
while (fp) {
if (fp->Opc == OP_SEP)
......@@ -1712,7 +1790,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
break; // Remove eventual ending separator(s)
// if (fp->Convert(g, having))
// throw TYPE_ARRAY;
// (int)throw TYPE_ARRAY;
filp = fp;
fp = fp->Next;
......@@ -1745,7 +1823,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
// return TRUE;
if (filp->Eval(g))
throw TYPE_FILTER;
throw (int)TYPE_FILTER;
if (trace > 1)
htrc("PlugFilter filp=%p result=%d\n",
......
/*************** Filter H Declares Source Code File (.H) ***************/
/* Name: FILTER.H Version 1.2 */
/* Name: FILTER.H Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2010-2015 */
/* (C) Copyright to the author Olivier BERTRAND 2010-2017 */
/* */
/* This file contains the FILTER and derived classes declares. */
/***********************************************************************/
......@@ -61,6 +61,9 @@ 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) || defined(JDBC_SUPPORT)
bool MakeSelector(PGLOBAL g, PSTRG s);
#endif // MONGO_SUPPORT || JDBC_SUPPORT
virtual void Printf(PGLOBAL g, FILE *f, uint n);
virtual void Prints(PGLOBAL g, char *ps, uint z);
// PFIL Linearize(bool nosep);
......
/***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright Olivier Bertrand 1993-2017 */
/* (C) Copyright MariaDB Corporation Ab */
/* Author Olivier Bertrand 1993-2017 */
/***********************************************************************/
/***********************************************************************/
......@@ -90,6 +91,7 @@
#define TYPE_BIGINT 5
#define TYPE_LIST 6
#define TYPE_INT 7
#define TYPE_DATE 8
#define TYPE_DECIM 9
#define TYPE_BIN 10
#define TYPE_PCHAR 11
......
This diff is collapsed.
/* Copyright (C) Olivier Bertrand 2004 - 2015
/* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -14,6 +14,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/** @file ha_connect.h
Author Olivier Bertrand
@brief
The ha_connect engine is a prototype storage engine to access external data.
......
......@@ -193,7 +193,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section )
}
for (key = section->key; key; key = key->next)
if (key->name[0]) {
if (key->name && key->name[0]) {
fprintf(file, "%s", SVP(key->name));
if (key->value)
......
This diff is collapsed.
/***********************************************************************/
/* JavaConn.h : header file for the Java connection classes. */
/***********************************************************************/
/***********************************************************************/
/* Included C-definition files required by the interface. */
/***********************************************************************/
#include "block.h"
#include "jdbccat.h"
/***********************************************************************/
/* Java native interface. */
/***********************************************************************/
#include <jni.h>
/***********************************************************************/
/* Constants and defines. */
/***********************************************************************/
// Miscellaneous sizing info
#define MAX_NUM_OF_MSG 10 // Max number of error messages
//efine MAX_CURRENCY 30 // Max size of Currency($) string
#define MAX_TNAME_LEN 32 // Max size of table names
//efine MAX_FNAME_LEN 256 // Max size of field names
//efine MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names
//efine MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE 0 // TYPE_NULL
#if !defined(__WIN__)
typedef unsigned char *PUCHAR;
#endif // !__WIN__
enum JCATINFO {
CAT_TAB = 1, // JDBC Tables
CAT_COL = 2, // JDBC Columns
CAT_KEY = 3, // JDBC PrimaryKeys
//CAT_STAT = 4, // SQLStatistics
//CAT_SPC = 5 // SQLSpecialColumns
};
/***********************************************************************/
/* This structure is used to control the catalog functions. */
/***********************************************************************/
typedef struct tagJCATPARM {
JCATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer
PCSZ DB; // Database (Schema)
PCSZ Tab; // Table name or pattern
PCSZ Pat; // Table type or column pattern
} JCATPARM;
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
typedef jint(JNICALL *GETJVM) (JavaVM **, jsize, jsize *);
#if defined(_DEBUG)
typedef jint(JNICALL *GETDEF) (void *);
#endif // _DEBUG
class JAVAConn;
/***********************************************************************/
/* JAVAConn class. */
/***********************************************************************/
class JAVAConn : public BLOCK {
friend class TDBJMG;
private:
JAVAConn(); // Standard (unused) constructor
public:
// Constructor
JAVAConn(PGLOBAL g, PCSZ wrapper);
// Set static variables
static void SetJVM(void) {
LibJvm = NULL;
CreateJavaVM = NULL;
GetCreatedJavaVMs = NULL;
#if defined(_DEBUG)
GetDefaultJavaVMInitArgs = NULL;
#endif // _DEBUG
} // end of SetJVM
static void ResetJVM(void);
static bool GetJVM(PGLOBAL g);
// Implementation
public:
//virtual ~JAVAConn();
bool IsOpen(void) { return m_Opened; }
bool IsConnected(void) { return m_Connected; }
// Java operations
protected:
bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig);
bool Check(jint rc = 0);
public:
virtual void AddJars(PSTRG jpop, char sep) = 0;
virtual bool Connect(PJPARM sop) = 0;
virtual bool Open(PGLOBAL g);
virtual bool MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options,
PCSZ filter, bool pipe) = 0;
virtual void Close(void);
protected:
// Members
#if defined(__WIN__)
static HANDLE LibJvm; // Handle to the jvm DLL
#else // !__WIN__
static void *LibJvm; // Handle for the jvm shared library
#endif // !__WIN__
static CRTJVM CreateJavaVM;
static GETJVM GetCreatedJavaVMs;
#if defined(_DEBUG)
static GETDEF GetDefaultJavaVMInitArgs;
#endif // _DEBUG
PGLOBAL m_G;
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
JNIEnv *env; // Pointer to native interface
jclass jdi; // Pointer to the java wrapper class
jobject job; // The java wrapper class object
jmethodID errid; // The GetErrmsg method ID
bool m_Opened;
bool m_Connected;
PCSZ DiscFunc;
PCSZ Msg;
PCSZ m_Wrap;
int m_Rows;
}; // end of JAVAConn class definition
#ifndef __JDBCCAT_H
#define __JDBCCAT_H
// Timeout and net wait defaults
#define DEFAULT_LOGIN_TIMEOUT -1 // means do not set
#define DEFAULT_QUERY_TIMEOUT -1 // means do not set
......@@ -8,9 +11,9 @@ typedef struct jdbc_parms {
PCSZ Url; // Driver URL
PCSZ User; // User connect info
PCSZ Pwd; // Password connect info
//char *Properties; // Connection property list
//int Cto; // Connect timeout
//int Qto; // Query timeout
int Version; // Driver version
int Fsize; // Fetch size
bool Scrollable; // Scrollable cursor
} JDBCPARM, *PJPARM;
......@@ -28,3 +31,5 @@ PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sop);
PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat,
PCSZ tabtyp, int maxres, bool info, PJPARM sop);
PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info);
#endif // __JDBCCAT_H
This diff is collapsed.
/***********************************************************************/
/* JDBConn.h : header file for the JDBC connection classes. */
/***********************************************************************/
//nclude <windows.h> /* Windows include file */
//nclude <windowsx.h> /* Message crackers */
/***********************************************************************/
/* Included C-definition files required by the interface. */
/***********************************************************************/
#include "block.h"
/***********************************************************************/
/* JDBC interface. */
/***********************************************************************/
#include <jni.h>
/***********************************************************************/
/* Constants and defines. */
/***********************************************************************/
// Miscellaneous sizing info
#define MAX_NUM_OF_MSG 10 // Max number of error messages
//efine MAX_CURRENCY 30 // Max size of Currency($) string
#define MAX_TNAME_LEN 32 // Max size of table names
//efine MAX_FNAME_LEN 256 // Max size of field names
//efine MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names
//efine MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE 0 // TYPE_NULL
#if !defined(__WIN__)
typedef unsigned char *PUCHAR;
#endif // !__WIN__
enum JCATINFO {
CAT_TAB = 1, // JDBC Tables
CAT_COL = 2, // JDBC Columns
CAT_KEY = 3, // JDBC PrimaryKeys
//CAT_STAT = 4, // SQLStatistics
//CAT_SPC = 5 // SQLSpecialColumns
};
/***********************************************************************/
/* This structure is used to control the catalog functions. */
/***********************************************************************/
typedef struct tagJCATPARM {
JCATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer
PCSZ DB; // Database (Schema)
PCSZ Tab; // Table name or pattern
PCSZ Pat; // Table type or column pattern
} JCATPARM;
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
typedef jint(JNICALL *GETJVM) (JavaVM **, jsize, jsize *);
#if defined(_DEBUG)
typedef jint(JNICALL *GETDEF) (void *);
#endif // _DEBUG
#include "javaconn.h"
// JDBC connection to a data source
class TDBJDBC;
......@@ -66,7 +12,7 @@ class TDBXJDC;
/***********************************************************************/
/* JDBConn class. */
/***********************************************************************/
class JDBConn : public BLOCK {
class JDBConn : public JAVAConn {
friend class TDBJDBC;
friend class TDBXJDC;
//friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
......@@ -74,118 +20,80 @@ class JDBConn : public BLOCK {
JDBConn(); // Standard (unused) constructor
public:
JDBConn(PGLOBAL g, TDBJDBC *tdbp);
// Constructor
JDBConn(PGLOBAL g, PCSZ wrapper);
int Open(PJPARM sop);
int Rewind(PCSZ sql);
void Close(void);
PQRYRES AllocateResult(PGLOBAL g);
virtual void AddJars(PSTRG jpop, char sep);
PQRYRES AllocateResult(PGLOBAL g, PTDB tdbp);
// Attributes
public:
char *GetQuoteChar(void) { return m_IDQuoteChar; }
// Database successfully opened?
bool IsOpen(void) { return m_Opened; }
//PSZ GetStringInfo(ushort infotype);
int GetMaxValue(int infotype);
//PSZ GetConnect(void) { return m_Connect; }
char *GetQuoteChar(void) { return m_IDQuoteChar; }
virtual int GetMaxValue(int infotype);
public:
// Operations
//void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;}
//void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
//void SetUserName(PSZ user) {m_User = user;}
//void SetUserPwd(PSZ pwd) {m_Pwd = pwd;}
int GetResultSize(PCSZ sql, JDBCCOL *colp);
int ExecuteQuery(PCSZ sql);
int ExecuteUpdate(PCSZ sql);
int Fetch(int pos = 0);
virtual bool Connect(PJPARM sop);
virtual bool MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options,
PCSZ filter, bool pipe) {return true;}
virtual int GetResultSize(PCSZ sql, PCOL colp);
virtual int ExecuteCommand(PCSZ sql);
virtual int ExecuteQuery(PCSZ sql);
virtual int ExecuteUpdate(PCSZ sql);
virtual int Fetch(int pos = 0);
virtual void SetColumnValue(int rank, PSZ name, PVAL val);
// Jdbc operations
bool PrepareSQL(PCSZ sql);
int ExecuteSQL(void);
int ExecuteSQL(void); // Prepared statement
bool SetParam(JDBCCOL *colp);
int ExecSQLcommand(PCSZ sql);
void SetColumnValue(int rank, PSZ name, PVAL val);
int GetCatInfo(JCATPARM *cap);
//bool GetDataSources(PQRYRES qrp);
bool GetDrivers(PQRYRES qrp);
PQRYRES GetMetaData(PGLOBAL g, PCSZ src);
public:
// Set static variables
static void SetJVM(void) {
LibJvm = NULL;
CreateJavaVM = NULL;
GetCreatedJavaVMs = NULL;
#if defined(_DEBUG)
GetDefaultJavaVMInitArgs = NULL;
#endif // _DEBUG
} // end of SetJVM
static void ResetJVM(void);
static bool GetJVM(PGLOBAL g);
int Rewind(PCSZ sql);
// Implementation
public:
//virtual ~JDBConn();
// JDBC operations
protected:
bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig);
bool Check(jint rc = 0);
//void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/);
//void ThrowDJX(PSZ msg);
//void Free(void);
protected:
// Members
#if defined(__WIN__)
static HANDLE LibJvm; // Handle to the jvm DLL
#else // !__WIN__
static void *LibJvm; // Handle for the jvm shared library
#endif // !__WIN__
static CRTJVM CreateJavaVM;
static GETJVM GetCreatedJavaVMs;
#if defined(_DEBUG)
static GETDEF GetDefaultJavaVMInitArgs;
#endif // _DEBUG
PGLOBAL m_G;
TDBJDBC *m_Tdb;
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
JNIEnv *env; // Pointer to native interface
jclass jdi; // Pointer to the java wrapper class
jobject job; // The java wrapper class object
jmethodID xqid; // The ExecuteQuery method ID
jmethodID xuid; // The ExecuteUpdate method ID
jmethodID xid; // The Execute method ID
jmethodID grs; // The GetResult method ID
jmethodID readid; // The ReadNext method ID
jmethodID fetchid; // The Fetch method ID
jmethodID typid; // The ColumnType method ID
jmethodID prepid; // The CreatePrepStmt method ID
jmethodID xpid; // The ExecutePrep method ID
jmethodID pcid; // The ClosePrepStmt method ID
jmethodID errid; // The GetErrmsg method ID
jmethodID objfldid; // The ObjectField method ID
jmethodID chrfldid; // The StringField method ID
jmethodID intfldid; // The IntField method ID
jmethodID dblfldid; // The DoubleField method ID
jmethodID fltfldid; // The FloatField method ID
jmethodID datfldid; // The DateField method ID
jmethodID timfldid; // The TimeField method ID
jmethodID tspfldid; // The TimestampField method ID
jmethodID bigfldid; // The BigintField method ID
PCSZ Msg;
char *m_Wrap;
#if 0
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
JNIEnv *env; // Pointer to native interface
jclass jdi; // Pointer to the java wrapper class
jobject job; // The java wrapper class object
jmethodID errid; // The GetErrmsg method ID
#endif // 0
jmethodID xqid; // The ExecuteQuery method ID
jmethodID xuid; // The ExecuteUpdate method ID
jmethodID xid; // The Execute method ID
jmethodID grs; // The GetResult method ID
jmethodID readid; // The ReadNext method ID
jmethodID fetchid; // The Fetch method ID
jmethodID typid; // The ColumnType method ID
jmethodID prepid; // The CreatePrepStmt method ID
jmethodID xpid; // The ExecutePrep method ID
jmethodID pcid; // The ClosePrepStmt method ID
jmethodID objfldid; // The ObjectField method ID
jmethodID chrfldid; // The StringField method ID
jmethodID intfldid; // The IntField method ID
jmethodID dblfldid; // The DoubleField method ID
jmethodID fltfldid; // The FloatField method ID
jmethodID datfldid; // The DateField method ID
jmethodID timfldid; // The TimeField method ID
jmethodID tspfldid; // The TimestampField method ID
jmethodID bigfldid; // The BigintField method ID
// PCSZ Msg;
// PCSZ m_Wrap;
char m_IDQuoteChar[2];
PCSZ m_Pwd;
int m_Ncol;
int m_Aff;
int m_Rows;
int m_Fetch;
int m_RowsetSize;
jboolean m_Updatable;
jboolean m_Transact;
jboolean m_Scrollable;
bool m_Opened;
bool m_Full;
}; // end of JDBConn class definition
This diff is collapsed.
/************** MongoFam H Declares Source Code File (.H) **************/
/* Name: jmgfam.h Version 1.0 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2017 */
/* */
/* This file contains the JAVA MongoDB access method classes declares */
/***********************************************************************/
#pragma once
/***********************************************************************/
/* Include MongoDB library header files. */
/***********************************************************************/
#include "block.h"
//#include "mongo.h"
#include "jmgoconn.h"
typedef class JMGFAM *PJMGFAM;
typedef class MGODEF *PMGODEF;
/***********************************************************************/
/* This is the Java MongoDB Access Method class declaration. */
/***********************************************************************/
class DllExport JMGFAM : public DOSFAM {
friend void mongo_init(bool);
public:
// Constructor
JMGFAM(PJDEF tdp);
JMGFAM(PJMGFAM txfp);
// Implementation
virtual AMT GetAmType(void) { return TYPE_AM_MGO; }
virtual bool GetUseTemp(void) { return false; }
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) { return (PTXF)new(g) JMGFAM(this); }
void SetLrecl(int lrecl) { Lrecl = lrecl; }
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g) { return false; }
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
virtual bool OpenTempFile(PGLOBAL g) { return false; }
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b) { return false; }
virtual int RenameTempFile(PGLOBAL g) { return RC_OK; }
virtual int InitDelete(PGLOBAL g, int fpos, int spos);
bool Init(PGLOBAL g);
//bool MakeCursor(PGLOBAL g);
// Members
JMgoConn *Jcp; // Points to a Mongo connection class
JDBCPARM Ops; // Additional parameters
PFBLOCK To_Fbt; // Pointer to temp file block
MODE Mode;
PCSZ Uristr;
PCSZ Db_name;
PCSZ Coll_name;
PCSZ Options;
PCSZ Filter;
PSZ Wrapname;
bool Done; // Init done
bool Pipe;
int Version;
int Curpos; // Cursor position of last fetch
}; // end of class JMGFAM
This diff is collapsed.
/***********************************************************************/
/* JMgoConn.h : header file for the MongoDB connection classes. */
/***********************************************************************/
/***********************************************************************/
/* Java interface. */
/***********************************************************************/
#include "javaconn.h"
// Java connection to a MongoDB data source
class TDBJMG;
class JMGCOL;
/***********************************************************************/
/* Include MongoDB library header files. */
/***********************************************************************/
typedef class JNCOL *PJNCOL;
typedef class MGODEF *PMGODEF;
typedef class TDBJMG *PTDBJMG;
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 {
JKCOL *Next;
PJNCOL Jncolp;
PCOL Colp;
char *Key;
int N;
} *PJKC;
/***********************************************************************/
/* Used when inserting values in a MongoDB collection. */
/***********************************************************************/
class JNCOL : public BLOCK {
public:
// Constructor
JNCOL(bool ar) { Klist = NULL; Array = ar; }
// Methods
void AddCol(PGLOBAL g, PCOL colp, PSZ jp);
//Members
PJKC Klist;
bool Array;
}; // end of JNCOL;
/***********************************************************************/
/* JMgoConn class. */
/***********************************************************************/
class JMgoConn : public JAVAConn {
friend class TDBJMG;
//friend class TDBXJDC;
//friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
private:
JMgoConn(); // Standard (unused) constructor
public:
// Constructor
JMgoConn(PGLOBAL g, PCSZ collname, PCSZ wrapper);
// Implementation
public:
virtual void AddJars(PSTRG jpop, char sep);
virtual bool Connect(PJPARM sop);
virtual bool MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options, PCSZ filter, bool pipe);
// PQRYRES AllocateResult(PGLOBAL g, TDBEXT *tdbp, int n);
// Attributes
public:
// virtual int GetMaxValue(int infotype);
public:
// Operations
virtual int Fetch(int pos = 0);
virtual PSZ GetColumnValue(PSZ name);
int CollSize(PGLOBAL g);
bool FindCollection(PCSZ query, PCSZ proj);
bool AggregateCollection(PCSZ pipeline);
void MakeColumnGroups(PGLOBAL g, PTDB tdbp);
bool GetMethodId(PGLOBAL g, MODE mode);
jobject MakeObject(PGLOBAL g, PCOL colp, bool& error);
jobject MakeDoc(PGLOBAL g, PJNCOL jcp);
int DocWrite(PGLOBAL g);
int DocUpdate(PGLOBAL g, PTDB tdbp);
int DocDelete(PGLOBAL g, bool all);
bool Rewind(void);
PSZ GetDocument(void);
protected:
// Members
PCSZ CollName; // The collation name
jmethodID gcollid; // The GetCollection method ID
jmethodID countid; // The GetCollSize method ID
jmethodID fcollid; // The FindColl method ID
jmethodID acollid; // The AggregateColl method ID
jmethodID readid; // The ReadNext method ID
jmethodID fetchid; // The Fetch method ID
jmethodID rewindid; // The Rewind method ID
jmethodID getdocid; // The GetDoc method ID
jmethodID objfldid; // The ObjectField method ID
jmethodID mkdocid; // The MakeDocument method ID
jmethodID docaddid; // The DocAdd method ID
jmethodID mkarid; // The MakeArray method ID
jmethodID araddid; // The ArrayAdd method ID
jmethodID insertid; // The CollInsert method ID
jmethodID updateid; // The CollUpdate method ID
jmethodID deleteid; // The CollDelete method ID
PJNCOL Fpc; // To JNCOL classes
int m_Fetch;
int m_Version; // Java driver version (2 or 3)
}; // end of JMgoConn class definition
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.
/* Copyright (C) MariaDB Corporation Ab */
#define MSG_ACCESS_VIOLATN 200
#define MSG_ADD_BAD_TYPE 201
#define MSG_ALLOC_ERROR 202
......
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.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Copyright (C) MariaDB Corporation Ab */
#ifndef _OS_H_INCLUDED
#define _OS_H_INCLUDED
......
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.
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