mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Add mongoDB access to json tables.
Filalize replacement oflongjmp by throw. modified: storage/connect/CMakeLists.txt modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/colblk.cpp modified: storage/connect/connect.cc modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filter.cpp modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/json.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/plugutil.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h modified: storage/connect/tabmul.cpp modified: storage/connect/tabmysql.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabvir.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xobject.cpp
This commit is contained in:
@@ -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 )
|
||||
|
||||
|
||||
#
|
||||
@@ -291,6 +291,31 @@ IF(CONNECT_WITH_ZIP)
|
||||
add_definitions(-DZIP_SUPPORT -DNOCRYPT)
|
||||
ENDIF(CONNECT_WITH_ZIP)
|
||||
|
||||
#
|
||||
# MONGO (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} mongofam.cpp mongofam.h)
|
||||
# add_definitions(-DMONGO_SUPPORT)
|
||||
# ENDIF(MONGO_FOUND)
|
||||
#ENDIF(CONNECT_WITH_MONGO)
|
||||
|
||||
|
||||
#
|
||||
# XMAP
|
||||
@@ -310,6 +335,6 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
|
||||
STORAGE_ENGINE
|
||||
COMPONENT connect-engine
|
||||
RECOMPILE_FOR_EMBEDDED
|
||||
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
|
||||
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} $(MONGO_LIBRARY)
|
||||
${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY})
|
||||
|
||||
|
@@ -519,11 +519,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
|
||||
|
||||
} else if (opc != OP_EXIST) {
|
||||
sprintf(g->Message, MSG(MISSING_ARG), opc);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_ARRAY;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
#endif // !USE_TRY
|
||||
} else // OP_EXIST
|
||||
return Nval > 0;
|
||||
|
||||
@@ -685,22 +681,14 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
|
||||
{
|
||||
if (Vblp == NULL) {
|
||||
strcpy(g->Message, MSG(PREC_VBLP_NULL));
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_ARRAY;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
#endif // !USE_TRY
|
||||
} // endif Vblp
|
||||
|
||||
bool was = Vblp->IsCi();
|
||||
|
||||
if (was && !p) {
|
||||
strcpy(g->Message, MSG(BAD_SET_CASE));
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_ARRAY;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
#endif // !USE_TRY
|
||||
} // endif Vblp
|
||||
|
||||
if (was || !p)
|
||||
@@ -711,11 +699,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
|
||||
if (!was && Type == TYPE_STRING)
|
||||
// Must be resorted to eliminate duplicate strings
|
||||
if (Sort(g))
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_ARRAY;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
#endif // !USE_TRY
|
||||
|
||||
} // end of SetPrecision
|
||||
|
||||
|
@@ -595,11 +595,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
|
||||
|
||||
if (Colp->GetResultType() != Type) {
|
||||
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
|
||||
#if defined(USE_TRY)
|
||||
throw g->Message;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
#endif // !USE_TRY
|
||||
} else if (Colp->GetValue()->IsCi())
|
||||
Arap->SetPrecision(g, 1); // Case insensitive
|
||||
|
||||
|
@@ -195,13 +195,9 @@ int COLBLK::GetLengthEx(void)
|
||||
/* corresponding to this column and convert it to buffer type. */
|
||||
/***********************************************************************/
|
||||
void COLBLK::ReadColumn(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_COLBLK;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
#endif // !USE_TRY
|
||||
} // end of ReadColumn
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -210,13 +206,9 @@ void COLBLK::ReadColumn(PGLOBAL g)
|
||||
/* corresponding to this column from the column buffer and type. */
|
||||
/***********************************************************************/
|
||||
void COLBLK::WriteColumn(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_COLBLK;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
#endif // !USE_TRY
|
||||
} // end of WriteColumn
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -268,13 +260,9 @@ SPCBLK::SPCBLK(PCOLUMN cp)
|
||||
/* corresponding to this column from the column buffer and type. */
|
||||
/***********************************************************************/
|
||||
void SPCBLK::WriteColumn(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_COLBLK;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
#endif // !USE_TRY
|
||||
} // end of WriteColumn
|
||||
|
||||
/***********************************************************************/
|
||||
|
@@ -200,21 +200,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
|
||||
if (!cat)
|
||||
return NULL;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
tdbp = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Get table object from the catalog
|
||||
tabp = new(g) XTAB(name);
|
||||
|
||||
@@ -227,23 +213,18 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
|
||||
if (!(tdbp = cat->GetTable(g, tabp, mode)))
|
||||
printf("CntGetTDB: %s\n", g->Message);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (trace)
|
||||
printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
|
||||
|
||||
return tdbp;
|
||||
} // end of CntGetTDB
|
||||
} // end of CntGetTDB
|
||||
|
||||
/***********************************************************************/
|
||||
/* OPENTAB: Open a Table. */
|
||||
@@ -267,107 +248,70 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
||||
return true;
|
||||
} // endif tdbp
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!c1) {
|
||||
if (mode == MODE_INSERT)
|
||||
// Allocate all column blocks for that table
|
||||
tdbp->ColDB(g, NULL, 0);
|
||||
|
||||
} else for (p= c1; *p; p+= n) {
|
||||
} else for (p = c1; *p; p += n) {
|
||||
// Allocate only used column blocks
|
||||
if (trace)
|
||||
printf("Allocating column %s\n", p);
|
||||
|
||||
g->Message[0] = 0; // To check whether ColDB made an error message
|
||||
colp= tdbp->ColDB(g, p, 0);
|
||||
colp = tdbp->ColDB(g, p, 0);
|
||||
|
||||
if (!colp && !(mode == MODE_INSERT && tdbp->IsSpecial(p))) {
|
||||
if (g->Message[0] == 0)
|
||||
sprintf(g->Message, MSG(COL_ISNOT_TABLE), p, tdbp->GetName());
|
||||
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} // endif colp
|
||||
|
||||
n= strlen(p) + 1;
|
||||
n = strlen(p) + 1;
|
||||
} // endfor p
|
||||
|
||||
for (i= 0, colp= tdbp->GetColumns(); colp; i++, colp= colp->GetNext()) {
|
||||
for (i = 0, colp = tdbp->GetColumns(); colp; i++, colp = colp->GetNext()) {
|
||||
if (colp->InitValue(g))
|
||||
#if defined(USE_TRY)
|
||||
throw 2;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (mode == MODE_INSERT)
|
||||
// Allow type conversion
|
||||
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
||||
#if defined(USE_TRY)
|
||||
throw 3;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
|
||||
colp->AddColUse(U_P); // For PLG tables
|
||||
} // endfor colp
|
||||
|
||||
/*********************************************************************/
|
||||
/*******************************************************************/
|
||||
/* In Update mode, the updated column blocks must be distinct from */
|
||||
/* the read column blocks. So make a copy of the TDB and allocate */
|
||||
/* its column blocks in mode write (required by XML tables). */
|
||||
/*********************************************************************/
|
||||
/*******************************************************************/
|
||||
if (mode == MODE_UPDATE) {
|
||||
PTDBASE utp;
|
||||
|
||||
if (!(utp= (PTDBASE)tdbp->Duplicate(g))) {
|
||||
if (!(utp = (PTDBASE)tdbp->Duplicate(g))) {
|
||||
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
|
||||
#if defined(USE_TRY)
|
||||
throw 4;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} // endif tp
|
||||
|
||||
if (!c2)
|
||||
// Allocate all column blocks for that table
|
||||
utp->ColDB(g, NULL, 0);
|
||||
else for (p= c2; *p; p+= n) {
|
||||
else for (p = c2; *p; p += n) {
|
||||
// Allocate only used column blocks
|
||||
colp= utp->ColDB(g, p, 0);
|
||||
n= strlen(p) + 1;
|
||||
colp = utp->ColDB(g, p, 0);
|
||||
n = strlen(p) + 1;
|
||||
} // endfor p
|
||||
|
||||
for (i= 0, colp= utp->GetColumns(); colp; i++, colp= colp->GetNext()) {
|
||||
for (i = 0, colp = utp->GetColumns(); colp; i++, colp = colp->GetNext()) {
|
||||
if (colp->InitValue(g))
|
||||
#if defined(USE_TRY)
|
||||
throw 5;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
||||
#if defined(USE_TRY)
|
||||
throw 6;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
|
||||
} // endfor colp
|
||||
|
||||
@@ -381,7 +325,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
||||
printf("Opening table %s in mode %d tdbp=%p\n",
|
||||
tdbp->GetName(), mode, tdbp);
|
||||
|
||||
//tdbp->SetMode(mode);
|
||||
//tdbp->SetMode(mode);
|
||||
|
||||
if (del/* && (tdbp->GetFtype() != RECFM_NAF*/) {
|
||||
// To avoid erasing the table when doing a partial delete
|
||||
@@ -399,29 +343,21 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
||||
if (mode != MODE_ANY && mode != MODE_ALTER) {
|
||||
if (tdbp->OpenDB(g)) {
|
||||
printf("%s\n", g->Message);
|
||||
#if defined(USE_TRY)
|
||||
throw 7;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
tdbp->SetNext(NULL);
|
||||
|
||||
} // endif mode
|
||||
|
||||
rcop= false;
|
||||
rcop = false;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
return rcop;
|
||||
} // end of CntOpenTable
|
||||
|
||||
@@ -441,65 +377,40 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp)
|
||||
/* Evaluate all columns after a record is read. */
|
||||
/***********************************************************************/
|
||||
RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
|
||||
{
|
||||
{
|
||||
RCODE rc= RC_OK;
|
||||
PCOL colp;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
if (trace) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
printf("EvalColumns: %s\n", g->Message);
|
||||
} // endif
|
||||
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
if (trace)
|
||||
printf("Error reading columns: %s\n", g->Message);
|
||||
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
for (colp= tdbp->GetColumns(); rc == RC_OK && colp;
|
||||
colp= colp->GetNext()) {
|
||||
for (colp = tdbp->GetColumns(); rc == RC_OK && colp;
|
||||
colp = colp->GetNext()) {
|
||||
if (reset)
|
||||
colp->Reset();
|
||||
|
||||
// Virtual columns are computed by MariaDB
|
||||
if (!colp->GetColUse(U_VIRTUAL) && (!mrr || colp->GetKcol()))
|
||||
if (colp->Eval(g))
|
||||
rc= RC_FX;
|
||||
rc = RC_FX;
|
||||
|
||||
} // endfor colp
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
printf("Error %d reading columns: %s\n", n, g->Message);
|
||||
|
||||
rc = RC_FX;
|
||||
} catch (const char *msg) {
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
} // end catch
|
||||
|
||||
return rc;
|
||||
} // end of EvalColumns
|
||||
} // end of EvalColumns
|
||||
|
||||
/***********************************************************************/
|
||||
/* ReadNext: Read next record sequentially. */
|
||||
/***********************************************************************/
|
||||
RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
||||
{
|
||||
{
|
||||
RCODE rc;
|
||||
|
||||
if (!tdbp)
|
||||
@@ -514,103 +425,66 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
||||
((PTDBASE)tdbp)->ResetKindex(g, NULL);
|
||||
} // endif index
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
|
||||
if ((setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Do it now to avoid double eval when filtering
|
||||
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
|
||||
for (PCOL colp = tdbp->GetColumns(); colp; colp = colp->GetNext())
|
||||
colp->Reset();
|
||||
|
||||
do {
|
||||
if ((rc= (RCODE)tdbp->ReadDB(g)) == RC_OK)
|
||||
if ((rc = (RCODE)tdbp->ReadDB(g)) == RC_OK)
|
||||
if (!ApplyFilter(g, tdbp->GetFilter()))
|
||||
rc= RC_NF;
|
||||
rc = RC_NF;
|
||||
|
||||
} while (rc == RC_NF);
|
||||
|
||||
if (rc == RC_OK)
|
||||
rc= EvalColumns(g, tdbp, false);
|
||||
rc = EvalColumns(g, tdbp, false);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int) {
|
||||
rc = RC_FX;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
rc = RC_FX;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
return rc;
|
||||
} // end of CntReadNext
|
||||
} // end of CntReadNext
|
||||
|
||||
/***********************************************************************/
|
||||
/* WriteRow: Insert a new row into a table. */
|
||||
/***********************************************************************/
|
||||
RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
|
||||
{
|
||||
{
|
||||
RCODE rc;
|
||||
PCOL colp;
|
||||
//PTDBASE tp= (PTDBASE)tdbp;
|
||||
//PTDBASE tp= (PTDBASE)tdbp;
|
||||
|
||||
if (!tdbp)
|
||||
return RC_FX;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Store column values in table write buffer(s)
|
||||
for (colp= tdbp->GetSetCols(); colp; colp= colp->GetNext())
|
||||
for (colp = tdbp->GetSetCols(); colp; colp = colp->GetNext())
|
||||
if (!colp->GetColUse(U_VIRTUAL))
|
||||
colp->WriteColumn(g);
|
||||
|
||||
if (tdbp->IsIndexed())
|
||||
// Index values must be sorted before updating
|
||||
rc= (RCODE)((PTDBDOS)tdbp)->GetTxfp()->StoreValues(g, true);
|
||||
rc = (RCODE)((PTDBDOS)tdbp)->GetTxfp()->StoreValues(g, true);
|
||||
else
|
||||
// Return result code from write operation
|
||||
rc= (RCODE)tdbp->WriteDB(g);
|
||||
rc = (RCODE)tdbp->WriteDB(g);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
} catch (int n) {
|
||||
printf("Exception %d: %s\n", n, g->Message);
|
||||
rc = RC_FX;
|
||||
} catch (const char *msg) {
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
rc = RC_FX;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
} // end catch
|
||||
|
||||
return rc;
|
||||
} // end of CntWriteRow
|
||||
} // end of CntWriteRow
|
||||
|
||||
/***********************************************************************/
|
||||
/* UpdateRow: Update a row into a table. */
|
||||
@@ -658,9 +532,9 @@ RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all)
|
||||
/* CLOSETAB: Close a table. */
|
||||
/***********************************************************************/
|
||||
int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
|
||||
{
|
||||
int rc= RC_OK;
|
||||
//TDBASE *tbxp= (PTDBASE)tdbp;
|
||||
{
|
||||
int rc = RC_OK;
|
||||
//TDBASE *tbxp= (PTDBASE)tdbp;
|
||||
|
||||
if (!tdbp)
|
||||
return rc; // Nothing to do
|
||||
@@ -677,39 +551,24 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
|
||||
|
||||
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN) {
|
||||
if (tdbp->IsIndexed())
|
||||
rc= ((PTDBDOS)tdbp)->GetTxfp()->DeleteSortedRows(g);
|
||||
rc = ((PTDBDOS)tdbp)->GetTxfp()->DeleteSortedRows(g);
|
||||
|
||||
if (!rc)
|
||||
rc= tdbp->DeleteDB(g, RC_EF); // Specific A.M. delete routine
|
||||
rc = tdbp->DeleteDB(g, RC_EF); // Specific A.M. delete routine
|
||||
|
||||
} else if (tdbp->GetMode() == MODE_UPDATE && tdbp->IsIndexed())
|
||||
rc= ((PTDBDOX)tdbp)->Txfp->UpdateSortedRows(g);
|
||||
rc = ((PTDBDOX)tdbp)->Txfp->UpdateSortedRows(g);
|
||||
|
||||
switch(rc) {
|
||||
switch (rc) {
|
||||
case RC_FX:
|
||||
abort= true;
|
||||
abort = true;
|
||||
break;
|
||||
case RC_INFO:
|
||||
PushWarning(g, tdbp);
|
||||
break;
|
||||
} // endswitch rc
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif
|
||||
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif
|
||||
#endif // !USE_TRY
|
||||
|
||||
// This will close the table file(s) and also finalize write
|
||||
// operations such as Insert, Update, or Delete.
|
||||
tdbp->SetAbort(abort);
|
||||
@@ -733,23 +592,18 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
|
||||
|
||||
} // endif nox
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int) {
|
||||
} catch (int) {
|
||||
rc = RC_FX;
|
||||
} catch (const char *msg) {
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
rc = RC_FX;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
} // end catch
|
||||
|
||||
if (trace > 1)
|
||||
htrc("Done rc=%d\n", rc);
|
||||
|
||||
return (rc == RC_OK || rc == RC_INFO) ? 0 : rc;
|
||||
} // end of CntCloseTable
|
||||
} // end of CntCloseTable
|
||||
|
||||
/***********************************************************************/
|
||||
/* Load and initialize the use of an index. */
|
||||
|
@@ -1174,20 +1174,12 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
|
||||
if (rename(filename, filetemp)) { // Save file for security
|
||||
sprintf(g->Message, MSG(RENAME_ERROR),
|
||||
filename, filetemp, strerror(errno));
|
||||
#if defined(USE_TRY)
|
||||
throw 51;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 51);
|
||||
#endif // !USE_TRY
|
||||
} else if (rename(tempname, filename)) {
|
||||
sprintf(g->Message, MSG(RENAME_ERROR),
|
||||
tempname, filename, strerror(errno));
|
||||
rc = rename(filetemp, filename); // Restore saved file
|
||||
#if defined(USE_TRY)
|
||||
throw 52;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 52);
|
||||
#endif // !USE_TRY
|
||||
} else if (remove(filetemp)) {
|
||||
sprintf(g->Message, MSG(REMOVE_ERROR),
|
||||
filetemp, strerror(errno));
|
||||
|
@@ -559,7 +559,7 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
|
||||
/* Do initial action when inserting. */
|
||||
/***********************************************************************/
|
||||
bool VCTFAM::InitInsert(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
bool rc = false;
|
||||
|
||||
// We come here in MODE_INSERT only
|
||||
@@ -575,26 +575,11 @@ bool VCTFAM::InitInsert(PGLOBAL g)
|
||||
CurBlk = Block - 1;
|
||||
CurNum = Last;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
g->jump_level--;
|
||||
return true;
|
||||
} // endif
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Last block must be updated by new values
|
||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||
cp->ReadBlock(g);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -603,9 +588,7 @@ bool VCTFAM::InitInsert(PGLOBAL g)
|
||||
strcpy(g->Message, msg);
|
||||
rc = true;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
} // endif Last
|
||||
|
||||
if (!rc)
|
||||
@@ -1126,11 +1109,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
|
||||
} else if (AddBlock) {
|
||||
// Last block was not written
|
||||
rc = ResetTableSize(g, CurBlk, Nrec);
|
||||
#if defined(USE_TRY)
|
||||
throw 44;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 44);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
} else if (mode == MODE_UPDATE) {
|
||||
@@ -1550,7 +1529,7 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g)
|
||||
/* Do initial action when inserting. */
|
||||
/***********************************************************************/
|
||||
bool VCMFAM::InitInsert(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
bool rc = false;
|
||||
volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
|
||||
|
||||
@@ -1565,26 +1544,11 @@ bool VCMFAM::InitInsert(PGLOBAL g)
|
||||
CurNum = Last;
|
||||
} // endif Last
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
g->jump_level--;
|
||||
return true;
|
||||
} // endif
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Initialize the column block pointer
|
||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||
cp->ReadBlock(g);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -1593,11 +1557,9 @@ bool VCMFAM::InitInsert(PGLOBAL g)
|
||||
strcpy(g->Message, msg);
|
||||
rc = true;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
return rc;
|
||||
} // end of InitInsert
|
||||
} // end of InitInsert
|
||||
|
||||
/***********************************************************************/
|
||||
/* Data Base write routine for VMP access method. */
|
||||
@@ -2541,11 +2503,7 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
|
||||
if (wrc != RC_FX)
|
||||
rc = ResetTableSize(g, Block, Last);
|
||||
else
|
||||
#if defined(USE_TRY)
|
||||
throw 44;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 44);
|
||||
#endif // !USE_TRY
|
||||
|
||||
} else if (mode == MODE_UPDATE) {
|
||||
if (UseTemp && !InitUpdate && !Abort) {
|
||||
@@ -4206,11 +4164,7 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
|
||||
} else if (AddBlock) {
|
||||
// Last block was not written
|
||||
rc = ResetTableSize(g, CurBlk, Nrec);
|
||||
#if defined(USE_TRY)
|
||||
throw 44;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 44);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
} else if (mode == MODE_UPDATE) {
|
||||
|
@@ -87,11 +87,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
|
||||
case OP_EXIST: bt = 0x00; break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_ARRAY;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch opc
|
||||
|
||||
return bt;
|
||||
@@ -1715,11 +1711,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
|
||||
break; // Remove eventual ending separator(s)
|
||||
|
||||
// if (fp->Convert(g, having))
|
||||
//#if defined(USE_TRY)
|
||||
// throw TYPE_ARRAY;
|
||||
//#else // !USE_TRY
|
||||
// longjmp(g->jumper[g->jump_level], TYPE_FILTER);
|
||||
//#endif // !USE_TRY
|
||||
|
||||
filp = fp;
|
||||
fp = fp->Next;
|
||||
@@ -1752,11 +1744,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
|
||||
// return TRUE;
|
||||
|
||||
if (filp->Eval(g))
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_FILTER;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_FILTER);
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (trace > 1)
|
||||
htrc("PlugFilter filp=%p result=%d\n",
|
||||
|
@@ -172,9 +172,9 @@
|
||||
#define JSONMAX 10 // JSON Default max grp size
|
||||
|
||||
extern "C" {
|
||||
char version[]= "Version 1.05.0003 March 7, 2017";
|
||||
char version[]= "Version 1.06.0001 April 7, 2017";
|
||||
#if defined(__WIN__)
|
||||
char compver[]= "Version 1.05.0003 " __DATE__ " " __TIME__;
|
||||
char compver[]= "Version 1.06.0001 " __DATE__ " " __TIME__;
|
||||
char slash= '\\';
|
||||
#else // !__WIN__
|
||||
char slash= '/';
|
||||
@@ -209,7 +209,7 @@ pthread_mutex_t parmut = PTHREAD_MUTEX_INITIALIZER;
|
||||
/***********************************************************************/
|
||||
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
|
||||
PQRYRES VirColumns(PGLOBAL g, bool info);
|
||||
PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info);
|
||||
PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info);
|
||||
PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info);
|
||||
int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v);
|
||||
void PushWarning(PGLOBAL g, THD *thd, int level);
|
||||
@@ -217,6 +217,7 @@ bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host,
|
||||
const char *db, char *tab, const char *src, int port);
|
||||
bool ZipLoadFile(PGLOBAL, char*, char*, char*, bool, bool);
|
||||
bool ExactInfo(void);
|
||||
void mongo_init(bool);
|
||||
USETEMP UseTemp(void);
|
||||
int GetConvSize(void);
|
||||
TYPCONV GetTypeConv(void);
|
||||
@@ -670,10 +671,14 @@ static int connect_init_func(void *p)
|
||||
sql_print_information("CONNECT: %s", version);
|
||||
#endif // !__WIN__
|
||||
|
||||
#ifdef LIBXML2_SUPPORT
|
||||
#if defined(LIBXML2_SUPPORT)
|
||||
XmlInitParserLib();
|
||||
#endif // LIBXML2_SUPPORT
|
||||
|
||||
#if defined(MONGO_SUPPORT)
|
||||
mongo_init(true);
|
||||
#endif // MONGO_SUPPORT
|
||||
|
||||
init_connect_psi_keys();
|
||||
|
||||
connect_hton= (handlerton *)p;
|
||||
@@ -712,6 +717,10 @@ static int connect_done_func(void *)
|
||||
XmlCleanupParserLib();
|
||||
#endif // LIBXML2_SUPPORT
|
||||
|
||||
#if defined(MONGO_SUPPORT)
|
||||
mongo_init(false);
|
||||
#endif // MONGO_SUPPORT
|
||||
|
||||
#ifdef JDBC_SUPPORT
|
||||
JDBConn::ResetJVM();
|
||||
#endif // JDBC_SUPPORT
|
||||
@@ -1901,41 +1910,21 @@ bool ha_connect::CheckColumnList(PGLOBAL g)
|
||||
Field* fp;
|
||||
MY_BITMAP *map= table->read_set;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif jump_level
|
||||
|
||||
if (!setjmp(g->jumper[++g->jump_level])) {
|
||||
#endif // !USE_TRY
|
||||
for (field= table->field; fp= *field; field++)
|
||||
if (bitmap_is_set(map, fp->field_index)) {
|
||||
if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name, 0))) {
|
||||
sprintf(g->Message, "Column %s not found in %s",
|
||||
fp->field_name, tdbp->GetName());
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
brc = true;
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
} // endif colp
|
||||
|
||||
if ((brc= colp->InitValue(g)))
|
||||
#if defined(USE_TRY)
|
||||
throw 2;
|
||||
#else // !USE_TRY
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
|
||||
colp->AddColUse(U_P); // For PLG tables
|
||||
} // endif
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -1944,13 +1933,7 @@ bool ha_connect::CheckColumnList(PGLOBAL g)
|
||||
strcpy(g->Message, msg);
|
||||
brc = true;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
} else
|
||||
brc = true;
|
||||
|
||||
fin:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return brc;
|
||||
} // end of CheckColumnList
|
||||
|
||||
@@ -3084,28 +3067,16 @@ const COND *ha_connect::cond_push(const COND *cond)
|
||||
tty == TYPE_AM_PLG || tty == TYPE_AM_JDBC || x);
|
||||
|
||||
// This should never happen but is done to avoid crashing
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
DBUG_RETURN(cond);
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]))
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (b) {
|
||||
PCFIL filp;
|
||||
int rc;
|
||||
|
||||
if ((filp= tdbp->GetCondFil()) && filp->Cond == cond &&
|
||||
if ((filp = tdbp->GetCondFil()) && filp->Cond == cond &&
|
||||
filp->Idx == active_index && filp->Type == tty)
|
||||
goto fin;
|
||||
|
||||
filp= new(g) CONDFIL(cond, active_index, tty);
|
||||
filp = new(g) CONDFIL(cond, active_index, tty);
|
||||
rc = filp->Init(g, this);
|
||||
|
||||
if (rc == RC_INFO) {
|
||||
@@ -3127,16 +3098,15 @@ const COND *ha_connect::cond_push(const COND *cond)
|
||||
if (!x)
|
||||
PlugSubAlloc(g, NULL, strlen(filp->Body) + 1);
|
||||
else
|
||||
cond= NULL; // Does this work?
|
||||
cond = NULL; // Does this work?
|
||||
|
||||
tdbp->SetCondFil(filp);
|
||||
} else if (x && cond)
|
||||
tdbp->SetCondFil(filp); // Wrong filter
|
||||
|
||||
} else if (tty != TYPE_AM_JSN && tty != TYPE_AM_JSON)
|
||||
} else // if (tty != TYPE_AM_JSN && tty != TYPE_AM_JSON)
|
||||
tdbp->SetFilter(CondFilter(g, (Item *)cond));
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -3145,10 +3115,6 @@ const COND *ha_connect::cond_push(const COND *cond)
|
||||
} // end catch
|
||||
|
||||
fin:;
|
||||
#else // !USE_TRY
|
||||
fin:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
} // endif tdbp
|
||||
|
||||
// Let MySQL do the filtering
|
||||
@@ -3299,44 +3265,28 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
|
||||
PGLOBAL& g= xp->g;
|
||||
PDBUSER dup= PlgGetUser(g);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif setjmp
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Ignore error on the opt file
|
||||
dup->Check &= ~CHK_OPT;
|
||||
tdbp= GetTDB(g);
|
||||
tdbp = GetTDB(g);
|
||||
dup->Check |= CHK_OPT;
|
||||
|
||||
if (tdbp && !tdbp->IsRemote()) {
|
||||
bool dop= IsTypeIndexable(GetRealType(NULL));
|
||||
bool dox= (tdbp->GetDef()->Indexable() == 1);
|
||||
bool dop = IsTypeIndexable(GetRealType(NULL));
|
||||
bool dox = (tdbp->GetDef()->Indexable() == 1);
|
||||
|
||||
if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, dop, dox))) {
|
||||
if ((rc = ((PTDBASE)tdbp)->ResetTableOpt(g, dop, dox))) {
|
||||
if (rc == RC_INFO) {
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
||||
rc= 0;
|
||||
rc = 0;
|
||||
} else
|
||||
rc= HA_ERR_INTERNAL_ERROR;
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
|
||||
} // endif rc
|
||||
|
||||
} else if (!tdbp)
|
||||
rc= HA_ERR_INTERNAL_ERROR;
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -3345,10 +3295,6 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
|
||||
strcpy(g->Message, msg);
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
return rc;
|
||||
} // end of optimize
|
||||
@@ -5401,25 +5347,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
if (!(shm= (char*)db))
|
||||
db= table_s->db.str; // Default value
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
goto jer;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Check table type
|
||||
if (ttp == TAB_UNDEF) {
|
||||
topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
|
||||
ttp= GetTypeID(topt->type);
|
||||
topt->type = (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
|
||||
ttp = GetTypeID(topt->type);
|
||||
sprintf(g->Message, "No table_type. Was set to %s", topt->type);
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
||||
} else if (ttp == TAB_NIY) {
|
||||
@@ -5439,35 +5371,35 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
goto err;
|
||||
} // endif tbl
|
||||
|
||||
tab= PlugDup(g, tbl);
|
||||
tab = PlugDup(g, tbl);
|
||||
|
||||
if ((p= strchr(tab, ',')))
|
||||
*p= 0;
|
||||
if ((p = strchr(tab, ',')))
|
||||
*p = 0;
|
||||
|
||||
if ((p=strchr(tab, '.'))) {
|
||||
*p= 0;
|
||||
db= tab;
|
||||
tab= p + 1;
|
||||
if ((p = strchr(tab, '.'))) {
|
||||
*p = 0;
|
||||
db = tab;
|
||||
tab = p + 1;
|
||||
} // endif p
|
||||
|
||||
} else if (ttp != TAB_ODBC || !(fnc & (FNC_TABLE | FNC_COL)))
|
||||
tab= table_s->table_name.str; // Default value
|
||||
tab = table_s->table_name.str; // Default value
|
||||
|
||||
} // endif tab
|
||||
|
||||
switch (ttp) {
|
||||
#if defined(ODBC_SUPPORT)
|
||||
case TAB_ODBC:
|
||||
dsn= strz(g, create_info->connect_string);
|
||||
dsn = strz(g, create_info->connect_string);
|
||||
|
||||
if (fnc & (FNC_DSN | FNC_DRIVER)) {
|
||||
ok= true;
|
||||
ok = true;
|
||||
#if defined(PROMPT_OK)
|
||||
} else if (!stricmp(thd->main_security_ctx.host, "localhost")
|
||||
&& cop == 1) {
|
||||
if ((dsn = ODBCCheckConnection(g, dsn, cop)) != NULL) {
|
||||
thd->make_lex_string(&create_info->connect_string, dsn, strlen(dsn));
|
||||
ok= true;
|
||||
ok = true;
|
||||
} // endif dsn
|
||||
#endif // PROMPT_OK
|
||||
|
||||
@@ -5475,13 +5407,13 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
sprintf(g->Message, "Missing %s connection string", topt->type);
|
||||
} else {
|
||||
// Store ODBC additional parameters
|
||||
sop= (POPARM)PlugSubAlloc(g, NULL, sizeof(ODBCPARM));
|
||||
sop->User= (char*)user;
|
||||
sop->Pwd= (char*)pwd;
|
||||
sop->Cto= cto;
|
||||
sop->Qto= qto;
|
||||
sop->UseCnc= cnc;
|
||||
ok= true;
|
||||
sop = (POPARM)PlugSubAlloc(g, NULL, sizeof(ODBCPARM));
|
||||
sop->User = (char*)user;
|
||||
sop->Pwd = (char*)pwd;
|
||||
sop->Cto = cto;
|
||||
sop->Qto = qto;
|
||||
sop->UseCnc = cnc;
|
||||
ok = true;
|
||||
} // endif's
|
||||
|
||||
supfnc |= (FNC_TABLE | FNC_DSN | FNC_DRIVER);
|
||||
@@ -5490,31 +5422,31 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
#if defined(JDBC_SUPPORT)
|
||||
case TAB_JDBC:
|
||||
if (fnc & FNC_DRIVER) {
|
||||
ok= true;
|
||||
} else if (!(url= strz(g, create_info->connect_string))) {
|
||||
ok = true;
|
||||
} else if (!(url = strz(g, create_info->connect_string))) {
|
||||
strcpy(g->Message, "Missing URL");
|
||||
} else {
|
||||
// Store JDBC additional parameters
|
||||
int rc;
|
||||
PJDBCDEF jdef= new(g) JDBCDEF();
|
||||
PJDBCDEF jdef = new(g) JDBCDEF();
|
||||
|
||||
jdef->SetName(create_info->alias);
|
||||
sjp= (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM));
|
||||
sjp->Driver= driver;
|
||||
// sjp->Properties = prop;
|
||||
sjp->Fsize= 0;
|
||||
sjp->Scrollable= false;
|
||||
sjp = (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM));
|
||||
sjp->Driver = driver;
|
||||
// sjp->Properties = prop;
|
||||
sjp->Fsize = 0;
|
||||
sjp->Scrollable = false;
|
||||
|
||||
if ((rc = jdef->ParseURL(g, url, false)) == RC_OK) {
|
||||
sjp->Url= url;
|
||||
sjp->User= (char*)user;
|
||||
sjp->Pwd= (char*)pwd;
|
||||
ok= true;
|
||||
sjp->Url = url;
|
||||
sjp->User = (char*)user;
|
||||
sjp->Pwd = (char*)pwd;
|
||||
ok = true;
|
||||
} else if (rc == RC_NF) {
|
||||
if (jdef->GetTabname())
|
||||
tab= jdef->GetTabname();
|
||||
tab = jdef->GetTabname();
|
||||
|
||||
ok= jdef->SetParms(sjp);
|
||||
ok = jdef->SetParms(sjp);
|
||||
} // endif rc
|
||||
|
||||
} // endif's
|
||||
@@ -5523,7 +5455,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
break;
|
||||
#endif // JDBC_SUPPORT
|
||||
case TAB_DBF:
|
||||
dbf= true;
|
||||
dbf = true;
|
||||
// Passthru
|
||||
case TAB_CSV:
|
||||
if (!fn && fnc != FNC_NO)
|
||||
@@ -5531,56 +5463,56 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
else if (sep && strlen(sep) > 1)
|
||||
sprintf(g->Message, "Invalid separator %s", sep);
|
||||
else
|
||||
ok= true;
|
||||
ok = true;
|
||||
|
||||
break;
|
||||
case TAB_MYSQL:
|
||||
ok= true;
|
||||
ok = true;
|
||||
|
||||
if (create_info->connect_string.str &&
|
||||
create_info->connect_string.length) {
|
||||
PMYDEF mydef= new(g) MYSQLDEF();
|
||||
PMYDEF mydef = new(g) MYSQLDEF();
|
||||
|
||||
dsn= strz(g, create_info->connect_string);
|
||||
dsn = strz(g, create_info->connect_string);
|
||||
mydef->SetName(create_info->alias);
|
||||
|
||||
if (!mydef->ParseURL(g, dsn, false)) {
|
||||
if (mydef->GetHostname())
|
||||
host= mydef->GetHostname();
|
||||
host = mydef->GetHostname();
|
||||
|
||||
if (mydef->GetUsername())
|
||||
user= mydef->GetUsername();
|
||||
user = mydef->GetUsername();
|
||||
|
||||
if (mydef->GetPassword())
|
||||
pwd= mydef->GetPassword();
|
||||
pwd = mydef->GetPassword();
|
||||
|
||||
if (mydef->GetTabschema())
|
||||
db = mydef->GetTabschema();
|
||||
|
||||
if (mydef->GetTabname())
|
||||
tab= mydef->GetTabname();
|
||||
tab = mydef->GetTabname();
|
||||
|
||||
if (mydef->GetPortnumber())
|
||||
port= mydef->GetPortnumber();
|
||||
port = mydef->GetPortnumber();
|
||||
|
||||
} else
|
||||
ok= false;
|
||||
ok = false;
|
||||
|
||||
} else if (!user)
|
||||
user= "root";
|
||||
user = "root";
|
||||
|
||||
if (ok && CheckSelf(g, table_s, host, db, tab, src, port))
|
||||
ok= false;
|
||||
ok = false;
|
||||
|
||||
break;
|
||||
#if defined(__WIN__)
|
||||
case TAB_WMI:
|
||||
ok= true;
|
||||
ok = true;
|
||||
break;
|
||||
#endif // __WIN__
|
||||
#if defined(PIVOT_SUPPORT)
|
||||
case TAB_PIVOT:
|
||||
supfnc= FNC_NO;
|
||||
supfnc = FNC_NO;
|
||||
#endif // PIVOT_SUPPORT
|
||||
case TAB_PRX:
|
||||
case TAB_TBL:
|
||||
@@ -5590,12 +5522,12 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
(!db || !stricmp(db, table_s->db.str)))
|
||||
sprintf(g->Message, "A %s table cannot refer to itself", topt->type);
|
||||
else
|
||||
ok= true;
|
||||
ok = true;
|
||||
|
||||
break;
|
||||
case TAB_OEM:
|
||||
if (topt->module && topt->subtype)
|
||||
ok= true;
|
||||
ok = true;
|
||||
else
|
||||
strcpy(g->Message, "Missing OEM module or subtype");
|
||||
|
||||
@@ -5604,14 +5536,16 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
case TAB_XML:
|
||||
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
|
||||
case TAB_JSON:
|
||||
if (!fn && !zfn && !mul)
|
||||
dsn = strz(g, create_info->connect_string);
|
||||
|
||||
if (!fn && !zfn && !mul && !dsn)
|
||||
sprintf(g->Message, "Missing %s file name", topt->type);
|
||||
else
|
||||
ok= true;
|
||||
ok = true;
|
||||
|
||||
break;
|
||||
case TAB_VIR:
|
||||
ok= true;
|
||||
ok = true;
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, "Cannot get column info for table type %s", topt->type);
|
||||
@@ -5622,12 +5556,12 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
if (ok && !(supfnc & fnc)) {
|
||||
sprintf(g->Message, "Unsupported catalog function %s for table type %s",
|
||||
fncn, topt->type);
|
||||
ok= false;
|
||||
ok = false;
|
||||
} // endif supfnc
|
||||
|
||||
if (src && fnc != FNC_NO) {
|
||||
strcpy(g->Message, "Cannot make catalog table from srcdef");
|
||||
ok= false;
|
||||
ok = false;
|
||||
} // endif src
|
||||
|
||||
if (ok) {
|
||||
@@ -5751,7 +5685,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
qrp = VirColumns(g, fnc == FNC_COL);
|
||||
break;
|
||||
case TAB_JSON:
|
||||
qrp = JSONColumns(g, (char*)db, topt, fnc == FNC_COL);
|
||||
qrp = JSONColumns(g, (char*)db, dsn, topt, fnc == FNC_COL);
|
||||
break;
|
||||
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
|
||||
case TAB_XML:
|
||||
@@ -5994,7 +5928,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
rc = HA_ERR_UNSUPPORTED;
|
||||
} // endif ok
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -6005,16 +5938,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
if (rc)
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
|
||||
#if !defined(USE_TRY)
|
||||
jer:
|
||||
#endif // !USE_TRY
|
||||
PopUser(xp);
|
||||
return rc;
|
||||
} // end of connect_assisted_discovery
|
||||
@@ -7133,10 +7059,10 @@ maria_declare_plugin(connect)
|
||||
PLUGIN_LICENSE_GPL,
|
||||
connect_init_func, /* Plugin Init */
|
||||
connect_done_func, /* Plugin Deinit */
|
||||
0x0105, /* version number (1.05) */
|
||||
0x0106, /* version number (1.05) */
|
||||
NULL, /* status variables */
|
||||
connect_system_variables, /* system variables */
|
||||
"1.05.0003", /* string version */
|
||||
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
|
||||
"1.06.0001", /* string version */
|
||||
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
|
||||
}
|
||||
maria_declare_plugin_end;
|
||||
|
@@ -1200,11 +1200,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
if (rank == 0)
|
||||
if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
|
||||
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name));
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_JDBC;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||
#endif // !USE_TRY
|
||||
} // endif name
|
||||
|
||||
// Returns 666 is case of error
|
||||
@@ -1212,11 +1208,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
|
||||
if (Check((ctyp == 666) ? -1 : 1)) {
|
||||
sprintf(g->Message, "Getting ctyp: %s", Msg);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_JDBC;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
|
||||
if (val->GetNullable())
|
||||
@@ -1322,11 +1314,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
env->DeleteLocalRef(jn);
|
||||
|
||||
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_JDBC;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
|
||||
if (rank == 0)
|
||||
|
@@ -81,64 +81,21 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
||||
if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')))
|
||||
pty[0] = false;
|
||||
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
#if defined(SE_CATCH)
|
||||
// Let's try to recover from any kind of interrupt
|
||||
_se_translator_function f = _set_se_translator(trans_func);
|
||||
|
||||
try {
|
||||
#endif // SE_CATCH --------------------- try section --------------------
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
goto fin;
|
||||
} // endif rc
|
||||
|
||||
#if defined(SE_CATCH) // ------------- end of try section -----------------
|
||||
} catch (SE_Exception e) {
|
||||
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
|
||||
GetExceptionDesc(g, e.nSE), e.nSE);
|
||||
_set_se_translator(f);
|
||||
goto err;
|
||||
} catch (...) {
|
||||
strcpy(g->Message, "Exception doing setjmp");
|
||||
_set_se_translator(f);
|
||||
goto err;
|
||||
} // end of try-catches
|
||||
|
||||
_set_se_translator(f);
|
||||
#endif // SE_CATCH
|
||||
#endif // !USE_TRY
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
switch (s[i]) {
|
||||
case '[':
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseArray(g, ++i, src, pty)))
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
|
||||
break;
|
||||
case '{':
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseObject(g, ++i, src, pty)))
|
||||
#if defined(USE_TRY)
|
||||
throw 2;
|
||||
#else // !USE_TRY
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
|
||||
break;
|
||||
case ' ':
|
||||
@@ -156,12 +113,7 @@ _set_se_translator(f);
|
||||
} // endif pretty
|
||||
|
||||
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty);
|
||||
#if defined(USE_TRY)
|
||||
throw 3;
|
||||
#else // !USE_TRY
|
||||
jsp = NULL;
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
case '(':
|
||||
b = true;
|
||||
break;
|
||||
@@ -175,11 +127,7 @@ _set_se_translator(f);
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseValue(g, i, src, pty)))
|
||||
#if defined(USE_TRY)
|
||||
throw 4;
|
||||
#else // !USE_TRY
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
|
||||
break;
|
||||
}; // endswitch s[i]
|
||||
@@ -197,7 +145,6 @@ _set_se_translator(f);
|
||||
|
||||
} // endif ptyp
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -208,20 +155,12 @@ _set_se_translator(f);
|
||||
} // end catch
|
||||
|
||||
return jsp;
|
||||
#else // !USE_TRY
|
||||
fin:
|
||||
g->jump_level--;
|
||||
return jsp;
|
||||
#endif // !USE_TRY
|
||||
|
||||
tryit:
|
||||
if (pty[0] && (!pretty || pretty > 2)) {
|
||||
if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3)
|
||||
*ptyp = (pty[0]) ? 0 : 3;
|
||||
|
||||
#if !defined(USE_TRY)
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return jsp;
|
||||
} else
|
||||
strcpy(g->Message, "More than one item in file");
|
||||
@@ -626,28 +565,10 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
||||
|
||||
g->Message[0] = 0;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
str = NULL;
|
||||
goto fin;
|
||||
} // endif jmp
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!jsp) {
|
||||
strcpy(g->Message, "Null json tree");
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
} else if (!fn) {
|
||||
// Serialize to a string
|
||||
jp = new(g) JOUTSTR(g);
|
||||
@@ -657,11 +578,7 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"w", (int)errno, fn);
|
||||
strcat(strcat(g->Message, ": "), strerror(errno));
|
||||
#if defined(USE_TRY)
|
||||
throw 2;
|
||||
#else // !USE_TRY
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
} else if (pretty >= 2) {
|
||||
// Serialize to a pretty file
|
||||
jp = new(g)JOUTPRT(g, fs);
|
||||
@@ -702,19 +619,15 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
||||
|
||||
} // endif's
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
str = NULL;
|
||||
} catch (const char *msg) {
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
str = NULL;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
fin:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
} // end catch
|
||||
|
||||
return str;
|
||||
} // end of Serialize
|
||||
|
||||
|
@@ -2921,27 +2921,11 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
if (g->N) {
|
||||
str = (char*)g->Activityp;
|
||||
goto fin;
|
||||
goto err;
|
||||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*is_null = 1;
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
PUSH_WARNING(g->Message);
|
||||
str = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
@@ -2983,7 +2967,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)str;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -2996,12 +2979,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
fin:
|
||||
if (!str) {
|
||||
*is_null = 1;
|
||||
*res_length = 0;
|
||||
@@ -3292,25 +3269,7 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*error = 1;
|
||||
*is_null = 1;
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
PUSH_WARNING(g->Message);
|
||||
*error = 1;
|
||||
path = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
@@ -3348,7 +3307,6 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)path;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -3363,11 +3321,6 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!path) {
|
||||
*res_length = 0;
|
||||
*is_null = 1;
|
||||
@@ -3439,25 +3392,7 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*error = 1;
|
||||
*is_null = 1;
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
PUSH_WARNING(g->Message);
|
||||
*error = 1;
|
||||
path = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
@@ -3496,7 +3431,6 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)path;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -3511,11 +3445,6 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!path) {
|
||||
*res_length = 0;
|
||||
*is_null = 1;
|
||||
@@ -3722,42 +3651,17 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
goto fin;
|
||||
} // endelse
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*error = 1;
|
||||
goto fin;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
PUSH_WARNING(g->Message);
|
||||
str = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true, false, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
#if defined(USE_TRY)
|
||||
throw 2;
|
||||
#else // !USE_TRY
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
@@ -3773,9 +3677,9 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
jsx = new(g)JSNX(g, jsp, TYPE_STRING, initid->max_length, 0, true);
|
||||
|
||||
for (uint i = 1; i+1 < args->arg_count; i += 2) {
|
||||
for (uint i = 1; i + 1 < args->arg_count; i += 2) {
|
||||
jvp = MakeValue(gb, args, i);
|
||||
path = MakePSZ(g, args, i+1);
|
||||
path = MakePSZ(g, args, i + 1);
|
||||
|
||||
if (jsx->SetJpath(g, path, false)) {
|
||||
PUSH_WARNING(g->Message);
|
||||
@@ -3801,7 +3705,6 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)str;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -3812,10 +3715,6 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
PUSH_WARNING(g->Message);
|
||||
str = NULL;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
fin:
|
||||
if (!str) {
|
||||
|
609
storage/connect/mongofam.cpp
Normal file
609
storage/connect/mongofam.cpp
Normal file
@@ -0,0 +1,609 @@
|
||||
/************ MONGO FAM C++ Program Source Code File (.CPP) ************/
|
||||
/* PROGRAM NAME: mongofam.cpp */
|
||||
/* ------------- */
|
||||
/* Version 1.0 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 20017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
/* This program are the MongoDB access method classes. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
/* Include relevant sections of the System header files. */
|
||||
/***********************************************************************/
|
||||
#include "my_global.h"
|
||||
#if defined(__WIN__)
|
||||
//#include <io.h>
|
||||
//#include <fcntl.h>
|
||||
//#include <errno.h>
|
||||
#if defined(__BORLANDC__)
|
||||
#define __MFC_COMPAT__ // To define min/max as macro
|
||||
#endif // __BORLANDC__
|
||||
//#include <windows.h>
|
||||
#else // !__WIN__
|
||||
#if defined(UNIX) || defined(UNIV_LINUX)
|
||||
//#include <errno.h>
|
||||
#include <unistd.h>
|
||||
//#if !defined(sun) // Sun has the ftruncate fnc.
|
||||
//#define USETEMP // Force copy mode for DELETE
|
||||
//#endif // !sun
|
||||
#else // !UNIX
|
||||
//#include <io.h>
|
||||
#endif // !UNIX
|
||||
//#include <fcntl.h>
|
||||
#endif // !__WIN__
|
||||
|
||||
/***********************************************************************/
|
||||
/* Include application header files: */
|
||||
/* global.h is header containing all global declarations. */
|
||||
/* plgdbsem.h is header containing the DB application declarations. */
|
||||
/* filamtxt.h is header containing the file AM classes declarations. */
|
||||
/***********************************************************************/
|
||||
#include "global.h"
|
||||
#include "plgdbsem.h"
|
||||
#include "reldef.h"
|
||||
#include "filamtxt.h"
|
||||
#include "tabdos.h"
|
||||
#include "tabjson.h"
|
||||
#include "mongofam.h"
|
||||
|
||||
#if defined(UNIX) || defined(UNIV_LINUX)
|
||||
#include "osutil.h"
|
||||
//#define _fileno fileno
|
||||
//#define _O_RDONLY O_RDONLY
|
||||
#endif
|
||||
|
||||
//PGLOBAL MGOFAM::G = NULL;
|
||||
|
||||
// Required to initialize libmongoc's internals
|
||||
void mongo_init(bool init)
|
||||
{
|
||||
if (init) {
|
||||
//bson_mem_vtable_t vtable;
|
||||
|
||||
//vtable.malloc = MGOFAM::mgo_alloc;
|
||||
//vtable.calloc = MGOFAM::mgo_calloc;
|
||||
//vtable.realloc = MGOFAM::mgo_realloc;
|
||||
//vtable.free = MGOFAM::mgo_free;
|
||||
mongoc_init();
|
||||
//bson_mem_set_vtable(&vtable);
|
||||
} else {
|
||||
//bson_mem_restore_vtable();
|
||||
mongoc_cleanup();
|
||||
} // endif init
|
||||
|
||||
} // end of mongo_init
|
||||
|
||||
/* --------------------------- Class MGOFAM -------------------------- */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Constructors. */
|
||||
/***********************************************************************/
|
||||
MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
|
||||
{
|
||||
Client = NULL;
|
||||
Database = NULL;
|
||||
Collection = NULL;
|
||||
Cursor = NULL;
|
||||
Query = NULL;
|
||||
Opts = NULL;
|
||||
To_Fbt = NULL;
|
||||
Mode = MODE_ANY;
|
||||
uristr = tdp->Uri;
|
||||
db_name = tdp->Schema;
|
||||
coll_name = tdp->Collname;
|
||||
options = tdp->Options;
|
||||
filter = NULL;
|
||||
Done = false;
|
||||
Lrecl = tdp->Lrecl + tdp->Ending;
|
||||
} // end of MGOFAM standard constructor
|
||||
|
||||
MGOFAM::MGOFAM(PMGOFAM tdfp) : DOSFAM(tdfp)
|
||||
{
|
||||
//G = tdfp->G;
|
||||
Client = tdfp->Client;
|
||||
Database = NULL;
|
||||
Collection = tdfp->Collection;
|
||||
Cursor = tdfp->Cursor;
|
||||
Query = tdfp->Query;
|
||||
Opts = tdfp->Opts;
|
||||
To_Fbt = tdfp->To_Fbt;
|
||||
Mode = tdfp->Mode;
|
||||
Done = tdfp->Done;
|
||||
} // end of MGOFAM copy constructor
|
||||
|
||||
#if 0
|
||||
void *MGOFAM::mgo_alloc(size_t n)
|
||||
{
|
||||
char *mst = (char*)PlgDBSubAlloc(G, NULL, n + sizeof(size_t));
|
||||
|
||||
if (mst) {
|
||||
*(size_t*)mst = n;
|
||||
return mst + sizeof(size_t);
|
||||
} // endif mst
|
||||
|
||||
return NULL;
|
||||
} // end of mgo_alloc
|
||||
|
||||
void *MGOFAM::mgo_calloc(size_t n, size_t sz)
|
||||
{
|
||||
void *m = mgo_alloc(n * sz);
|
||||
|
||||
if (m)
|
||||
memset(m, 0, n * sz);
|
||||
|
||||
return m;
|
||||
} // end of mgo_calloc
|
||||
|
||||
void *MGOFAM::mgo_realloc(void *m, size_t n)
|
||||
{
|
||||
if (!m)
|
||||
return n ? mgo_alloc(n) : NULL;
|
||||
|
||||
size_t *osz = (size_t*)((char*)m - sizeof(size_t));
|
||||
|
||||
if (n > *osz) {
|
||||
void *nwm = mgo_alloc(n);
|
||||
|
||||
if (nwm)
|
||||
memcpy(nwm, m, *osz);
|
||||
|
||||
return nwm;
|
||||
} else {
|
||||
*osz = n;
|
||||
return m;
|
||||
} // endif n
|
||||
|
||||
} // end of mgo_realloc
|
||||
#endif // 0
|
||||
|
||||
/***********************************************************************/
|
||||
/* Reset: reset position values at the beginning of file. */
|
||||
/***********************************************************************/
|
||||
void MGOFAM::Reset(void)
|
||||
{
|
||||
TXTFAM::Reset();
|
||||
Fpos = Tpos = Spos = 0;
|
||||
} // end of Reset
|
||||
|
||||
/***********************************************************************/
|
||||
/* MGO GetFileLength: returns file size in number of bytes. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::GetFileLength(PGLOBAL g)
|
||||
{
|
||||
return 0;
|
||||
} // end of GetFileLength
|
||||
|
||||
/***********************************************************************/
|
||||
/* Cardinality: returns table cardinality in number of rows. */
|
||||
/* This function can be called with a null argument to test the */
|
||||
/* availability of Cardinality implementation (1 yes, 0 no). */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::Cardinality(PGLOBAL g)
|
||||
{
|
||||
if (g) {
|
||||
if (!Init(g)) {
|
||||
int64_t card = mongoc_collection_count(Collection,
|
||||
MONGOC_QUERY_NONE, Query, 0, 0, NULL, &Error);
|
||||
|
||||
if (card < 0)
|
||||
sprintf(g->Message, "Cardinality: %s", Error.message);
|
||||
|
||||
return (int)card;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
} else
|
||||
return 1;
|
||||
|
||||
} // end of Cardinality
|
||||
|
||||
/***********************************************************************/
|
||||
/* Use BlockTest to reduce the table estimated size. */
|
||||
/* Note: This function is not really implemented yet. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::MaxBlkSize(PGLOBAL, int s)
|
||||
{
|
||||
return s;
|
||||
} // end of MaxBlkSize
|
||||
|
||||
/***********************************************************************/
|
||||
/* Init: initialize MongoDB processing. */
|
||||
/***********************************************************************/
|
||||
bool MGOFAM::Init(PGLOBAL g)
|
||||
{
|
||||
if (Done)
|
||||
return false;
|
||||
|
||||
if (options) {
|
||||
char *p = (char*)strchr(options, ';');
|
||||
|
||||
if (p) {
|
||||
*p++ = 0;
|
||||
filter = p;
|
||||
} // endif p
|
||||
|
||||
} // endif opts
|
||||
|
||||
if (filter && *filter) {
|
||||
if (trace)
|
||||
htrc("filter=%s\n", filter);
|
||||
|
||||
Query = bson_new_from_json((const uint8_t *)filter, -1, &Error);
|
||||
|
||||
if (!Query) {
|
||||
sprintf(g->Message, "Wrong filter: %s", Error.message);
|
||||
return true;
|
||||
} // endif Query
|
||||
|
||||
} else
|
||||
Query = bson_new();
|
||||
|
||||
if (options && *options) {
|
||||
if (trace)
|
||||
htrc("options=%s\n", options);
|
||||
|
||||
Opts = bson_new_from_json((const uint8_t *)options, -1, &Error);
|
||||
|
||||
if (!Opts) {
|
||||
sprintf(g->Message, "Wrong options: %s", Error.message);
|
||||
return true;
|
||||
} // endif Opts
|
||||
|
||||
} // endif options
|
||||
|
||||
Uri = mongoc_uri_new(uristr);
|
||||
|
||||
if (!Uri) {
|
||||
sprintf(g->Message, "Failed to parse URI: \"%s\"", uristr);
|
||||
return true;
|
||||
} // endif Uri
|
||||
|
||||
// Create a new client pool instance
|
||||
Pool = mongoc_client_pool_new(Uri);
|
||||
mongoc_client_pool_set_error_api(Pool, 2);
|
||||
|
||||
// Register the application name so we can track it in the profile logs
|
||||
// on the server. This can also be done from the URI.
|
||||
mongoc_client_pool_set_appname(Pool, "Connect");
|
||||
|
||||
// Create a new client instance
|
||||
Client = mongoc_client_pool_pop(Pool);
|
||||
//Client = mongoc_client_new(uristr);
|
||||
|
||||
if (!Client) {
|
||||
sprintf(g->Message, "Failed to get Client");
|
||||
return true;
|
||||
} // endif Client
|
||||
|
||||
//mongoc_client_set_error_api(Client, 2);
|
||||
|
||||
// Register the application name so we can track it in the profile logs
|
||||
// on the server. This can also be done from the URI.
|
||||
//mongoc_client_set_appname(Client, "Connect");
|
||||
|
||||
// Get a handle on the database db_name and collection coll_name
|
||||
// Database = mongoc_client_get_database(Client, db_name);
|
||||
// Collection = mongoc_database_get_collection(Database, coll_name);
|
||||
Collection = mongoc_client_get_collection(Client, db_name, coll_name);
|
||||
|
||||
if (!Collection /*&& Mode != MODE_INSERT*/) {
|
||||
sprintf(g->Message, "Failed to get Collection %s.%s", db_name, coll_name);
|
||||
return true;
|
||||
} // endif Collection
|
||||
|
||||
Done = true;
|
||||
return false;
|
||||
} // end of Init
|
||||
|
||||
/***********************************************************************/
|
||||
/* OpenTableFile: Open a MongoDB table. */
|
||||
/***********************************************************************/
|
||||
bool MGOFAM::OpenTableFile(PGLOBAL g)
|
||||
{
|
||||
//if (!G) {
|
||||
// G = g;
|
||||
// Vtable.malloc = mgo_alloc;
|
||||
// Vtable.calloc = mgo_calloc;
|
||||
// Vtable.realloc = mgo_realloc;
|
||||
// Vtable.free = mgo_free;
|
||||
// bson_mem_set_vtable(&Vtable);
|
||||
//} else {
|
||||
// strcpy(g->Message, "G is not usable");
|
||||
// return true;
|
||||
//} // endif G
|
||||
Mode = Tdbp->GetMode();
|
||||
|
||||
if (Init(g))
|
||||
return true;
|
||||
|
||||
if (Mode == MODE_DELETE && !Tdbp->GetNext()) {
|
||||
// Store the number of deleted lines
|
||||
DelRows = Cardinality(g);
|
||||
|
||||
// Delete all documents
|
||||
if (!mongoc_collection_remove(Collection, MONGOC_REMOVE_NONE,
|
||||
Query, NULL, &Error)) {
|
||||
sprintf(g->Message, "Remove all: %s", Error.message);
|
||||
return true;
|
||||
} // endif remove
|
||||
|
||||
} else if (Mode != MODE_INSERT)
|
||||
Cursor = mongoc_collection_find_with_opts(Collection, Query, Opts, NULL);
|
||||
|
||||
return false;
|
||||
} // end of OpenTableFile
|
||||
|
||||
/***********************************************************************/
|
||||
/* GetRowID: return the RowID of last read record. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::GetRowID(void)
|
||||
{
|
||||
return Rows;
|
||||
} // end of GetRowID
|
||||
|
||||
/***********************************************************************/
|
||||
/* GetPos: return the position of last read record. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::GetPos(void)
|
||||
{
|
||||
return Fpos;
|
||||
} // end of GetPos
|
||||
|
||||
/***********************************************************************/
|
||||
/* GetNextPos: return the position of next record. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::GetNextPos(void)
|
||||
{
|
||||
return Fpos; // TODO
|
||||
} // end of GetNextPos
|
||||
|
||||
/***********************************************************************/
|
||||
/* SetPos: Replace the table at the specified position. */
|
||||
/***********************************************************************/
|
||||
bool MGOFAM::SetPos(PGLOBAL g, int pos)
|
||||
{
|
||||
Fpos = pos;
|
||||
Placed = true;
|
||||
return false;
|
||||
} // end of SetPos
|
||||
|
||||
/***********************************************************************/
|
||||
/* Record file position in case of UPDATE or DELETE. */
|
||||
/***********************************************************************/
|
||||
bool MGOFAM::RecordPos(PGLOBAL g)
|
||||
{
|
||||
strcpy(g->Message, "MGOFAM::RecordPos NIY");
|
||||
return true;
|
||||
} // end of RecordPos
|
||||
|
||||
/***********************************************************************/
|
||||
/* Initialize Fpos and the current position for indexed DELETE. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::InitDelete(PGLOBAL g, int fpos, int spos)
|
||||
{
|
||||
strcpy(g->Message, "MGOFAM::InitDelete NIY");
|
||||
return RC_FX;
|
||||
} // end of InitDelete
|
||||
|
||||
/***********************************************************************/
|
||||
/* Skip one record in file. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::SkipRecord(PGLOBAL g, bool header)
|
||||
{
|
||||
return RC_OK; // Dummy
|
||||
} // end of SkipRecord
|
||||
|
||||
/***********************************************************************/
|
||||
/* Use to trace restaurants document contains. */
|
||||
/***********************************************************************/
|
||||
void MGOFAM::ShowDocument(bson_iter_t *iter, const bson_t *doc, const char *k)
|
||||
{
|
||||
|
||||
if (!doc || bson_iter_init(iter, doc)) {
|
||||
const char *key;
|
||||
|
||||
while (bson_iter_next(iter)) {
|
||||
key = bson_iter_key(iter);
|
||||
htrc("Found element key: \"%s\"\n", key);
|
||||
|
||||
if (BSON_ITER_HOLDS_UTF8(iter))
|
||||
htrc("%s.%s=\"%s\"\n", k, key, bson_iter_utf8(iter, NULL));
|
||||
else if (BSON_ITER_HOLDS_INT32(iter))
|
||||
htrc("%s.%s=%d\n", k, key, bson_iter_int32(iter));
|
||||
else if (BSON_ITER_HOLDS_INT64(iter))
|
||||
htrc("%s.%s=%lld\n", k, key, bson_iter_int64(iter));
|
||||
else if (BSON_ITER_HOLDS_DOUBLE(iter))
|
||||
htrc("%s.%s=%g\n", k, key, bson_iter_double(iter));
|
||||
else if (BSON_ITER_HOLDS_DATE_TIME(iter))
|
||||
htrc("%s.%s=date(%lld)\n", k, key, bson_iter_date_time(iter));
|
||||
else if (BSON_ITER_HOLDS_OID(iter)) {
|
||||
char str[25];
|
||||
|
||||
bson_oid_to_string(bson_iter_oid(iter), str);
|
||||
htrc("%s.%s=%s\n", k, key, str);
|
||||
} else if (BSON_ITER_HOLDS_DECIMAL128(iter)) {
|
||||
char *str = NULL;
|
||||
bson_decimal128_t dec;
|
||||
|
||||
bson_iter_decimal128(iter, &dec);
|
||||
bson_decimal128_to_string(&dec, str);
|
||||
htrc("%s.%s=%s\n", k, key, str);
|
||||
} else if (BSON_ITER_HOLDS_DOCUMENT(iter)) {
|
||||
bson_iter_t child;
|
||||
|
||||
if (bson_iter_recurse(iter, &child))
|
||||
ShowDocument(&child, NULL, key);
|
||||
|
||||
} else if (BSON_ITER_HOLDS_ARRAY(iter)) {
|
||||
bson_t *arr;
|
||||
bson_iter_t itar;
|
||||
const uint8_t *data = NULL;
|
||||
uint32_t len = 0;
|
||||
|
||||
bson_iter_array(iter, &len, &data);
|
||||
arr = bson_new_from_data(data, len);
|
||||
ShowDocument(&itar, arr, key);
|
||||
} // endif's
|
||||
|
||||
} // endwhile bson_iter_next
|
||||
|
||||
} // endif bson_iter_init
|
||||
|
||||
} // end of ShowDocument
|
||||
|
||||
/***********************************************************************/
|
||||
/* ReadBuffer: Get next document from a collection. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::ReadBuffer(PGLOBAL g)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
|
||||
if (mongoc_cursor_next(Cursor, &Document)) {
|
||||
char *str = bson_as_json(Document, NULL);
|
||||
|
||||
if (trace > 1) {
|
||||
bson_iter_t iter;
|
||||
ShowDocument(&iter, Document, "");
|
||||
} else if (trace == 1)
|
||||
htrc("%s\n", str);
|
||||
|
||||
strncpy(Tdbp->GetLine(), str, Lrecl);
|
||||
bson_free(str);
|
||||
} else if (mongoc_cursor_error(Cursor, &Error)) {
|
||||
sprintf(g->Message, "Mongo Cursor Failure: %s", Error.message);
|
||||
rc = RC_FX;
|
||||
} else {
|
||||
//mongoc_cursor_destroy(Cursor);
|
||||
rc = RC_EF;
|
||||
} // endif's Cursor
|
||||
|
||||
return rc;
|
||||
} // end of ReadBuffer
|
||||
|
||||
/***********************************************************************/
|
||||
/* WriteBuffer: File write routine for MGO access method. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::WriteBuffer(PGLOBAL g)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
bson_t *doc;
|
||||
|
||||
//if (Mode == MODE_INSERT && !Collection) {
|
||||
// if ((Database = mongoc_client_get_database(Client, db_name)))
|
||||
// Collection = mongoc_database_create_collection(Database, coll_name,
|
||||
// NULL, &Error);
|
||||
|
||||
// if (!Collection)
|
||||
// if (Database) {
|
||||
// sprintf(g->Message, "Create collection: %s", Error.message);
|
||||
// return RC_FX;
|
||||
// } else {
|
||||
// sprintf(g->Message, "Fail to get database %s", db_name);
|
||||
// return RC_FX;
|
||||
// } // endif Database
|
||||
|
||||
//} // endif Collection
|
||||
|
||||
if (!(doc = bson_new_from_json((const uint8_t *)Tdbp->GetLine(),
|
||||
-1, &Error))) {
|
||||
sprintf(g->Message, "Wrong document: %s", Error.message);
|
||||
return RC_FX;
|
||||
} // endif doc
|
||||
|
||||
if (Mode != MODE_INSERT) {
|
||||
bool b = false;
|
||||
bson_iter_t iter;
|
||||
bson_t *selector = bson_new();
|
||||
|
||||
bson_iter_init(&iter, Document);
|
||||
|
||||
if (bson_iter_find(&iter, "_id")) {
|
||||
if (BSON_ITER_HOLDS_OID(&iter))
|
||||
b = BSON_APPEND_OID(selector, "_id", bson_iter_oid(&iter));
|
||||
else if (BSON_ITER_HOLDS_INT32(&iter))
|
||||
b = BSON_APPEND_INT32(selector, "_id", bson_iter_int32(&iter));
|
||||
else if (BSON_ITER_HOLDS_INT64(&iter))
|
||||
b = BSON_APPEND_INT64(selector, "_id", bson_iter_int64(&iter));
|
||||
else if (BSON_ITER_HOLDS_DOUBLE(&iter))
|
||||
b = BSON_APPEND_DOUBLE(selector, "_id", bson_iter_double(&iter));
|
||||
else if (BSON_ITER_HOLDS_UTF8(&iter))
|
||||
b = BSON_APPEND_UTF8(selector, "_id", bson_iter_utf8(&iter, NULL));
|
||||
|
||||
} // endif iter
|
||||
|
||||
if (!b) {
|
||||
strcpy(g->Message, "Cannot find _id");
|
||||
return RC_FX;
|
||||
} // endif oid
|
||||
|
||||
if (Mode == MODE_DELETE) {
|
||||
if (!mongoc_collection_remove(Collection, MONGOC_REMOVE_NONE,
|
||||
selector, NULL, &Error)) {
|
||||
sprintf(g->Message, "Remove: %s", Error.message);
|
||||
bson_destroy(selector);
|
||||
return RC_FX;
|
||||
} // endif remove
|
||||
|
||||
} else {
|
||||
if (!mongoc_collection_update(Collection, MONGOC_UPDATE_NONE,
|
||||
selector, doc, NULL, &Error)) {
|
||||
sprintf(g->Message, "Update: %s", Error.message);
|
||||
bson_destroy(selector);
|
||||
return RC_FX;
|
||||
} // endif remove
|
||||
|
||||
} // endif Mode
|
||||
|
||||
bson_destroy(selector);
|
||||
} else if (!mongoc_collection_insert(Collection, MONGOC_INSERT_NONE,
|
||||
doc, NULL, &Error)) {
|
||||
sprintf(g->Message, "Inserting: %s", Error.message);
|
||||
rc = RC_FX;
|
||||
} // endif insert
|
||||
|
||||
bson_destroy(doc);
|
||||
return rc;
|
||||
} // end of WriteBuffer
|
||||
|
||||
/***********************************************************************/
|
||||
/* Data Base delete line routine for MGO and BLK access methods. */
|
||||
/***********************************************************************/
|
||||
int MGOFAM::DeleteRecords(PGLOBAL g, int irc)
|
||||
{
|
||||
return (irc == RC_OK) ? WriteBuffer(g) : RC_OK;
|
||||
} // end of DeleteRecords
|
||||
|
||||
/***********************************************************************/
|
||||
/* Table file close routine for MGO access method. */
|
||||
/***********************************************************************/
|
||||
void MGOFAM::CloseTableFile(PGLOBAL g, bool)
|
||||
{
|
||||
if (Query) bson_destroy(Query);
|
||||
if (Opts) bson_destroy(Opts);
|
||||
if (Cursor) mongoc_cursor_destroy(Cursor);
|
||||
if (Collection) mongoc_collection_destroy(Collection);
|
||||
// mongoc_database_destroy(Database);
|
||||
// mongoc_client_destroy(Client);
|
||||
if (Client) mongoc_client_pool_push(Pool, Client);
|
||||
if (Pool) mongoc_client_pool_destroy(Pool);
|
||||
if (Uri) mongoc_uri_destroy(Uri);
|
||||
//bson_mem_restore_vtable();
|
||||
//mongoc_cleanup();
|
||||
//G = NULL;
|
||||
Done = false;
|
||||
} // end of CloseTableFile
|
||||
|
||||
/***********************************************************************/
|
||||
/* Rewind routine for MGO access method. */
|
||||
/***********************************************************************/
|
||||
void MGOFAM::Rewind(void)
|
||||
{
|
||||
// TODO implement me
|
||||
} // end of Rewind
|
||||
|
95
storage/connect/mongofam.h
Normal file
95
storage/connect/mongofam.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/************** MongoFam H Declares Source Code File (.H) **************/
|
||||
/* Name: mongofam.h Version 1.3 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
||||
/* */
|
||||
/* This file contains the MongoDB access method classes declares. */
|
||||
/***********************************************************************/
|
||||
#pragma once
|
||||
|
||||
/***********************************************************************/
|
||||
/* Include MongoDB library header files. */
|
||||
/***********************************************************************/
|
||||
#include <bson.h>
|
||||
#include <bcon.h>
|
||||
#include <mongoc.h>
|
||||
|
||||
#include "block.h"
|
||||
//#include "array.h"
|
||||
|
||||
typedef class TXTFAM *PTXF;
|
||||
typedef class MGOFAM *PMGOFAM;
|
||||
typedef class MGODEF *PMGODEF;
|
||||
typedef class TDBMGO *PTDBMGO;
|
||||
|
||||
/***********************************************************************/
|
||||
/* This is the MongoDB Access Method class declaration. */
|
||||
/***********************************************************************/
|
||||
class DllExport MGOFAM : public DOSFAM {
|
||||
friend void mongo_init(bool);
|
||||
public:
|
||||
// Constructor
|
||||
MGOFAM(PJDEF tdp);
|
||||
MGOFAM(PMGOFAM 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) MGOFAM(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);
|
||||
void ShowDocument(bson_iter_t *i, const bson_t *b, const char *k);
|
||||
//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 *) {}
|
||||
|
||||
|
||||
// Members
|
||||
//static PGLOBAL G;
|
||||
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_mem_vtable_t Vtable;
|
||||
bson_t *Query; // MongoDB cursor filter
|
||||
bson_t *Opts; // MongoDB cursor options
|
||||
bson_error_t Error;
|
||||
PFBLOCK To_Fbt; // Pointer to temp file block
|
||||
MODE Mode;
|
||||
const char *uristr;
|
||||
const char *db_name;
|
||||
const char *coll_name;
|
||||
const char *options;
|
||||
const char *filter;
|
||||
bool Done; // Init done
|
||||
}; // end of class MGOFAM
|
||||
|
@@ -241,7 +241,7 @@ char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop)
|
||||
/***********************************************************************/
|
||||
static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
|
||||
char *tab, PQRYRES qrp)
|
||||
{
|
||||
{
|
||||
size_t i, m, n;
|
||||
CATPARM *cap;
|
||||
|
||||
@@ -249,22 +249,7 @@ static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
|
||||
assert(qrp);
|
||||
#endif
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
cap = NULL;
|
||||
goto fin;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
m = (size_t)qrp->Maxres;
|
||||
n = (size_t)qrp->Nbcol;
|
||||
cap = (CATPARM *)PlugSubAlloc(g, NULL, sizeof(CATPARM));
|
||||
@@ -280,21 +265,17 @@ static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
|
||||
|
||||
cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD));
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
} catch (int n) {
|
||||
htrc("Exeption %d: %s\n", n, g->Message);
|
||||
cap = NULL;
|
||||
} catch (const char *msg) {
|
||||
} catch (const char *msg) {
|
||||
htrc(g->Message, msg);
|
||||
printf("%s\n", g->Message);
|
||||
cap = NULL;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
fin:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
} // end catch
|
||||
|
||||
return cap;
|
||||
} // end of AllocCatInfo
|
||||
} // end of AllocCatInfo
|
||||
|
||||
#if 0
|
||||
/***********************************************************************/
|
||||
|
@@ -143,6 +143,7 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
|
||||
TYPE_AM_MYX = 193, /* MYSQL EXEC access method type */
|
||||
TYPE_AM_CAT = 195, /* Catalog access method type no */
|
||||
TYPE_AM_ZIP = 198, /* ZIP access method type no */
|
||||
TYPE_AM_MGO = 199, /* MGO access method type no */
|
||||
TYPE_AM_OUT = 200}; /* Output relations (storage) */
|
||||
|
||||
enum RECFM {RECFM_NAF = -2, /* Not a file */
|
||||
|
@@ -238,31 +238,16 @@ void ptrc(char const *fmt, ...)
|
||||
PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
|
||||
int *buftyp, XFLD *fldtyp,
|
||||
unsigned int *length, bool blank, bool nonull)
|
||||
{
|
||||
{
|
||||
char cname[NAM_LEN+1];
|
||||
int i;
|
||||
PCOLRES *pcrp, crp;
|
||||
PQRYRES qrp;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
qrp = NULL;
|
||||
goto fin;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
/************************************************************************/
|
||||
/**********************************************************************/
|
||||
/* Allocate the structure used to contain the result set. */
|
||||
/************************************************************************/
|
||||
/**********************************************************************/
|
||||
qrp = (PQRYRES)PlugSubAlloc(g, NULL, sizeof(QRYRES));
|
||||
pcrp = &qrp->Colresp;
|
||||
qrp->Continued = false;
|
||||
@@ -320,7 +305,6 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
|
||||
|
||||
*pcrp = NULL;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
qrp = NULL;
|
||||
@@ -329,12 +313,9 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
|
||||
htrc("%s\n", g->Message);
|
||||
qrp = NULL;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
fin:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
return qrp;
|
||||
} // end of PlgAllocResult
|
||||
} // end of PlgAllocResult
|
||||
|
||||
/***********************************************************************/
|
||||
/* Allocate and initialize the new DB User Block. */
|
||||
@@ -380,11 +361,7 @@ PCATLG PlgGetCatalog(PGLOBAL g, bool jump)
|
||||
if (!cat && jump) {
|
||||
// Raise exception so caller doesn't have to check return value
|
||||
strcpy(g->Message, MSG(NO_ACTIVE_DB));
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 1);
|
||||
#endif // !USE_TRY
|
||||
} // endif cat
|
||||
|
||||
return cat;
|
||||
@@ -495,11 +472,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
|
||||
tp = g->Message;
|
||||
else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) {
|
||||
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
||||
#if defined(USE_TRY)
|
||||
throw OP_LIKE;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||
#endif // !USE_TRY
|
||||
} /* endif tp */
|
||||
|
||||
sp = tp + strlen(pat) + 1;
|
||||
@@ -510,11 +483,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
|
||||
tp = g->Message; /* Use this as temporary work space. */
|
||||
else if (!(tp = new char[strlen(pat) + 1])) {
|
||||
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
||||
#if defined(USE_TRY)
|
||||
throw OP_LIKE;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||
#endif // !USE_TRY
|
||||
} /* endif tp */
|
||||
|
||||
strcpy(tp, pat); /* Make a copy to be worked into */
|
||||
@@ -1547,11 +1516,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
|
||||
PGLOBAL g = t->G;
|
||||
|
||||
sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR));
|
||||
#if defined(USE_TRY)
|
||||
throw 3;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 3);
|
||||
#endif // !USE_TRY
|
||||
} else {
|
||||
tp->Next = t->P1;
|
||||
tp->Num = 0;
|
||||
@@ -1588,22 +1553,14 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
|
||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"rb", (int)errno, fn[i]);
|
||||
strcat(strcat(g->Message, ": "), strerror(errno));
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
// } else
|
||||
// len[i] = 0; // File does not exist yet
|
||||
|
||||
} else {
|
||||
if ((len[i] = _filelength(h[i])) < 0) {
|
||||
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]);
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
} // endif len
|
||||
|
||||
} // endif h
|
||||
|
@@ -519,13 +519,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
||||
if (trace)
|
||||
htrc("PlugSubAlloc: %s\n", g->Message);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
throw 1234;
|
||||
#else // !USE_TRY
|
||||
/* Nothing we can do if longjmp is not initialized. */
|
||||
assert(g->jump_level >= 0);
|
||||
longjmp(g->jumper[g->jump_level], 1);
|
||||
#endif // !USE_TRY
|
||||
} /* endif size OS32 code */
|
||||
|
||||
/*********************************************************************/
|
||||
|
@@ -132,6 +132,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
|
||||
bool map = (am && (*am == 'M' || *am == 'm'));
|
||||
LPCSTR dfm = (am && (*am == 'F' || *am == 'f')) ? "F"
|
||||
: (am && (*am == 'B' || *am == 'b')) ? "B"
|
||||
: (am && (*am == 'X' || *am == 'x')) ? "X"
|
||||
: (am && !stricmp(am, "DBF")) ? "D" : "V";
|
||||
|
||||
if ((Zipped = GetBoolCatInfo("Zipped", false))) {
|
||||
@@ -148,6 +149,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
|
||||
GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf));
|
||||
Recfm = (toupper(*buf) == 'F') ? RECFM_FIX :
|
||||
(toupper(*buf) == 'B') ? RECFM_BIN :
|
||||
(toupper(*buf) == 'X') ? RECFM_NAF : // MGO
|
||||
(toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR;
|
||||
Lrecl = GetIntCatInfo("Lrecl", 0);
|
||||
|
||||
@@ -1511,11 +1513,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
|
||||
if (n == 8 && ctype != TYPE_LIST) {
|
||||
// Should never happen
|
||||
strcpy(g->Message, "Block opt: bad constant");
|
||||
#if defined(USE_TRY)
|
||||
throw 99;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
#endif // !USE_TRY
|
||||
} // endif Conv
|
||||
|
||||
if (type[0] == 1) {
|
||||
@@ -1796,7 +1794,7 @@ err:
|
||||
/* Make a dynamic index. */
|
||||
/***********************************************************************/
|
||||
bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||
{
|
||||
{
|
||||
int k;
|
||||
volatile bool dynamic;
|
||||
bool brc;
|
||||
@@ -1867,17 +1865,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||
} else // Column contains same values as ROWID
|
||||
kxp = new(g) XXROW(this);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
|
||||
if (!setjmp(g->jumper[++g->jump_level])) {
|
||||
#endif // !USE_TRY
|
||||
if (dynamic) {
|
||||
ResetBlockFilter(g);
|
||||
kxp->SetDynamic(dynamic);
|
||||
@@ -1902,7 +1890,6 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||
|
||||
} // endif brc
|
||||
|
||||
#if defined(USE_TRY)
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -1911,14 +1898,9 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||
strcpy(g->Message, msg);
|
||||
brc = true;
|
||||
} // end catch
|
||||
#else // !USE_TRY
|
||||
} else
|
||||
brc = true;
|
||||
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return brc;
|
||||
} // end of InitialyzeIndex
|
||||
} // end of InitialyzeIndex
|
||||
|
||||
/***********************************************************************/
|
||||
/* DOS GetProgMax: get the max value for progress information. */
|
||||
@@ -2139,7 +2121,8 @@ bool TDBDOS::OpenDB(PGLOBAL g)
|
||||
return false;
|
||||
} // endif use
|
||||
|
||||
if (Mode == MODE_DELETE && !Next && Txfp->GetAmType() != TYPE_AM_DOS) {
|
||||
if (Mode == MODE_DELETE && !Next && Txfp->GetAmType() != TYPE_AM_DOS
|
||||
&& Txfp->GetAmType() != TYPE_AM_MGO) {
|
||||
// Delete all lines. Not handled in MAP or block mode
|
||||
Txfp = new(g) DOSFAM((PDOSDEF)To_Def);
|
||||
Txfp->SetTdbp(this);
|
||||
@@ -2537,11 +2520,7 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
||||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
p = tdbp->To_Line + Deplac;
|
||||
@@ -2597,11 +2576,7 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype);
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch Ftype
|
||||
|
||||
// Set null when applicable
|
||||
@@ -2710,11 +2685,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, "Invalid field format for column %s", Name);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch BufType
|
||||
|
||||
p2 = Buf;
|
||||
@@ -2726,11 +2697,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if ((len = strlen(p2)) > field) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Dsp)
|
||||
for (i = 0; i < len; i++)
|
||||
if (p2[i] == '.')
|
||||
|
@@ -411,11 +411,7 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
|
||||
case 'D': M = sizeof(double); break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch Fmt
|
||||
|
||||
} else if (IsTypeChar(Buf_Type))
|
||||
@@ -490,11 +486,7 @@ void BINCOL::ReadColumn(PGLOBAL g)
|
||||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
p = tdbp->To_Line + Deplac;
|
||||
@@ -553,11 +545,7 @@ void BINCOL::ReadColumn(PGLOBAL g)
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch Fmt
|
||||
|
||||
// Set null when applicable
|
||||
@@ -607,11 +595,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
} else if (Value->GetBinValue(p, Long, Status)) {
|
||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
|
||||
Name, Value->GetSize(), Long);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif p
|
||||
|
||||
break;
|
||||
@@ -620,11 +604,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (n > 32767LL || n < -32768LL) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Status)
|
||||
Value->GetValueNonAligned<short>(p, (short)n);
|
||||
|
||||
@@ -634,11 +614,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (n > 255LL || n < -256LL) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Status)
|
||||
*p = (char)n;
|
||||
|
||||
@@ -648,11 +624,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (n > INT_MAX || n < INT_MIN) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Status)
|
||||
Value->GetValueNonAligned<int>(p, (int)n);
|
||||
|
||||
@@ -676,11 +648,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
case 'C': // Characters
|
||||
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
|
||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif n
|
||||
|
||||
if (Status) {
|
||||
@@ -692,11 +660,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch Fmt
|
||||
|
||||
if (Eds && Status) {
|
||||
|
@@ -1435,11 +1435,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
|
||||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
if (tdbp->Mode != MODE_UPDATE) {
|
||||
@@ -1457,11 +1453,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
|
||||
Long = colen; // Restore column length
|
||||
sprintf(g->Message, MSG(FLD_TOO_LNG_FOR),
|
||||
Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} // endif Long
|
||||
|
||||
// Now do the reading
|
||||
@@ -1524,11 +1516,7 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
||||
if ((signed)strlen(p) > flen) {
|
||||
sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen,
|
||||
tdbp->RowNumber(g), tdbp->GetFile(g));
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} else if (Dsp)
|
||||
for (int i = 0; p[i]; i++)
|
||||
if (p[i] == '.')
|
||||
@@ -1544,11 +1532,7 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
||||
if (Fldnum < 0) {
|
||||
// This can happen for wrong offset value in XDB files
|
||||
sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name);
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
strncpy(tdbp->Field[Fldnum], p, flen);
|
||||
|
||||
|
@@ -31,6 +31,9 @@
|
||||
#if defined(ZIP_SUPPORT)
|
||||
#include "filamzip.h"
|
||||
#endif // ZIP_SUPPORT
|
||||
#if defined(MONGO_SUPPORT)
|
||||
#include "mongofam.h"
|
||||
#endif // MONGO_SUPPORT
|
||||
#include "tabmul.h"
|
||||
#include "checklvl.h"
|
||||
#include "resource.h"
|
||||
@@ -63,7 +66,7 @@ typedef struct _jncol {
|
||||
/* JSONColumns: construct the result blocks containing the description */
|
||||
/* of all the columns of a table contained inside a JSON file. */
|
||||
/***********************************************************************/
|
||||
PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
{
|
||||
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
|
||||
TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING};
|
||||
@@ -112,7 +115,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
#endif // ZIP_SUPPORT
|
||||
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
||||
|
||||
if (!tdp->Fn) {
|
||||
if (!tdp->Fn && !dsn) {
|
||||
strcpy(g->Message, MSG(MISSING_FNAME));
|
||||
return NULL;
|
||||
} // endif Fn
|
||||
@@ -126,6 +129,19 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
htrc("File %s objname=%s pretty=%d lvl=%d\n",
|
||||
tdp->Fn, tdp->Objname, tdp->Pretty, lvl);
|
||||
|
||||
if (tdp->Uri = dsn) {
|
||||
#if defined(MONGO_SUPPORT)
|
||||
tdp->Collname = GetStringTableOption(g, topt, "Name", NULL);
|
||||
tdp->Collname = GetStringTableOption(g, topt, "Tabname", tdp->Collname);
|
||||
tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test");
|
||||
tdp->Options = GetStringTableOption(g, topt, "Colist", NULL);
|
||||
tdp->Pretty = 0;
|
||||
#else // !MONGO_SUPPORT
|
||||
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
|
||||
return NULL;
|
||||
#endif // !MONGO_SUPPORT
|
||||
} // endif Uri
|
||||
|
||||
if (tdp->Pretty == 2) {
|
||||
if (tdp->Zipped) {
|
||||
#if defined(ZIP_SUPPORT)
|
||||
@@ -151,12 +167,14 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
|
||||
if (tdp->Zipped) {
|
||||
#if defined(ZIP_SUPPORT)
|
||||
tjnp = new(g)TDBJSN(tdp, new(g)UNZFAM(tdp));
|
||||
tjnp = new(g)TDBJSN(tdp, new(g) UNZFAM(tdp));
|
||||
#else // !ZIP_SUPPORT
|
||||
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
|
||||
return NULL;
|
||||
#endif // !ZIP_SUPPORT
|
||||
} else
|
||||
} else if (tdp->Uri)
|
||||
tjnp = new(g) TDBJSN(tdp, new(g) MGOFAM(tdp));
|
||||
else
|
||||
tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp));
|
||||
|
||||
tjnp->SetMode(MODE_READ);
|
||||
@@ -404,6 +422,10 @@ JSONDEF::JSONDEF(void)
|
||||
Limit = 1;
|
||||
Base = 0;
|
||||
Strict = false;
|
||||
#if defined(MONGO_SUPPORT)
|
||||
Uri = NULL;
|
||||
Collname = Schema = Options = NULL;
|
||||
#endif // MONGO_SUPPORT
|
||||
} // end of JSONDEF constructor
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -417,7 +439,22 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
|
||||
Pretty = GetIntCatInfo("Pretty", 2);
|
||||
Limit = GetIntCatInfo("Limit", 10);
|
||||
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
||||
return DOSDEF::DefineAM(g, "DOS", poff);
|
||||
|
||||
if (Uri = GetStringCatInfo(g, "Connect", NULL)) {
|
||||
#if defined(MONGO_SUPPORT)
|
||||
Collname = GetStringCatInfo(g, "Name",
|
||||
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
||||
Collname = GetStringCatInfo(g, "Tabname", Collname);
|
||||
Schema = GetStringCatInfo(g, "Dbname", "test");
|
||||
Options = GetStringCatInfo(g, "Colist", NULL);
|
||||
Pretty = 0;
|
||||
#else // !MONGO_SUPPORT
|
||||
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
|
||||
return true;
|
||||
#endif // !MONGO_SUPPORT
|
||||
} // endif Uri
|
||||
|
||||
return DOSDEF::DefineAM(g, (Uri ? "XMGO" : "DOS"), poff);
|
||||
} // end of DefineAM
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -463,7 +500,9 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
||||
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
|
||||
return NULL;
|
||||
#endif // !GZ_SUPPORT
|
||||
} else if (map)
|
||||
} else if (Uri)
|
||||
txfp = new(g) MGOFAM(this);
|
||||
else if (map)
|
||||
txfp = new(g) MAPFAM(this);
|
||||
else
|
||||
txfp = new(g) DOSFAM(this);
|
||||
@@ -527,6 +566,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
|
||||
if (tdp) {
|
||||
Jmode = tdp->Jmode;
|
||||
Objname = tdp->Objname;
|
||||
Amtype = (tdp->Uri ? TYPE_AM_MGO : TYPE_AM_JSN);
|
||||
Xcol = tdp->Xcol;
|
||||
Limit = tdp->Limit;
|
||||
Pretty = tdp->Pretty;
|
||||
@@ -535,6 +575,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
|
||||
} else {
|
||||
Jmode = MODE_OBJECT;
|
||||
Objname = NULL;
|
||||
Amtype = TYPE_AM_JSN;
|
||||
Xcol = NULL;
|
||||
Limit = 1;
|
||||
Pretty = 0;
|
||||
@@ -865,16 +906,16 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
||||
|
||||
} // end of PrepareWriting
|
||||
|
||||
/***********************************************************************/
|
||||
/* WriteDB: Data Base write routine for DOS access method. */
|
||||
/***********************************************************************/
|
||||
int TDBJSN::WriteDB(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* WriteDB: Data Base write routine for DOS access method. */
|
||||
/***********************************************************************/
|
||||
int TDBJSN::WriteDB(PGLOBAL g)
|
||||
{
|
||||
int rc = TDBDOS::WriteDB(g);
|
||||
|
||||
#if USE_G
|
||||
if (rc == RC_FX)
|
||||
strcpy(g->Message, G->Message);
|
||||
//if (rc == RC_FX)
|
||||
// strcpy(g->Message, G->Message);
|
||||
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
#endif
|
||||
@@ -882,7 +923,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
||||
return rc;
|
||||
} // end of WriteDB
|
||||
|
||||
/* ---------------------------- JSONCOL ------------------------------ */
|
||||
/* ---------------------------- JSONCOL ------------------------------ */
|
||||
|
||||
/***********************************************************************/
|
||||
/* JSONCOL public constructor. */
|
||||
@@ -1290,11 +1331,7 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n)
|
||||
|
||||
if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) {
|
||||
strcpy(g->Message, "Logical error expanding array");
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
} // endif jvp
|
||||
|
||||
if (n < Nod - 1 && jvp->GetJson()) {
|
||||
@@ -1480,11 +1517,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
||||
{
|
||||
if (Xpd && Tjp->Pretty < 2) {
|
||||
strcpy(g->Message, "Cannot write expanded column when Pretty is not 2");
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
} // endif Xpd
|
||||
|
||||
/*********************************************************************/
|
||||
@@ -1519,11 +1552,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (!(jsp = ParseJson(G, s, (int)strlen(s)))) {
|
||||
strcpy(g->Message, s);
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
} // endif jsp
|
||||
|
||||
if (arp) {
|
||||
@@ -1996,6 +2025,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
|
||||
{
|
||||
Topt = tdp->GetTopt();
|
||||
Db = (char*)tdp->GetDB();
|
||||
Dsn = (char*)tdp->Uri;
|
||||
} // end of TDBJCL constructor
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -2003,7 +2033,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
|
||||
/***********************************************************************/
|
||||
PQRYRES TDBJCL::GetResult(PGLOBAL g)
|
||||
{
|
||||
return JSONColumns(g, Db, Topt, false);
|
||||
return JSONColumns(g, Db, Dsn, Topt, false);
|
||||
} // end of GetResult
|
||||
|
||||
/* --------------------------- End of json --------------------------- */
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*************** tabjson H Declares Source Code File (.H) **************/
|
||||
/* Name: tabjson.h Version 1.2 */
|
||||
/* Name: tabjson.h Version 1.3 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
|
||||
/* */
|
||||
@@ -36,8 +36,11 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */
|
||||
friend class TDBJSON;
|
||||
friend class TDBJSN;
|
||||
friend class TDBJCL;
|
||||
friend PQRYRES JSONColumns(PGLOBAL, char*, PTOS, bool);
|
||||
public:
|
||||
friend PQRYRES JSONColumns(PGLOBAL, char*, char*, PTOS, bool);
|
||||
#if defined(MONGO_SUPPORT)
|
||||
friend class MGOFAM;
|
||||
#endif // MONGO_SUPPORT
|
||||
public:
|
||||
// Constructor
|
||||
JSONDEF(void);
|
||||
|
||||
@@ -58,6 +61,12 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */
|
||||
int Level; /* Used for catalog table */
|
||||
int Base; /* Tne array index base */
|
||||
bool Strict; /* Strict syntax checking */
|
||||
#if defined(MONGO_SUPPORT)
|
||||
const char *Uri; /* MongoDB connection URI */
|
||||
PSZ Collname; /* External collection name */
|
||||
PSZ Schema; /* External schema (DB) name */
|
||||
PSZ Options; /* Colist ; filter */
|
||||
#endif // MONGO_SUPPORT
|
||||
}; // end of JSONDEF
|
||||
|
||||
/* -------------------------- TDBJSN class --------------------------- */
|
||||
@@ -75,7 +84,7 @@ public:
|
||||
TDBJSN(TDBJSN *tdbp);
|
||||
|
||||
// Implementation
|
||||
virtual AMT GetAmType(void) {return TYPE_AM_JSN;}
|
||||
virtual AMT GetAmType(void) {return Amtype;}
|
||||
virtual bool SkipHeader(PGLOBAL g);
|
||||
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);}
|
||||
PJSON GetRow(void) {return Row;}
|
||||
@@ -107,6 +116,7 @@ public:
|
||||
PJSON Val; // The value of the current row
|
||||
PJCOL Colp; // The multiple column
|
||||
JMODE Jmode; // MODE_OBJECT by default
|
||||
AMT Amtype; // Access method type
|
||||
char *Objname; // The table object name
|
||||
char *Xcol; // Name of expandable column
|
||||
int Fpos; // The current row index
|
||||
@@ -233,4 +243,5 @@ class DllExport TDBJCL : public TDBCAT {
|
||||
// Members
|
||||
PTOS Topt;
|
||||
char *Db;
|
||||
char *Dsn;
|
||||
}; // end of class TDBJCL
|
||||
|
@@ -1008,11 +1008,7 @@ void DIRCOL::ReadColumn(PGLOBAL g)
|
||||
#endif // !__WIN__
|
||||
default:
|
||||
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
|
||||
#if defined(USE_TRY)
|
||||
throw GetAmType();
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], GetAmType());
|
||||
#endif // !USE_TRY
|
||||
} // endswitch N
|
||||
|
||||
} // end of ReadColumn
|
||||
@@ -1537,11 +1533,7 @@ void TDBDHR::CloseDB(PGLOBAL g)
|
||||
// Close the search handle.
|
||||
if (!FindClose(Hsearch)) {
|
||||
strcpy(g->Message, MSG(SRCH_CLOSE_ERR));
|
||||
#if defined(USE_TRY)
|
||||
throw GetAmType();
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], GetAmType());
|
||||
#endif // !USE_TRY
|
||||
} // endif FindClose
|
||||
|
||||
iFile = 0;
|
||||
|
@@ -1407,11 +1407,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
|
||||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
tdbp->Fetched = true;
|
||||
|
||||
|
@@ -106,7 +106,7 @@ bool PIVAID::SkipColumn(PCOLRES crp, char *skc)
|
||||
/* Make the Pivot table column list. */
|
||||
/***********************************************************************/
|
||||
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
char *p, *query, *colname, *skc, buf[64];
|
||||
int ndif, nblin, w = 0;
|
||||
bool b = false;
|
||||
@@ -114,20 +114,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
PQRYRES qrp;
|
||||
PCOLRES *pcrp, crp, fncrp = NULL;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Are there columns to skip?
|
||||
if (Skcol) {
|
||||
uint n = strlen(Skcol);
|
||||
@@ -253,8 +240,8 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
} else {
|
||||
// The query was limited, we must get pivot column values
|
||||
// Returned values must be in their original character set
|
||||
// if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
|
||||
// goto err;
|
||||
// if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
|
||||
// goto err;
|
||||
|
||||
query = (char*)PlugSubAlloc(g, NULL, 0);
|
||||
sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname);
|
||||
@@ -310,9 +297,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
|
||||
// We added ndif columns and removed 2 (picol and fncol)
|
||||
Qryp->Nbcol += (ndif - 2);
|
||||
#if defined(USE_TRY)
|
||||
return Qryp;
|
||||
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
@@ -321,19 +306,11 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
#else // !USE_TRY
|
||||
g->jump_level--;
|
||||
return Qryp;
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (b)
|
||||
Myc.Close();
|
||||
|
||||
return NULL;
|
||||
} // end of MakePivotColumns
|
||||
} // end of MakePivotColumns
|
||||
|
||||
/***********************************************************************/
|
||||
/* PIVAID: Compare routine for sorting pivot column values. */
|
||||
|
@@ -511,19 +511,11 @@ void INICOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Flag == 1) {
|
||||
if (tdbp->Mode == MODE_UPDATE) {
|
||||
strcpy(g->Message, MSG(NO_SEC_UPDATE));
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (*p) {
|
||||
tdbp->Section = p;
|
||||
} else
|
||||
@@ -532,11 +524,7 @@ void INICOL::WriteColumn(PGLOBAL g)
|
||||
return;
|
||||
} else if (!tdbp->Section) {
|
||||
strcpy(g->Message, MSG(SEC_NAME_FIRST));
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif's
|
||||
|
||||
/*********************************************************************/
|
||||
@@ -548,11 +536,7 @@ void INICOL::WriteColumn(PGLOBAL g)
|
||||
if (!rc) {
|
||||
sprintf(g->Message, "Error %d writing to %s",
|
||||
GetLastError(), tdbp->Ifile);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif rc
|
||||
|
||||
} // endif Status
|
||||
@@ -853,19 +837,11 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Flag == 1) {
|
||||
if (tdbp->Mode == MODE_UPDATE) {
|
||||
strcpy(g->Message, MSG(NO_SEC_UPDATE));
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (*p) {
|
||||
tdbp->Section = p;
|
||||
} else
|
||||
@@ -875,11 +851,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
||||
} else if (Flag == 2) {
|
||||
if (tdbp->Mode == MODE_UPDATE) {
|
||||
strcpy(g->Message, MSG(NO_KEY_UPDATE));
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (*p) {
|
||||
tdbp->Keycur = p;
|
||||
} else
|
||||
@@ -888,11 +860,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
||||
return;
|
||||
} else if (!tdbp->Section || !tdbp->Keycur) {
|
||||
strcpy(g->Message, MSG(SEC_KEY_FIRST));
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif's
|
||||
|
||||
/*********************************************************************/
|
||||
@@ -904,11 +872,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
||||
if (!rc) {
|
||||
sprintf(g->Message, "Error %d writing to %s",
|
||||
GetLastError(), tdbp->Ifile);
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif rc
|
||||
|
||||
} // endif Status
|
||||
|
@@ -490,11 +490,7 @@ void VCTCOL::ReadBlock(PGLOBAL g)
|
||||
#if defined(_DEBUG)
|
||||
if (!Blk) {
|
||||
strcpy(g->Message, MSG(TO_BLK_IS_NULL));
|
||||
#if defined(USE_TRY)
|
||||
throw 58;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 58);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
#endif
|
||||
|
||||
@@ -502,11 +498,7 @@ void VCTCOL::ReadBlock(PGLOBAL g)
|
||||
/* Read column block according to used access method. */
|
||||
/*********************************************************************/
|
||||
if (txfp->ReadBlock(g, this))
|
||||
#if defined(USE_TRY)
|
||||
throw 6;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 6);
|
||||
#endif // !USE_TRY
|
||||
|
||||
ColBlk = txfp->CurBlk;
|
||||
ColPos = -1; // Any invalid position
|
||||
@@ -526,11 +518,7 @@ void VCTCOL::WriteBlock(PGLOBAL g)
|
||||
#if defined(_DEBUG)
|
||||
if (!Blk) {
|
||||
strcpy(g->Message, MSG(BLK_IS_NULL));
|
||||
#if defined(USE_TRY)
|
||||
throw 56;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 56);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
#endif
|
||||
|
||||
@@ -538,11 +526,7 @@ void VCTCOL::WriteBlock(PGLOBAL g)
|
||||
/* Write column block according to used access method. */
|
||||
/*******************************************************************/
|
||||
if (txfp->WriteBlock(g, this))
|
||||
#if defined(USE_TRY)
|
||||
throw 6;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 6);
|
||||
#endif // !USE_TRY
|
||||
|
||||
Modif = 0;
|
||||
} // endif Modif
|
||||
|
@@ -289,11 +289,7 @@ void VIRCOL::ReadColumn(PGLOBAL g)
|
||||
{
|
||||
// This should never be called
|
||||
sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_COLBLK;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
#endif // !USE_TRY
|
||||
} // end of ReadColumn
|
||||
|
||||
/* ---------------------------TDBVICL class -------------------------- */
|
||||
|
@@ -1314,11 +1314,7 @@ void TDBXML::CloseDB(PGLOBAL g)
|
||||
Docp->CloseDoc(g, To_Xb);
|
||||
|
||||
// This causes a crash in Diagnostics_area::set_error_status
|
||||
//#if defined(USE_TRY)
|
||||
// throw TYPE_AM_XML;
|
||||
//#else // !USE_TRY
|
||||
// longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
//#endif // !USE_TRY
|
||||
} // endif DumpDoc
|
||||
|
||||
} // endif Changed
|
||||
@@ -1641,11 +1637,7 @@ void XMLCOL::ReadColumn(PGLOBAL g)
|
||||
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
||||
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
||||
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endif type
|
||||
|
||||
// Get the Xname value from the XML file
|
||||
@@ -1656,11 +1648,7 @@ void XMLCOL::ReadColumn(PGLOBAL g)
|
||||
PushWarning(g, Tdbp);
|
||||
break;
|
||||
default:
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch
|
||||
|
||||
Value->SetValue_psz(Valbuf);
|
||||
@@ -1711,11 +1699,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
||||
/* For columns having an Xpath, the Clist must be updated. */
|
||||
/*********************************************************************/
|
||||
if (Tdbp->CheckRow(g, Nod || Tdbp->Colname))
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
|
||||
/*********************************************************************/
|
||||
/* Null values are represented by no node. */
|
||||
@@ -1787,15 +1771,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (ColNode == NULL) {
|
||||
strcpy(g->Message, MSG(COL_ALLOC_ERR));
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
#endif // !USE_TRY
|
||||
} // endif ColNode
|
||||
|
||||
} // endif ColNode
|
||||
@@ -1824,11 +1800,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
strcpy(Valbuf, p);
|
||||
|
||||
@@ -1878,11 +1850,7 @@ void XMULCOL::ReadColumn(PGLOBAL g)
|
||||
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
||||
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
||||
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endif type
|
||||
|
||||
// Get the Xname value from the XML file
|
||||
@@ -1968,11 +1936,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
||||
/* For columns having an Xpath, the Clist must be updated. */
|
||||
/*********************************************************************/
|
||||
if (Tdbp->CheckRow(g, Nod))
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
|
||||
/*********************************************************************/
|
||||
/* Find the column and value nodes to update or insert. */
|
||||
@@ -2021,11 +1985,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (len > 1 && !Tdbp->Xpand) {
|
||||
sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp);
|
||||
|
||||
@@ -2067,11 +2027,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (ColNode == NULL) {
|
||||
strcpy(g->Message, MSG(COL_ALLOC_ERR));
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endif ColNode
|
||||
|
||||
} // endif ColNode
|
||||
@@ -2100,11 +2056,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
strcpy(Valbuf, p);
|
||||
|
||||
@@ -2136,11 +2088,7 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
|
||||
|
||||
if (Tdbp->Clist == NULL) {
|
||||
strcpy(g->Message, MSG(MIS_TAG_LIST));
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endif Clist
|
||||
|
||||
if ((ValNode = Tdbp->Clist->GetItem(g, Rank, Vxnp))) {
|
||||
@@ -2152,11 +2100,7 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
|
||||
PushWarning(g, Tdbp);
|
||||
break;
|
||||
default:
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch
|
||||
|
||||
Value->SetValue_psz(Valbuf);
|
||||
@@ -2207,22 +2151,14 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
|
||||
/* For all columns the Clist must be updated. */
|
||||
/*********************************************************************/
|
||||
if (Tdbp->CheckRow(g, true))
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
|
||||
/*********************************************************************/
|
||||
/* Find the column and value nodes to update or insert. */
|
||||
/*********************************************************************/
|
||||
if (Tdbp->Clist == NULL) {
|
||||
strcpy(g->Message, MSG(MIS_TAG_LIST));
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endif Clist
|
||||
|
||||
n = Tdbp->Clist->GetLength();
|
||||
@@ -2247,11 +2183,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
strcpy(Valbuf, p);
|
||||
|
||||
|
@@ -138,11 +138,7 @@ PSZ VALBLK::GetCharValue(int)
|
||||
|
||||
assert(g);
|
||||
sprintf(g->Message, MSG(NO_CHAR_FROM), Type);
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
return NULL;
|
||||
} // end of GetCharValue
|
||||
|
||||
@@ -210,11 +206,7 @@ void VALBLK::ChkIndx(int n)
|
||||
if (n < 0 || n >= Nval) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BAD_VALBLK_INDX));
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif n
|
||||
|
||||
} // end of ChkIndx
|
||||
@@ -224,11 +216,7 @@ void VALBLK::ChkTyp(PVAL v)
|
||||
if (Check && (Type != v->GetType() || Unsigned != v->IsUnsigned())) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH));
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Type
|
||||
|
||||
} // end of ChkTyp
|
||||
@@ -238,11 +226,7 @@ void VALBLK::ChkTyp(PVBLK vb)
|
||||
if (Check && (Type != vb->GetType() || Unsigned != vb->IsUnsigned())) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH));
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Type
|
||||
|
||||
} // end of ChkTyp
|
||||
@@ -358,11 +342,7 @@ void TYPBLK<TYPE>::SetValue(PSZ p, int n)
|
||||
if (Check) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BAD_SET_STRING));
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
|
||||
bool minus;
|
||||
@@ -412,11 +392,7 @@ void TYPBLK<double>::SetValue(PSZ p, int n)
|
||||
if (Check) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BAD_SET_STRING));
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
|
||||
Typp[n] = atof(p);
|
||||
@@ -819,11 +795,7 @@ void CHRBLK::SetValue(char *sp, uint len, int n)
|
||||
if (Check && (signed)len > Long) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(SET_STR_TRUNC));
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
#endif // _DEBUG
|
||||
|
||||
@@ -851,11 +823,7 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
|
||||
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Type
|
||||
|
||||
if (!(b = pv->IsNull(n2)))
|
||||
@@ -906,11 +874,7 @@ void CHRBLK::SetValues(PVBLK pv, int k, int n)
|
||||
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Type
|
||||
#endif // _DEBUG
|
||||
char *p = ((CHRBLK*)pv)->Chrp;
|
||||
|
@@ -57,17 +57,10 @@
|
||||
/* Check macro's. */
|
||||
/***********************************************************************/
|
||||
#if defined(_DEBUG)
|
||||
#if defined(USE_TRY)
|
||||
#define CheckType(V) if (Type != V->GetType()) { \
|
||||
PGLOBAL& g = Global; \
|
||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
#define CheckType(V) if (Type != V->GetType()) { \
|
||||
PGLOBAL& g = Global; \
|
||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
#else
|
||||
#define CheckType(V)
|
||||
#endif
|
||||
@@ -1026,19 +1019,11 @@ TYPE TYPVAL<TYPE>::SafeAdd(TYPE n1, TYPE n2)
|
||||
if ((n2 > 0) && (n < n1)) {
|
||||
// Overflow
|
||||
strcpy(g->Message, MSG(FIX_OVFLW_ADD));
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} else if ((n2 < 0) && (n > n1)) {
|
||||
// Underflow
|
||||
strcpy(g->Message, MSG(FIX_UNFLW_ADD));
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} // endif's n2
|
||||
|
||||
return n;
|
||||
@@ -1062,19 +1047,11 @@ TYPE TYPVAL<TYPE>::SafeMult(TYPE n1, TYPE n2)
|
||||
if (n > MinMaxVal(true)) {
|
||||
// Overflow
|
||||
strcpy(g->Message, MSG(FIX_OVFLW_TIMES));
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} else if (n < MinMaxVal(false)) {
|
||||
// Underflow
|
||||
strcpy(g->Message, MSG(FIX_UNFLW_TIMES));
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} // endif's n2
|
||||
|
||||
return (TYPE)n;
|
||||
@@ -1455,15 +1432,7 @@ void TYPVAL<PSZ>::SetValue(int n)
|
||||
|
||||
if (k > Len) {
|
||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
SetValue_psz(buf);
|
||||
|
||||
@@ -1517,11 +1486,7 @@ void TYPVAL<PSZ>::SetValue(longlong n)
|
||||
|
||||
if (k > Len) {
|
||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
SetValue_psz(buf);
|
||||
|
||||
@@ -1564,11 +1529,7 @@ void TYPVAL<PSZ>::SetValue(double f)
|
||||
|
||||
if (k > Len) {
|
||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
SetValue_psz(buf);
|
||||
|
||||
|
@@ -446,11 +446,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
|
||||
#if 0
|
||||
if (!dup->Step) {
|
||||
strcpy(g->Message, MSG(QUERY_CANCELLED));
|
||||
#if defined(USE_TRY)
|
||||
throw 99;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
#endif // !USE_TRY
|
||||
} // endif Step
|
||||
#endif // 0
|
||||
|
||||
|
@@ -84,11 +84,7 @@ double XOBJECT::GetFloatValue(void)
|
||||
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
|
||||
{
|
||||
if (!(Value = AllocateValue(g, value, (int)type)))
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_CONST;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
||||
#endif // !USE_TRY
|
||||
|
||||
Constant = true;
|
||||
} // end of CONSTANT constructor
|
||||
@@ -99,11 +95,7 @@ CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
|
||||
CONSTANT::CONSTANT(PGLOBAL g, int n)
|
||||
{
|
||||
if (!(Value = AllocateValue(g, &n, TYPE_INT)))
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_CONST;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
||||
#endif // !USE_TRY
|
||||
|
||||
Constant = true;
|
||||
} // end of CONSTANT constructor
|
||||
@@ -125,11 +117,7 @@ void CONSTANT::Convert(PGLOBAL g, int newtype)
|
||||
{
|
||||
if (Value->GetType() != newtype)
|
||||
if (!(Value = AllocateValue(g, Value, newtype)))
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_CONST;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
||||
#endif // !USE_TRY
|
||||
|
||||
} // end of Convert
|
||||
|
||||
|
Reference in New Issue
Block a user