Commit 9262ae65 authored by Olivier Bertrand's avatar Olivier Bertrand

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
parent 2c167929
...@@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h) ...@@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
# Definitions that are shared for all OSes # Definitions that are shared for all OSes
# #
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS) add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT -DUSE_TRY ) add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT )
# #
...@@ -291,6 +291,31 @@ IF(CONNECT_WITH_ZIP) ...@@ -291,6 +291,31 @@ IF(CONNECT_WITH_ZIP)
add_definitions(-DZIP_SUPPORT -DNOCRYPT) add_definitions(-DZIP_SUPPORT -DNOCRYPT)
ENDIF(CONNECT_WITH_ZIP) 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 # XMAP
...@@ -310,6 +335,6 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES} ...@@ -310,6 +335,6 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
STORAGE_ENGINE STORAGE_ENGINE
COMPONENT connect-engine COMPONENT connect-engine
RECOMPILE_FOR_EMBEDDED 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}) ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY})
...@@ -519,11 +519,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm) ...@@ -519,11 +519,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
} else if (opc != OP_EXIST) { } else if (opc != OP_EXIST) {
sprintf(g->Message, MSG(MISSING_ARG), opc); sprintf(g->Message, MSG(MISSING_ARG), opc);
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} else // OP_EXIST } else // OP_EXIST
return Nval > 0; return Nval > 0;
...@@ -685,22 +681,14 @@ void ARRAY::SetPrecision(PGLOBAL g, int p) ...@@ -685,22 +681,14 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
{ {
if (Vblp == NULL) { if (Vblp == NULL) {
strcpy(g->Message, MSG(PREC_VBLP_NULL)); strcpy(g->Message, MSG(PREC_VBLP_NULL));
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} // endif Vblp } // endif Vblp
bool was = Vblp->IsCi(); bool was = Vblp->IsCi();
if (was && !p) { if (was && !p) {
strcpy(g->Message, MSG(BAD_SET_CASE)); strcpy(g->Message, MSG(BAD_SET_CASE));
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} // endif Vblp } // endif Vblp
if (was || !p) if (was || !p)
...@@ -711,11 +699,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p) ...@@ -711,11 +699,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
if (!was && Type == TYPE_STRING) if (!was && Type == TYPE_STRING)
// Must be resorted to eliminate duplicate strings // Must be resorted to eliminate duplicate strings
if (Sort(g)) if (Sort(g))
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} // end of SetPrecision } // end of SetPrecision
......
...@@ -595,11 +595,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp) ...@@ -595,11 +595,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
if (Colp->GetResultType() != Type) { if (Colp->GetResultType() != Type) {
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH)); sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
#if defined(USE_TRY)
throw g->Message; throw g->Message;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 99);
#endif // !USE_TRY
} else if (Colp->GetValue()->IsCi()) } else if (Colp->GetValue()->IsCi())
Arap->SetPrecision(g, 1); // Case insensitive Arap->SetPrecision(g, 1); // Case insensitive
......
...@@ -195,13 +195,9 @@ int COLBLK::GetLengthEx(void) ...@@ -195,13 +195,9 @@ int COLBLK::GetLengthEx(void)
/* corresponding to this column and convert it to buffer type. */ /* corresponding to this column and convert it to buffer type. */
/***********************************************************************/ /***********************************************************************/
void COLBLK::ReadColumn(PGLOBAL g) void COLBLK::ReadColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn"); sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
#if defined(USE_TRY)
throw TYPE_COLBLK; throw TYPE_COLBLK;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
#endif // !USE_TRY
} // end of ReadColumn } // end of ReadColumn
/***********************************************************************/ /***********************************************************************/
...@@ -210,13 +206,9 @@ void COLBLK::ReadColumn(PGLOBAL g) ...@@ -210,13 +206,9 @@ void COLBLK::ReadColumn(PGLOBAL g)
/* corresponding to this column from the column buffer and type. */ /* corresponding to this column from the column buffer and type. */
/***********************************************************************/ /***********************************************************************/
void COLBLK::WriteColumn(PGLOBAL g) void COLBLK::WriteColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn"); sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
#if defined(USE_TRY)
throw TYPE_COLBLK; throw TYPE_COLBLK;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
#endif // !USE_TRY
} // end of WriteColumn } // end of WriteColumn
/***********************************************************************/ /***********************************************************************/
...@@ -268,13 +260,9 @@ SPCBLK::SPCBLK(PCOLUMN cp) ...@@ -268,13 +260,9 @@ SPCBLK::SPCBLK(PCOLUMN cp)
/* corresponding to this column from the column buffer and type. */ /* corresponding to this column from the column buffer and type. */
/***********************************************************************/ /***********************************************************************/
void SPCBLK::WriteColumn(PGLOBAL g) void SPCBLK::WriteColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(SPCOL_READONLY), Name); sprintf(g->Message, MSG(SPCOL_READONLY), Name);
#if defined(USE_TRY)
throw TYPE_COLBLK; throw TYPE_COLBLK;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
#endif // !USE_TRY
} // end of WriteColumn } // end of WriteColumn
/***********************************************************************/ /***********************************************************************/
......
This diff is collapsed.
...@@ -986,7 +986,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -986,7 +986,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
} else { } else {
/*****************************************************************/ /*****************************************************************/
/* Move of eventual preceding lines is not required here. */ /* Move of eventual preceding lines is not required here. */
/* Set the target file as being the source file itself. */ /* Set the target file as being the source file itself. */
/* Set the future Tpos, and give Spos a value to block copying. */ /* Set the future Tpos, and give Spos a value to block copying. */
/*****************************************************************/ /*****************************************************************/
...@@ -1174,20 +1174,12 @@ int DOSFAM::RenameTempFile(PGLOBAL g) ...@@ -1174,20 +1174,12 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
if (rename(filename, filetemp)) { // Save file for security if (rename(filename, filetemp)) { // Save file for security
sprintf(g->Message, MSG(RENAME_ERROR), sprintf(g->Message, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno)); filename, filetemp, strerror(errno));
#if defined(USE_TRY)
throw 51; throw 51;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 51);
#endif // !USE_TRY
} else if (rename(tempname, filename)) { } else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR), sprintf(g->Message, MSG(RENAME_ERROR),
tempname, filename, strerror(errno)); tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file rc = rename(filetemp, filename); // Restore saved file
#if defined(USE_TRY)
throw 52; throw 52;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 52);
#endif // !USE_TRY
} else if (remove(filetemp)) { } else if (remove(filetemp)) {
sprintf(g->Message, MSG(REMOVE_ERROR), sprintf(g->Message, MSG(REMOVE_ERROR),
filetemp, strerror(errno)); filetemp, strerror(errno));
......
...@@ -559,7 +559,7 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g) ...@@ -559,7 +559,7 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
/* Do initial action when inserting. */ /* Do initial action when inserting. */
/***********************************************************************/ /***********************************************************************/
bool VCTFAM::InitInsert(PGLOBAL g) bool VCTFAM::InitInsert(PGLOBAL g)
{ {
bool rc = false; bool rc = false;
// We come here in MODE_INSERT only // We come here in MODE_INSERT only
...@@ -575,26 +575,11 @@ bool VCTFAM::InitInsert(PGLOBAL g) ...@@ -575,26 +575,11 @@ bool VCTFAM::InitInsert(PGLOBAL g)
CurBlk = Block - 1; CurBlk = Block - 1;
CurNum = Last; CurNum = Last;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY // Last block must be updated by new values
// Prepare error return for (; cp; cp = (PVCTCOL)cp->Next)
if (g->jump_level == MAX_JUMP) { cp->ReadBlock(g);
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) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
...@@ -603,9 +588,7 @@ bool VCTFAM::InitInsert(PGLOBAL g) ...@@ -603,9 +588,7 @@ bool VCTFAM::InitInsert(PGLOBAL g)
strcpy(g->Message, msg); strcpy(g->Message, msg);
rc = true; rc = true;
} // end catch } // end catch
#else // !USE_TRY
g->jump_level--;
#endif // !USE_TRY
} // endif Last } // endif Last
if (!rc) if (!rc)
...@@ -1126,11 +1109,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort) ...@@ -1126,11 +1109,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
} else if (AddBlock) { } else if (AddBlock) {
// Last block was not written // Last block was not written
rc = ResetTableSize(g, CurBlk, Nrec); rc = ResetTableSize(g, CurBlk, Nrec);
#if defined(USE_TRY)
throw 44; throw 44;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 44);
#endif // !USE_TRY
} // endif } // endif
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {
...@@ -1550,7 +1529,7 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g) ...@@ -1550,7 +1529,7 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g)
/* Do initial action when inserting. */ /* Do initial action when inserting. */
/***********************************************************************/ /***********************************************************************/
bool VCMFAM::InitInsert(PGLOBAL g) bool VCMFAM::InitInsert(PGLOBAL g)
{ {
bool rc = false; bool rc = false;
volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns(); volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
...@@ -1565,27 +1544,12 @@ bool VCMFAM::InitInsert(PGLOBAL g) ...@@ -1565,27 +1544,12 @@ bool VCMFAM::InitInsert(PGLOBAL g)
CurNum = Last; CurNum = Last;
} // endif Last } // endif Last
#if defined(USE_TRY)
try { try {
#else // !USE_TRY // Initialize the column block pointer
// Prepare error return for (; cp; cp = (PVCTCOL)cp->Next)
if (g->jump_level == MAX_JUMP) { cp->ReadBlock(g);
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true; } catch (int n) {
} // 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) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
rc = true; rc = true;
...@@ -1593,11 +1557,9 @@ bool VCMFAM::InitInsert(PGLOBAL g) ...@@ -1593,11 +1557,9 @@ bool VCMFAM::InitInsert(PGLOBAL g)
strcpy(g->Message, msg); strcpy(g->Message, msg);
rc = true; rc = true;
} // end catch } // end catch
#else // !USE_TRY
g->jump_level--;
#endif // !USE_TRY
return rc; return rc;
} // end of InitInsert } // end of InitInsert
/***********************************************************************/ /***********************************************************************/
/* Data Base write routine for VMP access method. */ /* Data Base write routine for VMP access method. */
...@@ -2541,11 +2503,7 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort) ...@@ -2541,11 +2503,7 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
if (wrc != RC_FX) if (wrc != RC_FX)
rc = ResetTableSize(g, Block, Last); rc = ResetTableSize(g, Block, Last);
else else
#if defined(USE_TRY)
throw 44; throw 44;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 44);
#endif // !USE_TRY
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {
if (UseTemp && !InitUpdate && !Abort) { if (UseTemp && !InitUpdate && !Abort) {
...@@ -4206,11 +4164,7 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort) ...@@ -4206,11 +4164,7 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
} else if (AddBlock) { } else if (AddBlock) {
// Last block was not written // Last block was not written
rc = ResetTableSize(g, CurBlk, Nrec); rc = ResetTableSize(g, CurBlk, Nrec);
#if defined(USE_TRY)
throw 44; throw 44;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 44);
#endif // !USE_TRY
} // endif } // endif
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {
......
...@@ -87,11 +87,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc) ...@@ -87,11 +87,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
case OP_EXIST: bt = 0x00; break; case OP_EXIST: bt = 0x00; break;
default: default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc); sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} // endswitch opc } // endswitch opc
return bt; return bt;
...@@ -1715,11 +1711,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having) ...@@ -1715,11 +1711,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
break; // Remove eventual ending separator(s) break; // Remove eventual ending separator(s)
// if (fp->Convert(g, having)) // if (fp->Convert(g, having))
//#if defined(USE_TRY)
// throw TYPE_ARRAY; // throw TYPE_ARRAY;
//#else // !USE_TRY
// longjmp(g->jumper[g->jump_level], TYPE_FILTER);
//#endif // !USE_TRY
filp = fp; filp = fp;
fp = fp->Next; fp = fp->Next;
...@@ -1752,11 +1744,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp) ...@@ -1752,11 +1744,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
// return TRUE; // return TRUE;
if (filp->Eval(g)) if (filp->Eval(g))
#if defined(USE_TRY)
throw TYPE_FILTER; throw TYPE_FILTER;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_FILTER);
#endif // !USE_TRY
if (trace > 1) if (trace > 1)
htrc("PlugFilter filp=%p result=%d\n", htrc("PlugFilter filp=%p result=%d\n",
......
This diff is collapsed.
...@@ -1200,11 +1200,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1200,11 +1200,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (rank == 0) if (rank == 0)
if (!name || (jn = env->NewStringUTF(name)) == nullptr) { if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name)); sprintf(g->Message, "Fail to allocate jstring %s", SVP(name));
#if defined(USE_TRY)
throw TYPE_AM_JDBC; throw TYPE_AM_JDBC;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
#endif // !USE_TRY
} // endif name } // endif name
// Returns 666 is case of error // Returns 666 is case of error
...@@ -1212,11 +1208,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1212,11 +1208,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (Check((ctyp == 666) ? -1 : 1)) { if (Check((ctyp == 666) ? -1 : 1)) {
sprintf(g->Message, "Getting ctyp: %s", Msg); sprintf(g->Message, "Getting ctyp: %s", Msg);
#if defined(USE_TRY)
throw TYPE_AM_JDBC; throw TYPE_AM_JDBC;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
#endif // !USE_TRY
} // endif Check } // endif Check
if (val->GetNullable()) if (val->GetNullable())
...@@ -1322,11 +1314,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1322,11 +1314,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
env->DeleteLocalRef(jn); env->DeleteLocalRef(jn);
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp); sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
#if defined(USE_TRY)
throw TYPE_AM_JDBC; throw TYPE_AM_JDBC;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
#endif // !USE_TRY
} // endif Check } // endif Check
if (rank == 0) if (rank == 0)
......
...@@ -81,123 +81,70 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) ...@@ -81,123 +81,70 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n'))) if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')))
pty[0] = false; 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 { try {
#endif // SE_CATCH --------------------- try section -------------------- for (i = 0; i < len; i++)
if (setjmp(g->jumper[++g->jump_level])) { switch (s[i]) {
goto fin; case '[':
} // endif rc if (jsp)
goto tryit;
#if defined(SE_CATCH) // ------------- end of try section ----------------- else if (!(jsp = ParseArray(g, ++i, src, pty)))
} catch (SE_Exception e) { throw 1;
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
GetExceptionDesc(g, e.nSE), e.nSE); break;
_set_se_translator(f); case '{':
goto err; if (jsp)
} catch (...) { goto tryit;
strcpy(g->Message, "Exception doing setjmp"); else if (!(jsp = ParseObject(g, ++i, src, pty)))
_set_se_translator(f); throw 2;
goto err;
} // end of try-catches break;
case ' ':
_set_se_translator(f); case '\t':
#endif // SE_CATCH case '\n':
#endif // !USE_TRY case '\r':
break;
for (i = 0; i < len; i++) case ',':
switch (s[i]) { if (jsp && (pretty == 1 || pretty == 3)) {
case '[': if (comma)
if (jsp) *comma = true;
goto tryit;
else if (!(jsp = ParseArray(g, ++i, src, pty))) pty[0] = pty[2] = false;
#if defined(USE_TRY) break;
throw 1; } // endif pretty
#else // !USE_TRY
goto fin; sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty);
#endif // !USE_TRY throw 3;
case '(':
break; b = true;
case '{': break;
if (jsp) case ')':
goto tryit; if (b) {
else if (!(jsp = ParseObject(g, ++i, src, pty))) b = false;
#if defined(USE_TRY) break;
throw 2; } // endif b
#else // !USE_TRY
goto fin; default:
#endif // !USE_TRY if (jsp)
goto tryit;
break; else if (!(jsp = ParseValue(g, i, src, pty)))
case ' ': throw 4;
case '\t':
case '\n': break;
case '\r': }; // endswitch s[i]
break;
case ',': if (!jsp)
if (jsp && (pretty == 1 || pretty == 3)) { sprintf(g->Message, "Invalid Json string '%.*s'", 50, s);
if (comma) else if (ptyp && pretty == 3) {
*comma = true; *ptyp = 3; // Not recognized pretty
pty[0] = pty[2] = false; for (i = 0; i < 3; i++)
break; if (pty[i]) {
} // endif pretty *ptyp = i;
break;
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty); } // endif pty
#if defined(USE_TRY)
throw 3; } // endif ptyp
#else // !USE_TRY
jsp = NULL;
goto fin;
#endif // !USE_TRY
case '(':
b = true;
break;
case ')':
if (b) {
b = false;
break;
} // endif b
default:
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]
if (!jsp)
sprintf(g->Message, "Invalid Json string '%.*s'", 50, s);
else if (ptyp && pretty == 3) {
*ptyp = 3; // Not recognized pretty
for (i = 0; i < 3; i++)
if (pty[i]) {
*ptyp = i;
break;
} // endif pty
} // endif ptyp
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
...@@ -208,20 +155,12 @@ _set_se_translator(f); ...@@ -208,20 +155,12 @@ _set_se_translator(f);
} // end catch } // end catch
return jsp; return jsp;
#else // !USE_TRY
fin:
g->jump_level--;
return jsp;
#endif // !USE_TRY
tryit: tryit:
if (pty[0] && (!pretty || pretty > 2)) { if (pty[0] && (!pretty || pretty > 2)) {
if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3) if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3)
*ptyp = (pty[0]) ? 0 : 3; *ptyp = (pty[0]) ? 0 : 3;
#if !defined(USE_TRY)
g->jump_level--;
#endif // !USE_TRY
return jsp; return jsp;
} else } else
strcpy(g->Message, "More than one item in file"); strcpy(g->Message, "More than one item in file");
...@@ -620,101 +559,75 @@ PVAL ParseNumeric(PGLOBAL g, int& i, STRG& src) ...@@ -620,101 +559,75 @@ PVAL ParseNumeric(PGLOBAL g, int& i, STRG& src)
PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty) PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
{ {
PSZ str = NULL; PSZ str = NULL;
bool b = false, err = true; bool b = false, err = true;
JOUT *jp; JOUT *jp;
FILE *fs = NULL; FILE *fs = NULL;
g->Message[0] = 0; g->Message[0] = 0;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY if (!jsp) {
// Save stack and allocation environment and prepare error return strcpy(g->Message, "Null json tree");
if (g->jump_level == MAX_JUMP) { throw 1;
strcpy(g->Message, MSG(TOO_MANY_JUMPS)); } else if (!fn) {
return NULL; // Serialize to a string
} // endif jump_level jp = new(g) JOUTSTR(g);
b = pretty == 1;
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);
b = pretty == 1;
} else {
if (!(fs = fopen(fn, "wb"))) {
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);
} else { } else {
// Serialize to a flat file if (!(fs = fopen(fn, "wb"))) {
b = true; sprintf(g->Message, MSG(OPEN_MODE_ERROR),
jp = new(g)JOUTFILE(g, fs, pretty); "w", (int)errno, fn);
} // endif's strcat(strcat(g->Message, ": "), strerror(errno));
throw 2;
} // endif's } else if (pretty >= 2) {
// Serialize to a pretty file
switch (jsp->GetType()) { jp = new(g)JOUTPRT(g, fs);
case TYPE_JAR: } else {
err = SerializeArray(jp, (PJAR)jsp, b); // Serialize to a flat file
break; b = true;
case TYPE_JOB: jp = new(g)JOUTFILE(g, fs, pretty);
err = ((b && jp->Prty()) && jp->WriteChr('\t')); } // endif's
err |= SerializeObject(jp, (PJOB)jsp);
break; } // endif's
case TYPE_JVAL:
err = SerializeValue(jp, (PJVAL)jsp); switch (jsp->GetType()) {
break; case TYPE_JAR:
default: err = SerializeArray(jp, (PJAR)jsp, b);
strcpy(g->Message, "Invalid json tree"); break;
} // endswitch Type case TYPE_JOB:
err = ((b && jp->Prty()) && jp->WriteChr('\t'));
err |= SerializeObject(jp, (PJOB)jsp);
break;
case TYPE_JVAL:
err = SerializeValue(jp, (PJVAL)jsp);
break;
default:
strcpy(g->Message, "Invalid json tree");
} // endswitch Type
if (fs) {
fputs(EL, fs);
fclose(fs);
str = (err) ? NULL : strcpy(g->Message, "Ok");
} else if (!err) {
str = ((JOUTSTR*)jp)->Strp;
jp->WriteChr('\0');
PlugSubAlloc(g, NULL, ((JOUTSTR*)jp)->N);
} else {
if (!g->Message[0])
strcpy(g->Message, "Error in Serialize");
if (fs) { } // endif's
fputs(EL, fs);
fclose(fs);
str = (err) ? NULL : strcpy(g->Message, "Ok");
} else if (!err) {
str = ((JOUTSTR*)jp)->Strp;
jp->WriteChr('\0');
PlugSubAlloc(g, NULL, ((JOUTSTR*)jp)->N);
} else {
if (!g->Message[0])
strcpy(g->Message, "Error in Serialize");
} // endif's } catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
str = NULL;
} catch (const char *msg) {
strcpy(g->Message, msg);
str = NULL;
} // end catch
#if defined(USE_TRY)
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
str = NULL;
} catch (const char *msg) {
strcpy(g->Message, msg);
str = NULL;
} // end catch
#else // !USE_TRY
fin:
g->jump_level--;
#endif // !USE_TRY
return str; return str;
} // end of Serialize } // end of Serialize
......
This diff is collapsed.
This diff is collapsed.
/************** 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
...@@ -239,62 +239,43 @@ char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop) ...@@ -239,62 +239,43 @@ char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop)
/***********************************************************************/ /***********************************************************************/
/* Allocate the structure used to refer to the result set. */ /* Allocate the structure used to refer to the result set. */
/***********************************************************************/ /***********************************************************************/
static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db, static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
char *tab, PQRYRES qrp) char *tab, PQRYRES qrp)
{ {
size_t i, m, n; size_t i, m, n;
CATPARM *cap; CATPARM *cap;
#if defined(_DEBUG) #if defined(_DEBUG)
assert(qrp); assert(qrp);
#endif #endif
#if defined(USE_TRY)
try { try {
#else // !USE_TRY m = (size_t)qrp->Maxres;
// Save stack and allocation environment and prepare error return n = (size_t)qrp->Nbcol;
if (g->jump_level == MAX_JUMP) { cap = (CATPARM *)PlugSubAlloc(g, NULL, sizeof(CATPARM));
strcpy(g->Message, MSG(TOO_MANY_JUMPS)); memset(cap, 0, sizeof(CATPARM));
return NULL; cap->Id = fid;
} // endif jump_level cap->Qrp = qrp;
cap->DB = (PUCHAR)db;
if (setjmp(g->jumper[++g->jump_level]) != 0) { cap->Tab = (PUCHAR)tab;
cap->Vlen = (SQLLEN* *)PlugSubAlloc(g, NULL, n * sizeof(SQLLEN *));
for (i = 0; i < n; i++)
cap->Vlen[i] = (SQLLEN *)PlugSubAlloc(g, NULL, m * sizeof(SQLLEN));
cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD));
} catch (int n) {
htrc("Exeption %d: %s\n", n, g->Message);
cap = NULL;
} catch (const char *msg) {
htrc(g->Message, msg);
printf("%s\n", g->Message); printf("%s\n", g->Message);
cap = NULL; cap = NULL;
goto fin; } // end catch
} // endif rc
#endif // !USE_TRY
m = (size_t)qrp->Maxres;
n = (size_t)qrp->Nbcol;
cap = (CATPARM *)PlugSubAlloc(g, NULL, sizeof(CATPARM));
memset(cap, 0, sizeof(CATPARM));
cap->Id = fid;
cap->Qrp = qrp;
cap->DB = (PUCHAR)db;
cap->Tab = (PUCHAR)tab;
cap->Vlen = (SQLLEN* *)PlugSubAlloc(g, NULL, n * sizeof(SQLLEN *));
for (i = 0; i < n; i++)
cap->Vlen[i] = (SQLLEN *)PlugSubAlloc(g, NULL, m * sizeof(SQLLEN));
cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD));
#if defined(USE_TRY)
} catch (int n) {
htrc("Exeption %d: %s\n", n, g->Message);
cap = NULL;
} 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
return cap; return cap;
} // end of AllocCatInfo } // end of AllocCatInfo
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
......
...@@ -143,7 +143,8 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */ ...@@ -143,7 +143,8 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
TYPE_AM_MYX = 193, /* MYSQL EXEC access method type */ TYPE_AM_MYX = 193, /* MYSQL EXEC access method type */
TYPE_AM_CAT = 195, /* Catalog access method type no */ TYPE_AM_CAT = 195, /* Catalog access method type no */
TYPE_AM_ZIP = 198, /* ZIP access method type no */ TYPE_AM_ZIP = 198, /* ZIP access method type no */
TYPE_AM_OUT = 200}; /* Output relations (storage) */ TYPE_AM_MGO = 199, /* MGO access method type no */
TYPE_AM_OUT = 200}; /* Output relations (storage) */
enum RECFM {RECFM_NAF = -2, /* Not a file */ enum RECFM {RECFM_NAF = -2, /* Not a file */
RECFM_OEM = -1, /* OEM file access method */ RECFM_OEM = -1, /* OEM file access method */
......
...@@ -238,90 +238,74 @@ void ptrc(char const *fmt, ...) ...@@ -238,90 +238,74 @@ void ptrc(char const *fmt, ...)
PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
int *buftyp, XFLD *fldtyp, int *buftyp, XFLD *fldtyp,
unsigned int *length, bool blank, bool nonull) unsigned int *length, bool blank, bool nonull)
{ {
char cname[NAM_LEN+1]; char cname[NAM_LEN+1];
int i; int i;
PCOLRES *pcrp, crp; PCOLRES *pcrp, crp;
PQRYRES qrp; PQRYRES qrp;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY /**********************************************************************/
// Save stack and allocation environment and prepare error return /* Allocate the structure used to contain the result set. */
if (g->jump_level == MAX_JUMP) { /**********************************************************************/
strcpy(g->Message, MSG(TOO_MANY_JUMPS)); qrp = (PQRYRES)PlugSubAlloc(g, NULL, sizeof(QRYRES));
return NULL; pcrp = &qrp->Colresp;
} // endif jump_level qrp->Continued = false;
qrp->Truncated = false;
if (setjmp(g->jumper[++g->jump_level]) != 0) { qrp->Info = false;
printf("%s\n", g->Message); qrp->Suball = true;
qrp = NULL; qrp->Maxres = maxres;
goto fin; qrp->Maxsize = 0;
} // endif rc qrp->Nblin = 0;
#endif // !USE_TRY qrp->Nbcol = 0; // will be ncol
qrp->Cursor = 0;
/************************************************************************/ qrp->BadLines = 0;
/* Allocate the structure used to contain the result set. */
/************************************************************************/ for (i = 0; i < ncol; i++) {
qrp = (PQRYRES)PlugSubAlloc(g, NULL, sizeof(QRYRES)); *pcrp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES));
pcrp = &qrp->Colresp; crp = *pcrp;
qrp->Continued = false; pcrp = &crp->Next;
qrp->Truncated = false; memset(crp, 0, sizeof(COLRES));
qrp->Info = false; crp->Colp = NULL;
qrp->Suball = true; crp->Ncol = ++qrp->Nbcol;
qrp->Maxres = maxres; crp->Type = buftyp[i];
qrp->Maxsize = 0; crp->Length = length[i];
qrp->Nblin = 0; crp->Clen = GetTypeSize(crp->Type, length[i]);
qrp->Nbcol = 0; // will be ncol crp->Prec = 0;
qrp->Cursor = 0;
qrp->BadLines = 0; if (ids > 0) {
for (i = 0; i < ncol; i++) {
*pcrp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES));
crp = *pcrp;
pcrp = &crp->Next;
memset(crp, 0, sizeof(COLRES));
crp->Colp = NULL;
crp->Ncol = ++qrp->Nbcol;
crp->Type = buftyp[i];
crp->Length = length[i];
crp->Clen = GetTypeSize(crp->Type, length[i]);
crp->Prec = 0;
if (ids > 0) {
#if defined(XMSG) #if defined(XMSG)
// Get header from message file // Get header from message file
strncpy(cname, PlugReadMessage(g, ids + crp->Ncol, NULL), NAM_LEN); strncpy(cname, PlugReadMessage(g, ids + crp->Ncol, NULL), NAM_LEN);
cname[NAM_LEN] = 0; // for truncated long names cname[NAM_LEN] = 0; // for truncated long names
#else // !XMSG #else // !XMSG
GetRcString(ids + crp->Ncol, cname, sizeof(cname)); GetRcString(ids + crp->Ncol, cname, sizeof(cname));
#endif // !XMSG #endif // !XMSG
crp->Name = (PSZ)PlugDup(g, cname); crp->Name = (PSZ)PlugDup(g, cname);
} else } else
crp->Name = NULL; // Will be set by caller crp->Name = NULL; // Will be set by caller
if (fldtyp) if (fldtyp)
crp->Fld = fldtyp[i]; crp->Fld = fldtyp[i];
else else
crp->Fld = FLD_NO; crp->Fld = FLD_NO;
// Allocate the Value Block that will contain data // Allocate the Value Block that will contain data
if (crp->Length || nonull) if (crp->Length || nonull)
crp->Kdata = AllocValBlock(g, NULL, crp->Type, maxres, crp->Kdata = AllocValBlock(g, NULL, crp->Type, maxres,
crp->Length, 0, true, blank, false); crp->Length, 0, true, blank, false);
else else
crp->Kdata = NULL; crp->Kdata = NULL;
if (trace) if (trace)
htrc("Column(%d) %s type=%d len=%d value=%p\n", htrc("Column(%d) %s type=%d len=%d value=%p\n",
crp->Ncol, crp->Name, crp->Type, crp->Length, crp->Kdata); crp->Ncol, crp->Name, crp->Type, crp->Length, crp->Kdata);
} // endfor i } // endfor i
*pcrp = NULL; *pcrp = NULL;
#if defined(USE_TRY) } catch (int n) {
} catch (int n) {
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
qrp = NULL; qrp = NULL;
} catch (const char *msg) { } catch (const char *msg) {
...@@ -329,12 +313,9 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, ...@@ -329,12 +313,9 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
htrc("%s\n", g->Message); htrc("%s\n", g->Message);
qrp = NULL; qrp = NULL;
} // end catch } // end catch
#else // !USE_TRY
fin:
g->jump_level--;
#endif // !USE_TRY
return qrp; return qrp;
} // end of PlgAllocResult } // end of PlgAllocResult
/***********************************************************************/ /***********************************************************************/
/* Allocate and initialize the new DB User Block. */ /* Allocate and initialize the new DB User Block. */
...@@ -380,11 +361,7 @@ PCATLG PlgGetCatalog(PGLOBAL g, bool jump) ...@@ -380,11 +361,7 @@ PCATLG PlgGetCatalog(PGLOBAL g, bool jump)
if (!cat && jump) { if (!cat && jump) {
// Raise exception so caller doesn't have to check return value // Raise exception so caller doesn't have to check return value
strcpy(g->Message, MSG(NO_ACTIVE_DB)); strcpy(g->Message, MSG(NO_ACTIVE_DB));
#if defined(USE_TRY)
throw 1; throw 1;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 1);
#endif // !USE_TRY
} // endif cat } // endif cat
return cat; return cat;
...@@ -495,11 +472,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci) ...@@ -495,11 +472,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
tp = g->Message; tp = g->Message;
else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) { else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) {
strcpy(g->Message, MSG(NEW_RETURN_NULL)); strcpy(g->Message, MSG(NEW_RETURN_NULL));
#if defined(USE_TRY)
throw OP_LIKE; throw OP_LIKE;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], OP_LIKE);
#endif // !USE_TRY
} /* endif tp */ } /* endif tp */
sp = tp + strlen(pat) + 1; sp = tp + strlen(pat) + 1;
...@@ -510,11 +483,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci) ...@@ -510,11 +483,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
tp = g->Message; /* Use this as temporary work space. */ tp = g->Message; /* Use this as temporary work space. */
else if (!(tp = new char[strlen(pat) + 1])) { else if (!(tp = new char[strlen(pat) + 1])) {
strcpy(g->Message, MSG(NEW_RETURN_NULL)); strcpy(g->Message, MSG(NEW_RETURN_NULL));
#if defined(USE_TRY)
throw OP_LIKE; throw OP_LIKE;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], OP_LIKE);
#endif // !USE_TRY
} /* endif tp */ } /* endif tp */
strcpy(tp, pat); /* Make a copy to be worked into */ strcpy(tp, pat); /* Make a copy to be worked into */
...@@ -1547,11 +1516,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv) ...@@ -1547,11 +1516,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
PGLOBAL g = t->G; PGLOBAL g = t->G;
sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR)); sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR));
#if defined(USE_TRY)
throw 3; throw 3;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 3);
#endif // !USE_TRY
} else { } else {
tp->Next = t->P1; tp->Next = t->P1;
tp->Num = 0; tp->Num = 0;
...@@ -1588,22 +1553,14 @@ int FileComp(PGLOBAL g, char *file1, char *file2) ...@@ -1588,22 +1553,14 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
sprintf(g->Message, MSG(OPEN_MODE_ERROR), sprintf(g->Message, MSG(OPEN_MODE_ERROR),
"rb", (int)errno, fn[i]); "rb", (int)errno, fn[i]);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
// } else // } else
// len[i] = 0; // File does not exist yet // len[i] = 0; // File does not exist yet
} else { } else {
if ((len[i] = _filelength(h[i])) < 0) { if ((len[i] = _filelength(h[i])) < 0) {
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]); sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]);
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
} // endif len } // endif len
} // endif h } // endif h
......
...@@ -519,13 +519,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) ...@@ -519,13 +519,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
if (trace) if (trace)
htrc("PlugSubAlloc: %s\n", g->Message); htrc("PlugSubAlloc: %s\n", g->Message);
#if defined(USE_TRY)
throw 1234; 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 */ } /* endif size OS32 code */
/*********************************************************************/ /*********************************************************************/
......
...@@ -132,7 +132,8 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int) ...@@ -132,7 +132,8 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
bool map = (am && (*am == 'M' || *am == 'm')); bool map = (am && (*am == 'M' || *am == 'm'));
LPCSTR dfm = (am && (*am == 'F' || *am == 'f')) ? "F" LPCSTR dfm = (am && (*am == 'F' || *am == 'f')) ? "F"
: (am && (*am == 'B' || *am == 'b')) ? "B" : (am && (*am == 'B' || *am == 'b')) ? "B"
: (am && !stricmp(am, "DBF")) ? "D" : "V"; : (am && (*am == 'X' || *am == 'x')) ? "X"
: (am && !stricmp(am, "DBF")) ? "D" : "V";
if ((Zipped = GetBoolCatInfo("Zipped", false))) { if ((Zipped = GetBoolCatInfo("Zipped", false))) {
Entry = GetStringCatInfo(g, "Entry", NULL); Entry = GetStringCatInfo(g, "Entry", NULL);
...@@ -148,7 +149,8 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int) ...@@ -148,7 +149,8 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf)); GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf));
Recfm = (toupper(*buf) == 'F') ? RECFM_FIX : Recfm = (toupper(*buf) == 'F') ? RECFM_FIX :
(toupper(*buf) == 'B') ? RECFM_BIN : (toupper(*buf) == 'B') ? RECFM_BIN :
(toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR; (toupper(*buf) == 'X') ? RECFM_NAF : // MGO
(toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR;
Lrecl = GetIntCatInfo("Lrecl", 0); Lrecl = GetIntCatInfo("Lrecl", 0);
if (Recfm != RECFM_DBF) if (Recfm != RECFM_DBF)
...@@ -1511,11 +1513,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv) ...@@ -1511,11 +1513,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
if (n == 8 && ctype != TYPE_LIST) { if (n == 8 && ctype != TYPE_LIST) {
// Should never happen // Should never happen
strcpy(g->Message, "Block opt: bad constant"); strcpy(g->Message, "Block opt: bad constant");
#if defined(USE_TRY)
throw 99; throw 99;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 99);
#endif // !USE_TRY
} // endif Conv } // endif Conv
if (type[0] == 1) { if (type[0] == 1) {
...@@ -1796,7 +1794,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) ...@@ -1796,7 +1794,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
/* Make a dynamic index. */ /* Make a dynamic index. */
/***********************************************************************/ /***********************************************************************/
bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted) bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
{ {
int k; int k;
volatile bool dynamic; volatile bool dynamic;
bool brc; bool brc;
...@@ -1867,17 +1865,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted) ...@@ -1867,17 +1865,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
} else // Column contains same values as ROWID } else // Column contains same values as ROWID
kxp = new(g) XXROW(this); kxp = new(g) XXROW(this);
#if defined(USE_TRY)
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) { if (dynamic) {
ResetBlockFilter(g); ResetBlockFilter(g);
kxp->SetDynamic(dynamic); kxp->SetDynamic(dynamic);
...@@ -1902,7 +1890,6 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted) ...@@ -1902,7 +1890,6 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
} // endif brc } // endif brc
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
...@@ -1911,14 +1898,9 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted) ...@@ -1911,14 +1898,9 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
strcpy(g->Message, msg); strcpy(g->Message, msg);
brc = true; brc = true;
} // end catch } // end catch
#else // !USE_TRY
} else
brc = true;
g->jump_level--;
#endif // !USE_TRY
return brc; return brc;
} // end of InitialyzeIndex } // end of InitialyzeIndex
/***********************************************************************/ /***********************************************************************/
/* DOS GetProgMax: get the max value for progress information. */ /* DOS GetProgMax: get the max value for progress information. */
...@@ -2139,7 +2121,8 @@ bool TDBDOS::OpenDB(PGLOBAL g) ...@@ -2139,7 +2121,8 @@ bool TDBDOS::OpenDB(PGLOBAL g)
return false; return false;
} // endif use } // 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 // Delete all lines. Not handled in MAP or block mode
Txfp = new(g) DOSFAM((PDOSDEF)To_Def); Txfp = new(g) DOSFAM((PDOSDEF)To_Def);
Txfp->SetTdbp(this); Txfp->SetTdbp(this);
...@@ -2537,11 +2520,7 @@ void DOSCOL::ReadColumn(PGLOBAL g) ...@@ -2537,11 +2520,7 @@ void DOSCOL::ReadColumn(PGLOBAL g)
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); sprintf(g->Message, MSG(INV_DEF_READ), rc);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} // endif } // endif
p = tdbp->To_Line + Deplac; p = tdbp->To_Line + Deplac;
...@@ -2597,11 +2576,7 @@ void DOSCOL::ReadColumn(PGLOBAL g) ...@@ -2597,11 +2576,7 @@ void DOSCOL::ReadColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype); sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype);
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} // endswitch Ftype } // endswitch Ftype
// Set null when applicable // Set null when applicable
...@@ -2710,11 +2685,7 @@ void DOSCOL::WriteColumn(PGLOBAL g) ...@@ -2710,11 +2685,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, "Invalid field format for column %s", Name); sprintf(g->Message, "Invalid field format for column %s", Name);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endswitch BufType } // endswitch BufType
p2 = Buf; p2 = Buf;
...@@ -2726,11 +2697,7 @@ void DOSCOL::WriteColumn(PGLOBAL g) ...@@ -2726,11 +2697,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
if ((len = strlen(p2)) > field) { if ((len = strlen(p2)) > field) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field); sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Dsp) } else if (Dsp)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if (p2[i] == '.') if (p2[i] == '.')
......
...@@ -411,11 +411,7 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am) ...@@ -411,11 +411,7 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
case 'D': M = sizeof(double); break; case 'D': M = sizeof(double); break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} // endswitch Fmt } // endswitch Fmt
} else if (IsTypeChar(Buf_Type)) } else if (IsTypeChar(Buf_Type))
...@@ -490,11 +486,7 @@ void BINCOL::ReadColumn(PGLOBAL g) ...@@ -490,11 +486,7 @@ void BINCOL::ReadColumn(PGLOBAL g)
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); sprintf(g->Message, MSG(INV_DEF_READ), rc);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} // endif } // endif
p = tdbp->To_Line + Deplac; p = tdbp->To_Line + Deplac;
...@@ -553,11 +545,7 @@ void BINCOL::ReadColumn(PGLOBAL g) ...@@ -553,11 +545,7 @@ void BINCOL::ReadColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} // endswitch Fmt } // endswitch Fmt
// Set null when applicable // Set null when applicable
...@@ -607,11 +595,7 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -607,11 +595,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
} else if (Value->GetBinValue(p, Long, Status)) { } else if (Value->GetBinValue(p, Long, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), sprintf(g->Message, MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), Long); Name, Value->GetSize(), Long);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif p } // endif p
break; break;
...@@ -620,11 +604,7 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -620,11 +604,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
if (n > 32767LL || n < -32768LL) { if (n > 32767LL || n < -32768LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Status) } else if (Status)
Value->GetValueNonAligned<short>(p, (short)n); Value->GetValueNonAligned<short>(p, (short)n);
...@@ -634,11 +614,7 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -634,11 +614,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
if (n > 255LL || n < -256LL) { if (n > 255LL || n < -256LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Status) } else if (Status)
*p = (char)n; *p = (char)n;
...@@ -648,11 +624,7 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -648,11 +624,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
if (n > INT_MAX || n < INT_MIN) { if (n > INT_MAX || n < INT_MIN) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Status) } else if (Status)
Value->GetValueNonAligned<int>(p, (int)n); Value->GetValueNonAligned<int>(p, (int)n);
...@@ -676,11 +648,7 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -676,11 +648,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
case 'C': // Characters case 'C': // Characters
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) { if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long); sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif n } // endif n
if (Status) { if (Status) {
...@@ -692,11 +660,7 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -692,11 +660,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endswitch Fmt } // endswitch Fmt
if (Eds && Status) { if (Eds && Status) {
......
...@@ -1435,11 +1435,7 @@ void CSVCOL::ReadColumn(PGLOBAL g) ...@@ -1435,11 +1435,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); sprintf(g->Message, MSG(INV_DEF_READ), rc);
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} // endif } // endif
if (tdbp->Mode != MODE_UPDATE) { if (tdbp->Mode != MODE_UPDATE) {
...@@ -1457,11 +1453,7 @@ void CSVCOL::ReadColumn(PGLOBAL g) ...@@ -1457,11 +1453,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
Long = colen; // Restore column length Long = colen; // Restore column length
sprintf(g->Message, MSG(FLD_TOO_LNG_FOR), sprintf(g->Message, MSG(FLD_TOO_LNG_FOR),
Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g)); Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} // endif Long } // endif Long
// Now do the reading // Now do the reading
...@@ -1524,11 +1516,7 @@ void CSVCOL::WriteColumn(PGLOBAL g) ...@@ -1524,11 +1516,7 @@ void CSVCOL::WriteColumn(PGLOBAL g)
if ((signed)strlen(p) > flen) { if ((signed)strlen(p) > flen) {
sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen, sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen,
tdbp->RowNumber(g), tdbp->GetFile(g)); tdbp->RowNumber(g), tdbp->GetFile(g));
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} else if (Dsp) } else if (Dsp)
for (int i = 0; p[i]; i++) for (int i = 0; p[i]; i++)
if (p[i] == '.') if (p[i] == '.')
...@@ -1544,11 +1532,7 @@ void CSVCOL::WriteColumn(PGLOBAL g) ...@@ -1544,11 +1532,7 @@ void CSVCOL::WriteColumn(PGLOBAL g)
if (Fldnum < 0) { if (Fldnum < 0) {
// This can happen for wrong offset value in XDB files // This can happen for wrong offset value in XDB files
sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name); sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name);
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} else } else
strncpy(tdbp->Field[Fldnum], p, flen); strncpy(tdbp->Field[Fldnum], p, flen);
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
#include "filamzip.h" #include "filamzip.h"
#endif // ZIP_SUPPORT #endif // ZIP_SUPPORT
#if defined(MONGO_SUPPORT)
#include "mongofam.h"
#endif // MONGO_SUPPORT
#include "tabmul.h" #include "tabmul.h"
#include "checklvl.h" #include "checklvl.h"
#include "resource.h" #include "resource.h"
...@@ -63,7 +66,7 @@ typedef struct _jncol { ...@@ -63,7 +66,7 @@ typedef struct _jncol {
/* JSONColumns: construct the result blocks containing the description */ /* JSONColumns: construct the result blocks containing the description */
/* of all the columns of a table contained inside a JSON file. */ /* 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, static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING};
...@@ -112,7 +115,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) ...@@ -112,7 +115,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
#endif // ZIP_SUPPORT #endif // ZIP_SUPPORT
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL); tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
if (!tdp->Fn) { if (!tdp->Fn && !dsn) {
strcpy(g->Message, MSG(MISSING_FNAME)); strcpy(g->Message, MSG(MISSING_FNAME));
return NULL; return NULL;
} // endif Fn } // endif Fn
...@@ -126,6 +129,19 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) ...@@ -126,6 +129,19 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
htrc("File %s objname=%s pretty=%d lvl=%d\n", htrc("File %s objname=%s pretty=%d lvl=%d\n",
tdp->Fn, tdp->Objname, tdp->Pretty, lvl); 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->Pretty == 2) {
if (tdp->Zipped) { if (tdp->Zipped) {
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
...@@ -151,12 +167,14 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) ...@@ -151,12 +167,14 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
if (tdp->Zipped) { if (tdp->Zipped) {
#if defined(ZIP_SUPPORT) #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 #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #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 = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp));
tjnp->SetMode(MODE_READ); tjnp->SetMode(MODE_READ);
...@@ -404,6 +422,10 @@ JSONDEF::JSONDEF(void) ...@@ -404,6 +422,10 @@ JSONDEF::JSONDEF(void)
Limit = 1; Limit = 1;
Base = 0; Base = 0;
Strict = false; Strict = false;
#if defined(MONGO_SUPPORT)
Uri = NULL;
Collname = Schema = Options = NULL;
#endif // MONGO_SUPPORT
} // end of JSONDEF constructor } // end of JSONDEF constructor
/***********************************************************************/ /***********************************************************************/
...@@ -417,7 +439,22 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) ...@@ -417,7 +439,22 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
Pretty = GetIntCatInfo("Pretty", 2); Pretty = GetIntCatInfo("Pretty", 2);
Limit = GetIntCatInfo("Limit", 10); Limit = GetIntCatInfo("Limit", 10);
Base = GetIntCatInfo("Base", 0) ? 1 : 0; 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 } // end of DefineAM
/***********************************************************************/ /***********************************************************************/
...@@ -463,7 +500,9 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) ...@@ -463,7 +500,9 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !GZ_SUPPORT #endif // !GZ_SUPPORT
} else if (map) } else if (Uri)
txfp = new(g) MGOFAM(this);
else if (map)
txfp = new(g) MAPFAM(this); txfp = new(g) MAPFAM(this);
else else
txfp = new(g) DOSFAM(this); txfp = new(g) DOSFAM(this);
...@@ -527,6 +566,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) ...@@ -527,6 +566,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
if (tdp) { if (tdp) {
Jmode = tdp->Jmode; Jmode = tdp->Jmode;
Objname = tdp->Objname; Objname = tdp->Objname;
Amtype = (tdp->Uri ? TYPE_AM_MGO : TYPE_AM_JSN);
Xcol = tdp->Xcol; Xcol = tdp->Xcol;
Limit = tdp->Limit; Limit = tdp->Limit;
Pretty = tdp->Pretty; Pretty = tdp->Pretty;
...@@ -535,7 +575,8 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) ...@@ -535,7 +575,8 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
} else { } else {
Jmode = MODE_OBJECT; Jmode = MODE_OBJECT;
Objname = NULL; Objname = NULL;
Xcol = NULL; Amtype = TYPE_AM_JSN;
Xcol = NULL;
Limit = 1; Limit = 1;
Pretty = 0; Pretty = 0;
B = 0; B = 0;
...@@ -865,16 +906,16 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp) ...@@ -865,16 +906,16 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
} // end of PrepareWriting } // end of PrepareWriting
/***********************************************************************/ /***********************************************************************/
/* WriteDB: Data Base write routine for DOS access method. */ /* WriteDB: Data Base write routine for DOS access method. */
/***********************************************************************/ /***********************************************************************/
int TDBJSN::WriteDB(PGLOBAL g) int TDBJSN::WriteDB(PGLOBAL g)
{ {
int rc = TDBDOS::WriteDB(g); int rc = TDBDOS::WriteDB(g);
#if USE_G #if USE_G
if (rc == RC_FX) //if (rc == RC_FX)
strcpy(g->Message, G->Message); // strcpy(g->Message, G->Message);
PlugSubSet(G, G->Sarea, G->Sarea_Size); PlugSubSet(G, G->Sarea, G->Sarea_Size);
#endif #endif
...@@ -882,7 +923,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp) ...@@ -882,7 +923,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
return rc; return rc;
} // end of WriteDB } // end of WriteDB
/* ---------------------------- JSONCOL ------------------------------ */ /* ---------------------------- JSONCOL ------------------------------ */
/***********************************************************************/ /***********************************************************************/
/* JSONCOL public constructor. */ /* JSONCOL public constructor. */
...@@ -1290,11 +1331,7 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n) ...@@ -1290,11 +1331,7 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n)
if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) { if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) {
strcpy(g->Message, "Logical error expanding array"); strcpy(g->Message, "Logical error expanding array");
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
} // endif jvp } // endif jvp
if (n < Nod - 1 && jvp->GetJson()) { if (n < Nod - 1 && jvp->GetJson()) {
...@@ -1480,11 +1517,7 @@ void JSONCOL::WriteColumn(PGLOBAL g) ...@@ -1480,11 +1517,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
{ {
if (Xpd && Tjp->Pretty < 2) { if (Xpd && Tjp->Pretty < 2) {
strcpy(g->Message, "Cannot write expanded column when Pretty is not 2"); strcpy(g->Message, "Cannot write expanded column when Pretty is not 2");
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
} // endif Xpd } // endif Xpd
/*********************************************************************/ /*********************************************************************/
...@@ -1519,11 +1552,7 @@ void JSONCOL::WriteColumn(PGLOBAL g) ...@@ -1519,11 +1552,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
if (!(jsp = ParseJson(G, s, (int)strlen(s)))) { if (!(jsp = ParseJson(G, s, (int)strlen(s)))) {
strcpy(g->Message, s); strcpy(g->Message, s);
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
} // endif jsp } // endif jsp
if (arp) { if (arp) {
...@@ -1996,6 +2025,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) ...@@ -1996,6 +2025,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
{ {
Topt = tdp->GetTopt(); Topt = tdp->GetTopt();
Db = (char*)tdp->GetDB(); Db = (char*)tdp->GetDB();
Dsn = (char*)tdp->Uri;
} // end of TDBJCL constructor } // end of TDBJCL constructor
/***********************************************************************/ /***********************************************************************/
...@@ -2003,7 +2033,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) ...@@ -2003,7 +2033,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBJCL::GetResult(PGLOBAL g) PQRYRES TDBJCL::GetResult(PGLOBAL g)
{ {
return JSONColumns(g, Db, Topt, false); return JSONColumns(g, Db, Dsn, Topt, false);
} // end of GetResult } // end of GetResult
/* --------------------------- End of json --------------------------- */ /* --------------------------- End of json --------------------------- */
/*************** tabjson H Declares Source Code File (.H) **************/ /*************** 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 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
/* */ /* */
...@@ -36,8 +36,11 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */ ...@@ -36,8 +36,11 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */
friend class TDBJSON; friend class TDBJSON;
friend class TDBJSN; friend class TDBJSN;
friend class TDBJCL; friend class TDBJCL;
friend PQRYRES JSONColumns(PGLOBAL, char*, PTOS, bool); friend PQRYRES JSONColumns(PGLOBAL, char*, char*, PTOS, bool);
public: #if defined(MONGO_SUPPORT)
friend class MGOFAM;
#endif // MONGO_SUPPORT
public:
// Constructor // Constructor
JSONDEF(void); JSONDEF(void);
...@@ -58,6 +61,12 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */ ...@@ -58,6 +61,12 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */
int Level; /* Used for catalog table */ int Level; /* Used for catalog table */
int Base; /* Tne array index base */ int Base; /* Tne array index base */
bool Strict; /* Strict syntax checking */ 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 }; // end of JSONDEF
/* -------------------------- TDBJSN class --------------------------- */ /* -------------------------- TDBJSN class --------------------------- */
...@@ -75,7 +84,7 @@ class DllExport TDBJSN : public TDBDOS { ...@@ -75,7 +84,7 @@ class DllExport TDBJSN : public TDBDOS {
TDBJSN(TDBJSN *tdbp); TDBJSN(TDBJSN *tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_JSN;} virtual AMT GetAmType(void) {return Amtype;}
virtual bool SkipHeader(PGLOBAL g); virtual bool SkipHeader(PGLOBAL g);
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);}
PJSON GetRow(void) {return Row;} PJSON GetRow(void) {return Row;}
...@@ -107,6 +116,7 @@ class DllExport TDBJSN : public TDBDOS { ...@@ -107,6 +116,7 @@ class DllExport TDBJSN : public TDBDOS {
PJSON Val; // The value of the current row PJSON Val; // The value of the current row
PJCOL Colp; // The multiple column PJCOL Colp; // The multiple column
JMODE Jmode; // MODE_OBJECT by default JMODE Jmode; // MODE_OBJECT by default
AMT Amtype; // Access method type
char *Objname; // The table object name char *Objname; // The table object name
char *Xcol; // Name of expandable column char *Xcol; // Name of expandable column
int Fpos; // The current row index int Fpos; // The current row index
...@@ -233,4 +243,5 @@ class DllExport TDBJCL : public TDBCAT { ...@@ -233,4 +243,5 @@ class DllExport TDBJCL : public TDBCAT {
// Members // Members
PTOS Topt; PTOS Topt;
char *Db; char *Db;
char *Dsn;
}; // end of class TDBJCL }; // end of class TDBJCL
...@@ -1008,11 +1008,7 @@ void DIRCOL::ReadColumn(PGLOBAL g) ...@@ -1008,11 +1008,7 @@ void DIRCOL::ReadColumn(PGLOBAL g)
#endif // !__WIN__ #endif // !__WIN__
default: default:
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N); sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
#if defined(USE_TRY)
throw GetAmType(); throw GetAmType();
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], GetAmType());
#endif // !USE_TRY
} // endswitch N } // endswitch N
} // end of ReadColumn } // end of ReadColumn
...@@ -1537,11 +1533,7 @@ void TDBDHR::CloseDB(PGLOBAL g) ...@@ -1537,11 +1533,7 @@ void TDBDHR::CloseDB(PGLOBAL g)
// Close the search handle. // Close the search handle.
if (!FindClose(Hsearch)) { if (!FindClose(Hsearch)) {
strcpy(g->Message, MSG(SRCH_CLOSE_ERR)); strcpy(g->Message, MSG(SRCH_CLOSE_ERR));
#if defined(USE_TRY)
throw GetAmType(); throw GetAmType();
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], GetAmType());
#endif // !USE_TRY
} // endif FindClose } // endif FindClose
iFile = 0; iFile = 0;
......
...@@ -1407,11 +1407,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g) ...@@ -1407,11 +1407,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); sprintf(g->Message, MSG(INV_DEF_READ), rc);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} else } else
tdbp->Fetched = true; tdbp->Fetched = true;
......
This diff is collapsed.
...@@ -511,19 +511,11 @@ void INICOL::WriteColumn(PGLOBAL g) ...@@ -511,19 +511,11 @@ void INICOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Flag == 1) { } else if (Flag == 1) {
if (tdbp->Mode == MODE_UPDATE) { if (tdbp->Mode == MODE_UPDATE) {
strcpy(g->Message, MSG(NO_SEC_UPDATE)); strcpy(g->Message, MSG(NO_SEC_UPDATE));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (*p) { } else if (*p) {
tdbp->Section = p; tdbp->Section = p;
} else } else
...@@ -532,11 +524,7 @@ void INICOL::WriteColumn(PGLOBAL g) ...@@ -532,11 +524,7 @@ void INICOL::WriteColumn(PGLOBAL g)
return; return;
} else if (!tdbp->Section) { } else if (!tdbp->Section) {
strcpy(g->Message, MSG(SEC_NAME_FIRST)); strcpy(g->Message, MSG(SEC_NAME_FIRST));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif's } // endif's
/*********************************************************************/ /*********************************************************************/
...@@ -548,11 +536,7 @@ void INICOL::WriteColumn(PGLOBAL g) ...@@ -548,11 +536,7 @@ void INICOL::WriteColumn(PGLOBAL g)
if (!rc) { if (!rc) {
sprintf(g->Message, "Error %d writing to %s", sprintf(g->Message, "Error %d writing to %s",
GetLastError(), tdbp->Ifile); GetLastError(), tdbp->Ifile);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif rc } // endif rc
} // endif Status } // endif Status
...@@ -853,19 +837,11 @@ void XINCOL::WriteColumn(PGLOBAL g) ...@@ -853,19 +837,11 @@ void XINCOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Flag == 1) { } else if (Flag == 1) {
if (tdbp->Mode == MODE_UPDATE) { if (tdbp->Mode == MODE_UPDATE) {
strcpy(g->Message, MSG(NO_SEC_UPDATE)); strcpy(g->Message, MSG(NO_SEC_UPDATE));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (*p) { } else if (*p) {
tdbp->Section = p; tdbp->Section = p;
} else } else
...@@ -875,11 +851,7 @@ void XINCOL::WriteColumn(PGLOBAL g) ...@@ -875,11 +851,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
} else if (Flag == 2) { } else if (Flag == 2) {
if (tdbp->Mode == MODE_UPDATE) { if (tdbp->Mode == MODE_UPDATE) {
strcpy(g->Message, MSG(NO_KEY_UPDATE)); strcpy(g->Message, MSG(NO_KEY_UPDATE));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (*p) { } else if (*p) {
tdbp->Keycur = p; tdbp->Keycur = p;
} else } else
...@@ -888,11 +860,7 @@ void XINCOL::WriteColumn(PGLOBAL g) ...@@ -888,11 +860,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
return; return;
} else if (!tdbp->Section || !tdbp->Keycur) { } else if (!tdbp->Section || !tdbp->Keycur) {
strcpy(g->Message, MSG(SEC_KEY_FIRST)); strcpy(g->Message, MSG(SEC_KEY_FIRST));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif's } // endif's
/*********************************************************************/ /*********************************************************************/
...@@ -904,11 +872,7 @@ void XINCOL::WriteColumn(PGLOBAL g) ...@@ -904,11 +872,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
if (!rc) { if (!rc) {
sprintf(g->Message, "Error %d writing to %s", sprintf(g->Message, "Error %d writing to %s",
GetLastError(), tdbp->Ifile); GetLastError(), tdbp->Ifile);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif rc } // endif rc
} // endif Status } // endif Status
......
...@@ -490,11 +490,7 @@ void VCTCOL::ReadBlock(PGLOBAL g) ...@@ -490,11 +490,7 @@ void VCTCOL::ReadBlock(PGLOBAL g)
#if defined(_DEBUG) #if defined(_DEBUG)
if (!Blk) { if (!Blk) {
strcpy(g->Message, MSG(TO_BLK_IS_NULL)); strcpy(g->Message, MSG(TO_BLK_IS_NULL));
#if defined(USE_TRY)
throw 58; throw 58;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 58);
#endif // !USE_TRY
} // endif } // endif
#endif #endif
...@@ -502,11 +498,7 @@ void VCTCOL::ReadBlock(PGLOBAL g) ...@@ -502,11 +498,7 @@ void VCTCOL::ReadBlock(PGLOBAL g)
/* Read column block according to used access method. */ /* Read column block according to used access method. */
/*********************************************************************/ /*********************************************************************/
if (txfp->ReadBlock(g, this)) if (txfp->ReadBlock(g, this))
#if defined(USE_TRY)
throw 6; throw 6;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 6);
#endif // !USE_TRY
ColBlk = txfp->CurBlk; ColBlk = txfp->CurBlk;
ColPos = -1; // Any invalid position ColPos = -1; // Any invalid position
...@@ -526,11 +518,7 @@ void VCTCOL::WriteBlock(PGLOBAL g) ...@@ -526,11 +518,7 @@ void VCTCOL::WriteBlock(PGLOBAL g)
#if defined(_DEBUG) #if defined(_DEBUG)
if (!Blk) { if (!Blk) {
strcpy(g->Message, MSG(BLK_IS_NULL)); strcpy(g->Message, MSG(BLK_IS_NULL));
#if defined(USE_TRY)
throw 56; throw 56;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 56);
#endif // !USE_TRY
} // endif } // endif
#endif #endif
...@@ -538,11 +526,7 @@ void VCTCOL::WriteBlock(PGLOBAL g) ...@@ -538,11 +526,7 @@ void VCTCOL::WriteBlock(PGLOBAL g)
/* Write column block according to used access method. */ /* Write column block according to used access method. */
/*******************************************************************/ /*******************************************************************/
if (txfp->WriteBlock(g, this)) if (txfp->WriteBlock(g, this))
#if defined(USE_TRY)
throw 6; throw 6;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 6);
#endif // !USE_TRY
Modif = 0; Modif = 0;
} // endif Modif } // endif Modif
......
...@@ -289,11 +289,7 @@ void VIRCOL::ReadColumn(PGLOBAL g) ...@@ -289,11 +289,7 @@ void VIRCOL::ReadColumn(PGLOBAL g)
{ {
// This should never be called // This should never be called
sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name); sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name);
#if defined(USE_TRY)
throw TYPE_COLBLK; throw TYPE_COLBLK;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
#endif // !USE_TRY
} // end of ReadColumn } // end of ReadColumn
/* ---------------------------TDBVICL class -------------------------- */ /* ---------------------------TDBVICL class -------------------------- */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment