Skip to content

Commit f590296

Browse files
committed
-- Finalize work on MongoDB access
Implement discovery for the MongoDB Java Driver Create classes to minimize code and avoid dupicates Rearrange and rename implied files modified: storage/connect/CMakeLists.txt renamed: storage/connect/mongofam.cpp -> storage/connect/cmgfam.cpp renamed: storage/connect/mongofam.h -> storage/connect/cmgfam.h modified: storage/connect/cmgoconn.h modified: storage/connect/javaconn.h modified: storage/connect/jdbconn.cpp modified: storage/connect/jmgoconn.cpp modified: storage/connect/jmgoconn.h modified: storage/connect/mongo.cpp modified: storage/connect/mongo.h renamed: storage/connect/tabmgo.cpp -> storage/connect/tabcmg.cpp renamed: storage/connect/tabmgo.h -> storage/connect/tabcmg.h modified: storage/connect/tabjmg.cpp modified: storage/connect/tabjmg.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h -- Trace Sarea allocation and freeing modified: storage/connect/connect.cc modified: storage/connect/plugutil.cpp modified: storage/connect/user_connect.cc -- Null Json values where not mark as null in JSNX::SetJsonValue This was added in TYPE_NULL (declared as TYPE_VOID) modified: storage/connect/json.cpp modified: storage/connect/json.h modified: storage/connect/jsonudf.cpp -- Null JValues are ignored in JSNX::CalculateArray Also done in tabjson.cpp for JSONCOL::CalculateArray modified: storage/connect/json.h modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjson.cpp -- Null JSON values now represented by connect_json_null session variable modified: storage/connect/json.cpp modified: storage/connect/json.h modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjson.cpp -- JVALUE has size = 1 modified: storage/connect/json.h -- Fix by vuvova because Debian compilation failure. modified: storage/connect/value.cpp
1 parent a9d3201 commit f590296

26 files changed

+994
-587
lines changed

storage/connect/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ ENDIF(CONNECT_WITH_ZIP)
316316
# INCLUDE_DIRECTORIES(${MONGO_INCLUDE_DIR})
317317
# SET(MONGO_LIBRARY ${MONGO_LIBRARIES})
318318
# SET(CONNECT_SOURCES ${CONNECT_SOURCES}
319-
# cmgoconn.cpp mongofam.cpp tabmgo.cpp
320-
# cmgoconn.h mongofam.h tabmgo.h)
319+
# cmgoconn.cpp cmgfam.cpp tabcmg.cpp
320+
# cmgoconn.h cmgfam.h tabcmg.h)
321321
# IF (NOT JAVA_FOUND AND JNI_FOUND)
322322
# SET(CONNECT_SOURCES ${CONNECT_SOURCES} mongo.cpp mongo.h)
323323
# ENDIF (NOT JAVA_FOUND AND JNI_FOUND)

storage/connect/mongofam.cpp renamed to storage/connect/cmgfam.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/************ MONGO FAM C++ Program Source Code File (.CPP) ************/
2-
/* PROGRAM NAME: mongofam.cpp */
1+
/************** CMGFAM C++ Program Source Code File (.CPP) *************/
2+
/* PROGRAM NAME: cmgfam.cpp */
33
/* ------------- */
4-
/* Version 1.3 */
4+
/* Version 1.4 */
55
/* */
66
/* COPYRIGHT: */
77
/* ---------- */
@@ -30,18 +30,18 @@
3030
#include "filamtxt.h"
3131
#include "tabdos.h"
3232
#include "tabjson.h"
33-
#include "mongofam.h"
33+
#include "cmgfam.h"
3434

3535
#if defined(UNIX) || defined(UNIV_LINUX)
3636
#include "osutil.h"
3737
#endif
3838

39-
/* --------------------------- Class MGOFAM -------------------------- */
39+
/* --------------------------- Class CMGFAM -------------------------- */
4040

4141
/***********************************************************************/
4242
/* Constructors. */
4343
/***********************************************************************/
44-
MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
44+
CMGFAM::CMGFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
4545
{
4646
Cmgp = NULL;
4747
Pcg.Tdbp = NULL;
@@ -66,20 +66,20 @@ MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
6666
Mode = MODE_ANY;
6767
Done = false;
6868
Lrecl = tdp->Lrecl + tdp->Ending;
69-
} // end of MGOFAM standard constructor
69+
} // end of CMGFAM standard constructor
7070

71-
MGOFAM::MGOFAM(PMGOFAM tdfp) : DOSFAM(tdfp)
71+
CMGFAM::CMGFAM(PCMGFAM tdfp) : DOSFAM(tdfp)
7272
{
7373
Pcg = tdfp->Pcg;
7474
To_Fbt = tdfp->To_Fbt;
7575
Mode = tdfp->Mode;
7676
Done = tdfp->Done;
77-
} // end of MGOFAM copy constructor
77+
} // end of CMGFAM copy constructor
7878

7979
/***********************************************************************/
8080
/* Reset: reset position values at the beginning of file. */
8181
/***********************************************************************/
82-
void MGOFAM::Reset(void)
82+
void CMGFAM::Reset(void)
8383
{
8484
TXTFAM::Reset();
8585
Fpos = Tpos = Spos = 0;
@@ -88,7 +88,7 @@ void MGOFAM::Reset(void)
8888
/***********************************************************************/
8989
/* MGO GetFileLength: returns file size in number of bytes. */
9090
/***********************************************************************/
91-
int MGOFAM::GetFileLength(PGLOBAL g)
91+
int CMGFAM::GetFileLength(PGLOBAL g)
9292
{
9393
return 0;
9494
} // end of GetFileLength
@@ -98,7 +98,7 @@ int MGOFAM::GetFileLength(PGLOBAL g)
9898
/* This function can be called with a null argument to test the */
9999
/* availability of Cardinality implementation (1 yes, 0 no). */
100100
/***********************************************************************/
101-
int MGOFAM::Cardinality(PGLOBAL g)
101+
int CMGFAM::Cardinality(PGLOBAL g)
102102
{
103103
if (!g)
104104
return 1;
@@ -109,15 +109,15 @@ int MGOFAM::Cardinality(PGLOBAL g)
109109
/***********************************************************************/
110110
/* Note: This function is not really implemented yet. */
111111
/***********************************************************************/
112-
int MGOFAM::MaxBlkSize(PGLOBAL, int s)
112+
int CMGFAM::MaxBlkSize(PGLOBAL, int s)
113113
{
114114
return s;
115115
} // end of MaxBlkSize
116116

117117
/***********************************************************************/
118118
/* Init: initialize MongoDB processing. */
119119
/***********************************************************************/
120-
bool MGOFAM::Init(PGLOBAL g)
120+
bool CMGFAM::Init(PGLOBAL g)
121121
{
122122
if (Done)
123123
return false;
@@ -141,7 +141,7 @@ bool MGOFAM::Init(PGLOBAL g)
141141
/***********************************************************************/
142142
/* OpenTableFile: Open a MongoDB table. */
143143
/***********************************************************************/
144-
bool MGOFAM::OpenTableFile(PGLOBAL g)
144+
bool CMGFAM::OpenTableFile(PGLOBAL g)
145145
{
146146
Mode = Tdbp->GetMode();
147147

@@ -165,31 +165,31 @@ bool MGOFAM::OpenTableFile(PGLOBAL g)
165165
/***********************************************************************/
166166
/* GetRowID: return the RowID of last read record. */
167167
/***********************************************************************/
168-
int MGOFAM::GetRowID(void)
168+
int CMGFAM::GetRowID(void)
169169
{
170170
return Rows;
171171
} // end of GetRowID
172172

173173
/***********************************************************************/
174174
/* GetPos: return the position of last read record. */
175175
/***********************************************************************/
176-
int MGOFAM::GetPos(void)
176+
int CMGFAM::GetPos(void)
177177
{
178178
return Fpos;
179179
} // end of GetPos
180180

181181
/***********************************************************************/
182182
/* GetNextPos: return the position of next record. */
183183
/***********************************************************************/
184-
int MGOFAM::GetNextPos(void)
184+
int CMGFAM::GetNextPos(void)
185185
{
186186
return Fpos;// TODO
187187
} // end of GetNextPos
188188

189189
/***********************************************************************/
190190
/* SetPos: Replace the table at the specified position. */
191191
/***********************************************************************/
192-
bool MGOFAM::SetPos(PGLOBAL g, int pos)
192+
bool CMGFAM::SetPos(PGLOBAL g, int pos)
193193
{
194194
Fpos = pos;
195195
Placed = true;
@@ -199,33 +199,33 @@ bool MGOFAM::SetPos(PGLOBAL g, int pos)
199199
/***********************************************************************/
200200
/* Record file position in case of UPDATE or DELETE. */
201201
/***********************************************************************/
202-
bool MGOFAM::RecordPos(PGLOBAL g)
202+
bool CMGFAM::RecordPos(PGLOBAL g)
203203
{
204-
strcpy(g->Message, "MGOFAM::RecordPos NIY");
204+
strcpy(g->Message, "CMGFAM::RecordPos NIY");
205205
return true;
206206
} // end of RecordPos
207207

208208
/***********************************************************************/
209209
/* Initialize Fpos and the current position for indexed DELETE. */
210210
/***********************************************************************/
211-
int MGOFAM::InitDelete(PGLOBAL g, int fpos, int spos)
211+
int CMGFAM::InitDelete(PGLOBAL g, int fpos, int spos)
212212
{
213-
strcpy(g->Message, "MGOFAM::InitDelete NIY");
213+
strcpy(g->Message, "CMGFAM::InitDelete NIY");
214214
return RC_FX;
215215
} // end of InitDelete
216216

217217
/***********************************************************************/
218218
/* Skip one record in file. */
219219
/***********************************************************************/
220-
int MGOFAM::SkipRecord(PGLOBAL g, bool header)
220+
int CMGFAM::SkipRecord(PGLOBAL g, bool header)
221221
{
222222
return RC_OK; // Dummy
223223
} // end of SkipRecord
224224

225225
/***********************************************************************/
226226
/* ReadBuffer: Get next document from a collection. */
227227
/***********************************************************************/
228-
int MGOFAM::ReadBuffer(PGLOBAL g)
228+
int CMGFAM::ReadBuffer(PGLOBAL g)
229229
{
230230
int rc = Cmgp->ReadNext(g);
231231

@@ -239,23 +239,23 @@ int MGOFAM::ReadBuffer(PGLOBAL g)
239239
/***********************************************************************/
240240
/* WriteBuffer: File write routine for MGO access method. */
241241
/***********************************************************************/
242-
int MGOFAM::WriteBuffer(PGLOBAL g)
242+
int CMGFAM::WriteBuffer(PGLOBAL g)
243243
{
244244
return Cmgp->Write(g);
245245
} // end of WriteBuffer
246246

247247
/***********************************************************************/
248248
/* Data Base delete line routine for MGO and BLK access methods. */
249249
/***********************************************************************/
250-
int MGOFAM::DeleteRecords(PGLOBAL g, int irc)
250+
int CMGFAM::DeleteRecords(PGLOBAL g, int irc)
251251
{
252252
return (irc == RC_OK) ? WriteBuffer(g) : RC_OK;
253253
} // end of DeleteRecords
254254

255255
/***********************************************************************/
256256
/* Table file close routine for MGO access method. */
257257
/***********************************************************************/
258-
void MGOFAM::CloseTableFile(PGLOBAL g, bool)
258+
void CMGFAM::CloseTableFile(PGLOBAL g, bool)
259259
{
260260
Cmgp->Close();
261261
Done = false;
@@ -264,7 +264,7 @@ void MGOFAM::CloseTableFile(PGLOBAL g, bool)
264264
/***********************************************************************/
265265
/* Rewind routine for MGO access method. */
266266
/***********************************************************************/
267-
void MGOFAM::Rewind(void)
267+
void CMGFAM::Rewind(void)
268268
{
269269
Cmgp->Rewind();
270270
} // end of Rewind

storage/connect/mongofam.h renamed to storage/connect/cmgfam.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/************** MongoFam H Declares Source Code File (.H) **************/
2-
/* Name: mongofam.h Version 1.4 */
1+
/*************** CMGFam H Declares Source Code File (.H) ***************/
2+
/* Name: cmgfam.h Version 1.5 */
33
/* */
44
/* (C) Copyright to the author Olivier BERTRAND 2017 */
55
/* */
@@ -8,27 +8,27 @@
88
#include "cmgoconn.h"
99

1010
typedef class TXTFAM *PTXF;
11-
typedef class MGOFAM *PMGOFAM;
11+
typedef class CMGFAM *PCMGFAM;
1212
typedef class MGODEF *PMGODEF;
13-
typedef class TDBMGO *PTDBMGO;
13+
typedef class TDBCMG *PTDBCMG;
1414

1515
/***********************************************************************/
1616
/* This is the MongoDB Access Method class declaration. */
1717
/***********************************************************************/
18-
class DllExport MGOFAM : public DOSFAM {
18+
class DllExport CMGFAM : public DOSFAM {
1919
friend void mongo_init(bool);
2020
public:
2121
// Constructor
22-
MGOFAM(PJDEF tdp);
23-
MGOFAM(PMGOFAM txfp);
22+
CMGFAM(PJDEF tdp);
23+
CMGFAM(PCMGFAM txfp);
2424

2525
// Implementation
2626
virtual AMT GetAmType(void) { return TYPE_AM_MGO; }
2727
virtual bool GetUseTemp(void) { return false; }
2828
virtual int GetPos(void);
2929
virtual int GetNextPos(void);
3030
void SetTdbp(PTDBDOS tdbp) { Tdbp = tdbp; }
31-
virtual PTXF Duplicate(PGLOBAL g) { return (PTXF)new(g) MGOFAM(this); }
31+
virtual PTXF Duplicate(PGLOBAL g) { return (PTXF)new(g) CMGFAM(this); }
3232
void SetLrecl(int lrecl) { Lrecl = lrecl; }
3333

3434
// Methods
@@ -61,5 +61,5 @@ class DllExport MGOFAM : public DOSFAM {
6161
PFBLOCK To_Fbt; // Pointer to temp file block
6262
MODE Mode;
6363
bool Done; // Init done
64-
}; // end of class MGOFAM
64+
}; // end of class CMGFAM
6565

storage/connect/cmgoconn.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
#include <mongoc.h>
1111

1212
// C connection to a MongoDB data source
13-
class TDBMGO;
13+
class TDBCMG;
1414
class MGOCOL;
1515

1616
/***********************************************************************/
1717
/* Include MongoDB library header files. */
1818
/***********************************************************************/
1919
typedef class INCOL *PINCOL;
2020
typedef class MGODEF *PMGODEF;
21-
typedef class TDBMGO *PTDBMGO;
21+
typedef class TDBCMG *PTDBCMG;
2222
typedef class MGOCOL *PMGOCOL;
2323

2424
typedef struct mongo_parms {
@@ -63,8 +63,8 @@ class INCOL : public BLOCK {
6363
/* CMgoConn class. */
6464
/***********************************************************************/
6565
class CMgoConn : public BLOCK {
66-
friend class TDBMGO;
67-
friend class MGODISC;
66+
friend class TDBCMG;
67+
friend class CMGDISC;
6868
public:
6969
// Constructor
7070
CMgoConn(PGLOBAL g, PCPARM pcg);

storage/connect/connect.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,22 @@ PGLOBAL CntExit(PGLOBAL g)
8080
/* CntEndDB: DB termination semantic routine. */
8181
/***********************************************************************/
8282
void CntEndDB(PGLOBAL g)
83-
{
83+
{
8484
PDBUSER dbuserp= PlgGetUser(g);
8585

8686
if (dbuserp) {
8787
if (dbuserp->Catalog)
8888
delete dbuserp->Catalog;
8989

9090
free(dbuserp);
91-
} // endif dbuserp
9291

93-
} // end of CntEndDB
92+
if (trace)
93+
htrc("CntEndDB: Freeing Dup\n");
94+
95+
g->Activityp->Aptr = NULL;
96+
} // endif dbuserp
97+
98+
} // end of CntEndDB
9499

95100
/***********************************************************************/
96101
/* CntCheckDB: Initialize a DB application session. */

storage/connect/global.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,10 @@
5858
/* Miscellaneous Constants */
5959
/***********************************************************************/
6060
#define NO_IVAL -95684275 /* Used by GetIntegerOption */
61-
#define VMLANG 370 /* Size of olf VM lang blocks */
6261
#define MAX_JUMP 24 /* Maximum jump level number */
6362
#define MAX_STR 4160 /* Maximum message length */
64-
#define STR_SIZE 501 /* Length of char strings. */
65-
#define STD_INPUT 0 /* Standard language input */
66-
#define STD_OUTPUT 1 /* Standard language output */
67-
#define ERROR_OUTPUT 2 /* Error message output */
68-
#define DEBUG_OUTPUT 3 /* Debug info output */
69-
#define PROMPT_OUTPUT 4 /* Prompt message output */
70-
#define COPY_OUTPUT 5 /* Copy of language input */
71-
#define STD_MSG 6 /* System message file */
72-
#define DEBUG_MSG 7 /* Debug message file */
73-
#define DUMMY 0 /* Dummy file index in Ldm block */
74-
#define STDIN 1 /* stdin file index in Ldm block */
75-
#define STDOUT 2 /* stdout file index in Ldm block */
76-
#define STDERR 3 /* stderr file index in Ldm block */
77-
#define STDEBUG 4 /* debug file index in Ldm block */
78-
#define STDPRN 5 /* stdprn file index in Ldm block */
79-
#define STDFREE 6 /* Free file index in Ldm block */
8063

81-
#define TYPE_SEM -2 /* Returned semantic function */
82-
#define TYPE_DFONC -2 /* Indirect sem ref in FPARM */
8364
#define TYPE_VOID -1
84-
#define TYPE_SBPAR -1 /* Phrase reference in FPARM */
85-
#define TYPE_SEMX 0 /* Initial semantic function type? */
8665
#define TYPE_ERROR 0
8766
#define TYPE_STRING 1
8867
#define TYPE_DOUBLE 2
@@ -96,34 +75,13 @@
9675
#define TYPE_BIN 10
9776
#define TYPE_PCHAR 11
9877

99-
#if defined(OS32)
100-
#define SYS_STAMP "OS32"
101-
#elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
102-
#define SYS_STAMP "UNIX"
103-
#elif defined(OS16)
104-
#define SYS_STAMP "OS16"
105-
#elif defined(DOSR)
106-
#define SYS_STAMP "DOSR"
107-
#elif defined(WIN)
108-
#define SYS_STAMP "WIN1"
109-
#elif defined(__WIN__)
110-
#define SYS_STAMP "WIN2"
111-
#else
112-
#define SYS_STAMP "XXXX"
113-
#endif
114-
11578
#if defined(__cplusplus)
11679
extern "C" {
11780
#endif
11881

11982
/***********************************************************************/
12083
/* Static variables */
12184
/***********************************************************************/
122-
#if defined(STORAGE)
123-
char sys_stamp[5] = SYS_STAMP;
124-
#else
125-
extern char sys_stamp[];
126-
#endif
12785

12886
/***********************************************************************/
12987
/* File-Selection Indicators */

0 commit comments

Comments
 (0)