Commit 3e36eb23 authored by Olivier Bertrand's avatar Olivier Bertrand

Fix gcc compiler warnings reported by Sergei

  modified:   storage/connect/array.cpp
  modified:   storage/connect/array.h
  modified:   storage/connect/blkfil.cpp
  modified:   storage/connect/blkfil.h
  modified:   storage/connect/block.h
  modified:   storage/connect/colblk.cpp
  modified:   storage/connect/colblk.h
  modified:   storage/connect/csort.h
  modified:   storage/connect/filamvct.cpp
  modified:   storage/connect/filter.cpp
  modified:   storage/connect/filter.h
  modified:   storage/connect/global.h
  modified:   storage/connect/json.h
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/plgdbutl.cpp
  modified:   storage/connect/tabcol.cpp
  modified:   storage/connect/tabcol.h
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabdos.h
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/table.cpp
  modified:   storage/connect/tabodbc.cpp
  modified:   storage/connect/tabodbc.h
  modified:   storage/connect/tabsys.h
  modified:   storage/connect/tabxml.h
  modified:   storage/connect/value.cpp
  modified:   storage/connect/value.h
  modified:   storage/connect/xindex.cpp
  modified:   storage/connect/xindex.h
  modified:   storage/connect/xobject.cpp
  modified:   storage/connect/xobject.h
  modified:   storage/connect/xtable.h

Set values as nullable when retrieving catalog info
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/mysql-test/connect/r/odbc_oracle.result
  modified:   storage/connect/odbconn.cpp

Change format of Jpath
  modified:   storage/connect/json.cpp
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/mysql-test/connect/r/json.result
  modified:   storage/connect/mysql-test/connect/r/json_udf.result
  modified:   storage/connect/mysql-test/connect/r/json_udf_bin.result
  modified:   storage/connect/mysql-test/connect/r/zip.result
  modified:   storage/connect/mysql-test/connect/t/json.test
  modified:   storage/connect/mysql-test/connect/t/json_udf.test
  modified:   storage/connect/mysql-test/connect/t/json_udf_bin.test
  modified:   storage/connect/mysql-test/connect/t/zip.test
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h
  modified:   storage/connect/tabmgo.cpp

Change null representation from ??? to <null>
  modified:   storage/connect/json.cpp

Change the name of UDF that are equal to a native JSON function name
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h
  modified:   storage/connect/mysql-test/connect/t/json_udf.inc
  modified:   storage/connect/mysql-test/connect/t/json_udf2.inc

Fix bug in making JSON project info
  modified:   storage/connect/mongofam.cpp

Fix COMPUTE when one argument is null
  modified:   storage/connect/value.cpp

Value is null only when nullable
  modified:   storage/connect/value.h
parent e8333389
...@@ -18,10 +18,10 @@ SET(CONNECT_PLUGIN_DYNAMIC "connect") ...@@ -18,10 +18,10 @@ SET(CONNECT_PLUGIN_DYNAMIC "connect")
SET(CONNECT_SOURCES SET(CONNECT_SOURCES
ha_connect.cc connect.cc user_connect.cc mycat.cc ha_connect.cc connect.cc user_connect.cc mycat.cc
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h fmdlex.c osutil.c rcmsg.c rcmsg.h
array.cpp blkfil.cpp colblk.cpp csort.cpp array.cpp blkfil.cpp colblk.cpp csort.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp filter.cpp
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp plugutil.cpp
reldef.cpp tabcol.cpp tabdos.cpp tabext.cpp tabfix.cpp tabfmt.cpp tabjson.cpp reldef.cpp tabcol.cpp tabdos.cpp tabext.cpp tabfix.cpp tabfmt.cpp tabjson.cpp
table.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp table.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp
tabutil.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp tabutil.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
...@@ -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,7 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES} ...@@ -310,6 +335,7 @@ 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} $(MONGO_LIBRARY)
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY}) ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY})
...@@ -519,7 +519,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm) ...@@ -519,7 +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);
longjmp(g->jumper[g->jump_level], TYPE_ARRAY); throw TYPE_ARRAY;
} else // OP_EXIST } else // OP_EXIST
return Nval > 0; return Nval > 0;
...@@ -681,14 +681,14 @@ void ARRAY::SetPrecision(PGLOBAL g, int p) ...@@ -681,14 +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));
longjmp(g->jumper[g->jump_level], TYPE_ARRAY); throw TYPE_ARRAY;
} // 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));
longjmp(g->jumper[g->jump_level], TYPE_ARRAY); throw TYPE_ARRAY;
} // endif Vblp } // endif Vblp
if (was || !p) if (was || !p)
...@@ -699,7 +699,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p) ...@@ -699,7 +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))
longjmp(g->jumper[g->jump_level], TYPE_ARRAY); throw TYPE_ARRAY;
} // end of SetPrecision } // end of SetPrecision
...@@ -977,14 +977,14 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g) ...@@ -977,14 +977,14 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
size_t z, len = 2; size_t z, len = 2;
if (Type == TYPE_LIST) if (Type == TYPE_LIST)
return "(?" "?" "?)"; // To be implemented return (PSZ)("(?" "?" "?)"); // To be implemented
z = MY_MAX(24, GetTypeSize(Type, Len) + 4); z = MY_MAX(24, GetTypeSize(Type, Len) + 4);
tp = (char*)PlugSubAlloc(g, NULL, z); tp = (char*)PlugSubAlloc(g, NULL, z);
for (i = 0; i < Nval; i++) { for (i = 0; i < Nval; i++) {
Value->SetValue_pvblk(Vblp, i); Value->SetValue_pvblk(Vblp, i);
Value->Print(g, tp, z); Value->Prints(g, tp, z);
len += strlen(tp); len += strlen(tp);
} // enfor i } // enfor i
...@@ -996,7 +996,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g) ...@@ -996,7 +996,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
for (i = 0; i < Nval;) { for (i = 0; i < Nval;) {
Value->SetValue_pvblk(Vblp, i); Value->SetValue_pvblk(Vblp, i);
Value->Print(g, tp, z); Value->Prints(g, tp, z);
strcat(p, tp); strcat(p, tp);
strcat(p, (++i == Nval) ? ")" : ","); strcat(p, (++i == Nval) ? ")" : ",");
} // enfor i } // enfor i
...@@ -1010,7 +1010,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g) ...@@ -1010,7 +1010,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Make file output of ARRAY contents. */ /* Make file output of ARRAY contents. */
/***********************************************************************/ /***********************************************************************/
void ARRAY::Print(PGLOBAL g, FILE *f, uint n) void ARRAY::Printf(PGLOBAL g, FILE *f, uint n)
{ {
char m[64]; char m[64];
int lim = MY_MIN(Nval,10); int lim = MY_MIN(Nval,10);
...@@ -1027,25 +1027,25 @@ void ARRAY::Print(PGLOBAL g, FILE *f, uint n) ...@@ -1027,25 +1027,25 @@ void ARRAY::Print(PGLOBAL g, FILE *f, uint n)
if (Vblp) if (Vblp)
for (int i = 0; i < lim; i++) { for (int i = 0; i < lim; i++) {
Value->SetValue_pvblk(Vblp, i); Value->SetValue_pvblk(Vblp, i);
Value->Print(g, f, n+4); Value->Printf(g, f, n+4);
} // endfor i } // endfor i
} else } else
fprintf(f, "%sVALLST: numval=%d\n", m, Nval); fprintf(f, "%sVALLST: numval=%d\n", m, Nval);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of ARRAY contents. */ /* Make string output of ARRAY contents. */
/***********************************************************************/ /***********************************************************************/
void ARRAY::Print(PGLOBAL, char *ps, uint z) void ARRAY::Prints(PGLOBAL, char *ps, uint z)
{ {
if (z < 16) if (z < 16)
return; return;
sprintf(ps, "ARRAY: type=%d\n", Type); sprintf(ps, "ARRAY: type=%d\n", Type);
// More to be implemented later // More to be implemented later
} // end of Print } // end of Prints
/* -------------------------- Class MULAR ---------------------------- */ /* -------------------------- Class MULAR ---------------------------- */
......
...@@ -56,8 +56,8 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock ...@@ -56,8 +56,8 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
virtual bool Compare(PXOB) {assert(false); return false;} virtual bool Compare(PXOB) {assert(false); return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(false); return false;} virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(false); return false;}
//virtual int CheckSpcCol(PTDB, int) {return 0;} //virtual int CheckSpcCol(PTDB, int) {return 0;}
virtual void Print(PGLOBAL g, FILE *f, uint n); virtual void Printf(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z); virtual void Prints(PGLOBAL g, char *ps, uint z);
// void Empty(void); // void Empty(void);
void SetPrecision(PGLOBAL g, int p); void SetPrecision(PGLOBAL g, int p);
bool AddValue(PGLOBAL g, PSZ sp); bool AddValue(PGLOBAL g, PSZ sp);
......
/************* BlkFil C++ Program Source Code File (.CPP) **************/ /************* BlkFil C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: BLKFIL */ /* PROGRAM NAME: BLKFIL */
/* ------------- */ /* ------------- */
/* Version 2.5 */ /* Version 2.6 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2017 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -56,7 +56,7 @@ BLOCKFILTER::BLOCKFILTER(PTDBDOS tdbp, int op) ...@@ -56,7 +56,7 @@ BLOCKFILTER::BLOCKFILTER(PTDBDOS tdbp, int op)
/***********************************************************************/ /***********************************************************************/
/* Make file output of BLOCKFILTER contents. */ /* Make file output of BLOCKFILTER contents. */
/***********************************************************************/ /***********************************************************************/
void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n) void BLOCKFILTER::Printf(PGLOBAL, FILE *f, uint n)
{ {
char m[64]; char m[64];
...@@ -65,15 +65,15 @@ void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n) ...@@ -65,15 +65,15 @@ void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n)
fprintf(f, "%sBLOCKFILTER: at %p opc=%d opm=%d result=%d\n", fprintf(f, "%sBLOCKFILTER: at %p opc=%d opm=%d result=%d\n",
m, this, Opc, Opm, Result); m, this, Opc, Opm, Result);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of BLOCKFILTER contents. */ /* Make string output of BLOCKFILTER contents. */
/***********************************************************************/ /***********************************************************************/
void BLOCKFILTER::Print(PGLOBAL, char *ps, uint z) void BLOCKFILTER::Prints(PGLOBAL, char *ps, uint z)
{ {
strncat(ps, "BlockFilter(s)", z); strncat(ps, "BlockFilter(s)", z);
} // end of Print } // end of Prints
/* ---------------------- Class BLKFILLOG ---------------------------- */ /* ---------------------- Class BLKFILLOG ---------------------------- */
...@@ -412,7 +412,7 @@ void BLKFILMR2::MakeValueBitmap(void) ...@@ -412,7 +412,7 @@ void BLKFILMR2::MakeValueBitmap(void)
Void = !Bmp[N]; // There are no good values in the file Void = !Bmp[N]; // There are no good values in the file
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
Bxp[i] = ~0U; Bxp[i] = ~0;
if (noteq) if (noteq)
Bmp[i] = Bxp[i]; Bmp[i] = Bxp[i];
...@@ -595,7 +595,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp) ...@@ -595,7 +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));
longjmp(g->jumper[g->jump_level], 99); throw g->Message;
} else if (Colp->GetValue()->IsCi()) } else if (Colp->GetValue()->IsCi())
Arap->SetPrecision(g, 1); // Case insensitive Arap->SetPrecision(g, 1); // Case insensitive
...@@ -708,7 +708,7 @@ void BLKFILIN2::MakeValueBitmap(void) ...@@ -708,7 +708,7 @@ void BLKFILIN2::MakeValueBitmap(void)
Void = !Bmp[N]; // There are no good values in the file Void = !Bmp[N]; // There are no good values in the file
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
Bxp[i] = ~0U; Bxp[i] = ~0;
if (noteq) { if (noteq) {
Bmp[i] = Bxp[i]; Bmp[i] = Bxp[i];
...@@ -828,7 +828,7 @@ BLKFILIN2::BLKFILIN2(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp) ...@@ -828,7 +828,7 @@ BLKFILIN2::BLKFILIN2(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
Bxp[i] |= btp; Bxp[i] |= btp;
for (N = i--; i >= 0; i--) for (N = i--; i >= 0; i--)
Bxp[i] = ~0U; Bxp[i] = ~0;
break; break;
} // endif Bmp } // endif Bmp
...@@ -995,7 +995,7 @@ int BLOCKINDEX::BlockEval(PGLOBAL g) ...@@ -995,7 +995,7 @@ int BLOCKINDEX::BlockEval(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Make file output of BLOCKINDEX contents. */ /* Make file output of BLOCKINDEX contents. */
/***********************************************************************/ /***********************************************************************/
void BLOCKINDEX::Print(PGLOBAL g, FILE *f, UINT n) void BLOCKINDEX::Printf(PGLOBAL g, FILE *f, UINT n)
{ {
char m[64]; char m[64];
...@@ -1006,17 +1006,17 @@ void BLOCKINDEX::Print(PGLOBAL g, FILE *f, UINT n) ...@@ -1006,17 +1006,17 @@ void BLOCKINDEX::Print(PGLOBAL g, FILE *f, UINT n)
m, this, Next, (Colp) ? Colp->GetName() : "Rowid", Kxp, Result); m, this, Next, (Colp) ? Colp->GetName() : "Rowid", Kxp, Result);
if (Next) if (Next)
Next->Print(g, f, n); Next->Printf(g, f, n);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of BLOCKINDEX contents. */ /* Make string output of BLOCKINDEX contents. */
/***********************************************************************/ /***********************************************************************/
void BLOCKINDEX::Print(PGLOBAL g, char *ps, UINT z) void BLOCKINDEX::Prints(PGLOBAL g, char *ps, UINT z)
{ {
strncat(ps, "BlockIndex(es)", z); strncat(ps, "BlockIndex(es)", z);
} // end of Print } // end of Prints
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
......
...@@ -27,8 +27,8 @@ class DllExport BLOCKFILTER : public BLOCK { /* Block Filter */ ...@@ -27,8 +27,8 @@ class DllExport BLOCKFILTER : public BLOCK { /* Block Filter */
// Methods // Methods
virtual void Reset(PGLOBAL) = 0; virtual void Reset(PGLOBAL) = 0;
virtual int BlockEval(PGLOBAL) = 0; virtual int BlockEval(PGLOBAL) = 0;
virtual void Print(PGLOBAL g, FILE *f, uint n); virtual void Printf(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z); virtual void Prints(PGLOBAL g, char *ps, uint z);
protected: protected:
BLOCKFILTER(void) {} // Standard constructor not to be used BLOCKFILTER(void) {} // Standard constructor not to be used
...@@ -234,8 +234,8 @@ class DllExport BLOCKINDEX : public BLOCK { /* Indexing Test Block */ ...@@ -234,8 +234,8 @@ class DllExport BLOCKINDEX : public BLOCK { /* Indexing Test Block */
// Methods // Methods
void Reset(void); void Reset(void);
virtual int BlockEval(PGLOBAL); virtual int BlockEval(PGLOBAL);
virtual void Print(PGLOBAL g, FILE *f, UINT n); virtual void Printf(PGLOBAL g, FILE *f, UINT n);
virtual void Print(PGLOBAL g, char *ps, UINT z); virtual void Prints(PGLOBAL g, char *ps, UINT z);
protected: protected:
BLOCKINDEX(void) {} // Standard constructor not to be used BLOCKINDEX(void) {} // Standard constructor not to be used
......
...@@ -44,8 +44,8 @@ class DllExport BLOCK { ...@@ -44,8 +44,8 @@ class DllExport BLOCK {
return (PlugSubAlloc(g, p, size)); return (PlugSubAlloc(g, p, size));
} // end of new } // end of new
virtual void Print(PGLOBAL, FILE *, uint) {} // Produce file desc virtual void Printf(PGLOBAL, FILE *, uint) {} // Produce file desc
virtual void Print(PGLOBAL, char *, uint) {} // Produce string desc virtual void Prints(PGLOBAL, char *, uint) {} // Produce string desc
#if !defined(__BORLANDC__) #if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator // Avoid warning C4291 by defining a matching dummy delete operator
......
...@@ -36,7 +36,7 @@ typedef struct _curtab { ...@@ -36,7 +36,7 @@ typedef struct _curtab {
/* Defines the structure used to get column catalog info. */ /* Defines the structure used to get column catalog info. */
/***********************************************************************/ /***********************************************************************/
typedef struct _colinfo { typedef struct _colinfo {
char *Name; PCSZ Name;
int Type; int Type;
int Offset; int Offset;
int Length; int Length;
...@@ -45,9 +45,9 @@ typedef struct _colinfo { ...@@ -45,9 +45,9 @@ typedef struct _colinfo {
int Scale; int Scale;
int Opt; int Opt;
int Freq; int Freq;
char *Remark; PCSZ Remark;
char *Datefmt; PCSZ Datefmt;
char *Fieldfmt; PCSZ Fieldfmt;
ushort Flags; // Used by MariaDB CONNECT handlers ushort Flags; // Used by MariaDB CONNECT handlers
} COLINFO, *PCOLINFO; } COLINFO, *PCOLINFO;
...@@ -68,11 +68,9 @@ class DllExport CATALOG { ...@@ -68,11 +68,9 @@ class DllExport CATALOG {
bool GetDefHuge(void) {return DefHuge;} bool GetDefHuge(void) {return DefHuge;}
void SetDefHuge(bool b) {DefHuge = b;} void SetDefHuge(bool b) {DefHuge = b;}
char *GetCbuf(void) {return Cbuf;} char *GetCbuf(void) {return Cbuf;}
//char *GetDataPath(void) {return (char*)DataPath;}
// Methods // Methods
virtual void Reset(void) {} virtual void Reset(void) {}
//virtual void SetDataPath(PGLOBAL g, const char *path) {}
virtual bool CheckName(PGLOBAL, char*) {return true;} virtual bool CheckName(PGLOBAL, char*) {return true;}
virtual bool ClearName(PGLOBAL, PSZ) {return true;} virtual bool ClearName(PGLOBAL, PSZ) {return true;}
virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;} virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}
...@@ -102,7 +100,6 @@ class DllExport CATALOG { ...@@ -102,7 +100,6 @@ class DllExport CATALOG {
int Cblen; /* Length of suballoc. buffer */ int Cblen; /* Length of suballoc. buffer */
CURTAB Ctb; /* Used to enumerate tables */ CURTAB Ctb; /* Used to enumerate tables */
bool DefHuge; /* true: tables default to huge */ bool DefHuge; /* true: tables default to huge */
//LPCSTR DataPath; /* Is the Path of DB data dir */
}; // end of class CATALOG }; // end of class CATALOG
#endif // __CATALOG__H #endif // __CATALOG__H
...@@ -195,10 +195,10 @@ int COLBLK::GetLengthEx(void) ...@@ -195,10 +195,10 @@ 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");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); throw TYPE_COLBLK;
} // end of ReadColumn } // end of ReadColumn
/***********************************************************************/ /***********************************************************************/
/* WriteColumn: what this routine does is to access the last line */ /* WriteColumn: what this routine does is to access the last line */
...@@ -206,15 +206,15 @@ void COLBLK::ReadColumn(PGLOBAL g) ...@@ -206,15 +206,15 @@ 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");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); throw TYPE_COLBLK;
} // end of WriteColumn } // end of WriteColumn
/***********************************************************************/ /***********************************************************************/
/* Make file output of a column descriptor block. */ /* Make file output of a column descriptor block. */
/***********************************************************************/ /***********************************************************************/
void COLBLK::Print(PGLOBAL, FILE *f, uint n) void COLBLK::Printf(PGLOBAL, FILE *f, uint n)
{ {
char m[64]; char m[64];
int i; int i;
...@@ -232,15 +232,15 @@ void COLBLK::Print(PGLOBAL, FILE *f, uint n) ...@@ -232,15 +232,15 @@ void COLBLK::Print(PGLOBAL, FILE *f, uint n)
fprintf(f, fprintf(f,
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n", " coluse=%04X status=%04X buftyp=%d value=%p name=%s\n",
ColUse, Status, Buf_Type, Value, Name); ColUse, Status, Buf_Type, Value, Name);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of a column descriptor block. */ /* Make string output of a column descriptor block. */
/***********************************************************************/ /***********************************************************************/
void COLBLK::Print(PGLOBAL, char *ps, uint) void COLBLK::Prints(PGLOBAL, char *ps, uint)
{ {
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name); sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
} // end of Print } // end of Prints
/***********************************************************************/ /***********************************************************************/
...@@ -260,10 +260,10 @@ SPCBLK::SPCBLK(PCOLUMN cp) ...@@ -260,10 +260,10 @@ 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);
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); throw TYPE_COLBLK;
} // end of WriteColumn } // end of WriteColumn
/***********************************************************************/ /***********************************************************************/
/* RIDBLK constructor for the ROWID special column. */ /* RIDBLK constructor for the ROWID special column. */
...@@ -377,7 +377,7 @@ PRTBLK::PRTBLK(PCOLUMN cp) : SPCBLK(cp) ...@@ -377,7 +377,7 @@ PRTBLK::PRTBLK(PCOLUMN cp) : SPCBLK(cp)
void PRTBLK::ReadColumn(PGLOBAL g) void PRTBLK::ReadColumn(PGLOBAL g)
{ {
if (Pname == NULL) { if (Pname == NULL) {
char *p; const char *p;
Pname = To_Tdb->GetDef()->GetStringCatInfo(g, "partname", "?"); Pname = To_Tdb->GetDef()->GetStringCatInfo(g, "partname", "?");
p = strrchr(Pname, '#'); p = strrchr(Pname, '#');
...@@ -407,7 +407,7 @@ SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp) ...@@ -407,7 +407,7 @@ SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp)
void SIDBLK::ReadColumn(PGLOBAL) void SIDBLK::ReadColumn(PGLOBAL)
{ {
//if (Sname == NULL) { //if (Sname == NULL) {
Sname = (char*)To_Tdb->GetServer(); Sname = To_Tdb->GetServer();
Value->SetValue_psz(Sname); Value->SetValue_psz(Sname);
// } // endif Sname // } // endif Sname
......
...@@ -72,8 +72,8 @@ class DllExport COLBLK : public XOBJECT { ...@@ -72,8 +72,8 @@ class DllExport COLBLK : public XOBJECT {
virtual void SetTo_Val(PVAL) {} virtual void SetTo_Val(PVAL) {}
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint); virtual void Printf(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint); virtual void Prints(PGLOBAL g, char *, uint);
virtual bool VarSize(void) {return false;} virtual bool VarSize(void) {return false;}
bool InitValue(PGLOBAL g); bool InitValue(PGLOBAL g);
...@@ -154,7 +154,7 @@ class DllExport FIDBLK : public SPCBLK { ...@@ -154,7 +154,7 @@ class DllExport FIDBLK : public SPCBLK {
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
PSZ Fn; // The current To_File of the table PCSZ Fn; // The current To_File of the table
OPVAL Op; // The file part operator OPVAL Op; // The file part operator
}; // end of class FIDBLK }; // end of class FIDBLK
...@@ -178,7 +178,7 @@ class DllExport TIDBLK : public SPCBLK { ...@@ -178,7 +178,7 @@ class DllExport TIDBLK : public SPCBLK {
TIDBLK(void) {} TIDBLK(void) {}
// Members // Members
PSZ Tname; // The current table name PCSZ Tname; // The current table name
}; // end of class TIDBLK }; // end of class TIDBLK
/***********************************************************************/ /***********************************************************************/
...@@ -201,7 +201,7 @@ class DllExport PRTBLK : public SPCBLK { ...@@ -201,7 +201,7 @@ class DllExport PRTBLK : public SPCBLK {
PRTBLK(void) {} PRTBLK(void) {}
// Members // Members
PSZ Pname; // The current partition name PCSZ Pname; // The current partition name
}; // end of class PRTBLK }; // end of class PRTBLK
/***********************************************************************/ /***********************************************************************/
...@@ -224,7 +224,7 @@ class DllExport SIDBLK : public SPCBLK { ...@@ -224,7 +224,7 @@ class DllExport SIDBLK : public SPCBLK {
SIDBLK(void) {} SIDBLK(void) {}
// Members // Members
PSZ Sname; // The current server name PCSZ Sname; // The current server name
}; // end of class SIDBLK }; // end of class SIDBLK
#endif // __COLBLK__H #endif // __COLBLK__H
This diff is collapsed.
...@@ -49,8 +49,8 @@ class DllExport CSORT { ...@@ -49,8 +49,8 @@ class DllExport CSORT {
public: public:
// Methods // Methods
int Qsort(PGLOBAL g, int n); /* Sort calling routine */ int Qsort(PGLOBAL g, int n); /* Sort calling routine */
//virtual void Print(PGLOBAL g, FILE *f, uint n); //virtual void Printf(PGLOBAL g, FILE *f, uint n);
//virtual void Print(PGLOBAL g, char *ps, uint z); //virtual void Prints(PGLOBAL g, char *ps, uint z);
#ifdef DEBTRACE #ifdef DEBTRACE
int GetNcmp(void) {return num_comp;} int GetNcmp(void) {return num_comp;}
#endif #endif
......
...@@ -63,7 +63,9 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all) ...@@ -63,7 +63,9 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all)
xp->Docp->Release(); xp->Docp->Release();
} catch(_com_error e) { } catch(_com_error e) {
sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description()); char *p = _com_util::ConvertBSTRToString(e.Description());
sprintf(g->Message, "%s %s", MSG(COM_ERROR), p);
delete[] p;
} catch(...) {} } catch(...) {}
CoUninitialize(); CoUninitialize();
...@@ -89,7 +91,7 @@ DOMDOC::DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp) ...@@ -89,7 +91,7 @@ DOMDOC::DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
/******************************************************************/ /******************************************************************/
/* Initialize XML parser and check library compatibility. */ /* Initialize XML parser and check library compatibility. */
/******************************************************************/ /******************************************************************/
bool DOMDOC::Initialize(PGLOBAL g, char *entry, bool zipped) bool DOMDOC::Initialize(PGLOBAL g, PCSZ entry, bool zipped)
{ {
if (zipped && InitZip(g, entry)) if (zipped && InitZip(g, entry))
return true; return true;
...@@ -155,7 +157,7 @@ PFBLOCK DOMDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn) ...@@ -155,7 +157,7 @@ PFBLOCK DOMDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn)
/******************************************************************/ /******************************************************************/
/* Create the XML node. */ /* Create the XML node. */
/******************************************************************/ /******************************************************************/
bool DOMDOC::NewDoc(PGLOBAL g, char *ver) bool DOMDOC::NewDoc(PGLOBAL g, PCSZ ver)
{ {
char buf[64]; char buf[64];
MSXML2::IXMLDOMProcessingInstructionPtr pip; MSXML2::IXMLDOMProcessingInstructionPtr pip;
...@@ -490,9 +492,9 @@ PXATTR DOMNODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap) ...@@ -490,9 +492,9 @@ PXATTR DOMNODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap)
/******************************************************************/ /******************************************************************/
/* Add a new element child node to this node and return it. */ /* Add a new element child node to this node and return it. */
/******************************************************************/ /******************************************************************/
PXNODE DOMNODE::AddChildNode(PGLOBAL g, char *name, PXNODE np) PXNODE DOMNODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
{ {
char *p, *pn; const char *p, *pn;
// char *p, *pn, *epf, *pf = NULL; // char *p, *pn, *epf, *pf = NULL;
MSXML2::IXMLDOMNodePtr ep; MSXML2::IXMLDOMNodePtr ep;
// _bstr_t uri((wchar_t*)NULL); // _bstr_t uri((wchar_t*)NULL);
...@@ -585,7 +587,7 @@ PXATTR DOMNODE::AddProperty(PGLOBAL g, char *name, PXATTR ap) ...@@ -585,7 +587,7 @@ PXATTR DOMNODE::AddProperty(PGLOBAL g, char *name, PXATTR ap)
/******************************************************************/ /******************************************************************/
/* Add a new text node to this node. */ /* Add a new text node to this node. */
/******************************************************************/ /******************************************************************/
void DOMNODE::AddText(PGLOBAL g, char *txtp) void DOMNODE::AddText(PGLOBAL g, PCSZ txtp)
{ {
MSXML2::IXMLDOMTextPtr tp= Docp->createTextNode((_bstr_t)txtp); MSXML2::IXMLDOMTextPtr tp= Docp->createTextNode((_bstr_t)txtp);
......
...@@ -37,9 +37,9 @@ class DOMDOC : public XMLDOCUMENT { ...@@ -37,9 +37,9 @@ class DOMDOC : public XMLDOCUMENT {
virtual void SetNofree(bool b) {} // Only libxml2 virtual void SetNofree(bool b) {} // Only libxml2
// Methods // Methods
virtual bool Initialize(PGLOBAL g, char *entry, bool zipped); virtual bool Initialize(PGLOBAL g, PCSZ entry, bool zipped);
virtual bool ParseFile(PGLOBAL g, char *fn); virtual bool ParseFile(PGLOBAL g, char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver); virtual bool NewDoc(PGLOBAL g, PCSZ ver);
virtual void AddComment(PGLOBAL g, char *com); virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g); virtual PXNODE GetRoot(PGLOBAL g);
virtual PXNODE NewRoot(PGLOBAL g, char *name); virtual PXNODE NewRoot(PGLOBAL g, char *name);
...@@ -78,9 +78,9 @@ class DOMNODE : public XMLNODE { ...@@ -78,9 +78,9 @@ class DOMNODE : public XMLNODE {
virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp); virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np); virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap); virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np); virtual PXNODE AddChildNode(PGLOBAL g, PCSZ name, PXNODE np);
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap); virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
virtual void AddText(PGLOBAL g, char *txtp); virtual void AddText(PGLOBAL g, PCSZ txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp); virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected: protected:
......
...@@ -301,9 +301,8 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header) ...@@ -301,9 +301,8 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header)
PDBUSER dup = (PDBUSER)g->Activityp->Aptr; PDBUSER dup = (PDBUSER)g->Activityp->Aptr;
// Skip this record // Skip this record
while (*Mempos++ != '\n') ; // What about Unix ??? while (*Mempos++ != '\n') // What about Unix ???
if (Mempos == Top)
if (Mempos >= Top)
return RC_EF; return RC_EF;
// Update progress information // Update progress information
...@@ -320,7 +319,7 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header) ...@@ -320,7 +319,7 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/ /***********************************************************************/
int MAPFAM::ReadBuffer(PGLOBAL g) int MAPFAM::ReadBuffer(PGLOBAL g)
{ {
int rc, len; int rc, len, n = 1;
// Are we at the end of the memory // Are we at the end of the memory
if (Mempos >= Top) { if (Mempos >= Top) {
...@@ -362,10 +361,14 @@ int MAPFAM::ReadBuffer(PGLOBAL g) ...@@ -362,10 +361,14 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
Placed = false; Placed = false;
// Immediately calculate next position (Used by DeleteDB) // Immediately calculate next position (Used by DeleteDB)
while (*Mempos++ != '\n') ; // What about Unix ??? while (*Mempos++ != '\n') // What about Unix ???
if (Mempos == Top) {
n = 0;
break;
} // endif Mempos
// Set caller line buffer // Set caller line buffer
len = (Mempos - Fpos) - 1; len = (Mempos - Fpos) - n;
// Don't rely on ENDING setting // Don't rely on ENDING setting
if (len > 0 && *(Mempos - 2) == '\r') if (len > 0 && *(Mempos - 2) == '\r')
...@@ -619,7 +622,9 @@ int MBKFAM::ReadBuffer(PGLOBAL g) ...@@ -619,7 +622,9 @@ int MBKFAM::ReadBuffer(PGLOBAL g)
} // endif's } // endif's
// Immediately calculate next position (Used by DeleteDB) // Immediately calculate next position (Used by DeleteDB)
while (*Mempos++ != '\n') ; // What about Unix ??? while (*Mempos++ != '\n') // What about Unix ???
if (Mempos == Top)
break;
// Set caller line buffer // Set caller line buffer
len = (Mempos - Fpos) - Ending; len = (Mempos - Fpos) - Ending;
......
...@@ -128,7 +128,7 @@ typedef struct _descriptor { ...@@ -128,7 +128,7 @@ typedef struct _descriptor {
/* Moves file pointer to byte 32; fills buffer at buf with */ /* Moves file pointer to byte 32; fills buffer at buf with */
/* first 32 bytes of file. */ /* first 32 bytes of file. */
/****************************************************************************/ /****************************************************************************/
static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf) static int dbfhead(PGLOBAL g, FILE *file, PCSZ fn, DBFHEADER *buf)
{ {
char endmark[2]; char endmark[2];
int dbc = 2, rc = RC_OK; int dbc = 2, rc = RC_OK;
...@@ -186,7 +186,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf) ...@@ -186,7 +186,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
/* DBFColumns: constructs the result blocks containing the description */ /* DBFColumns: constructs the result blocks containing the description */
/* of all the columns of a DBF file that will be retrieved by #GetData. */ /* of all the columns of a DBF file that will be retrieved by #GetData. */
/****************************************************************************/ /****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info) PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info)
{ {
int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT}; TYPE_INT, TYPE_INT, TYPE_SHORT};
...@@ -393,7 +393,7 @@ DBFBASE::DBFBASE(DBFBASE *txfp) ...@@ -393,7 +393,7 @@ DBFBASE::DBFBASE(DBFBASE *txfp)
/* and header length. Set Records, check that Reclen is equal to lrecl and */ /* and header length. Set Records, check that Reclen is equal to lrecl and */
/* return the header length or 0 in case of error. */ /* return the header length or 0 in case of error. */
/****************************************************************************/ /****************************************************************************/
int DBFBASE::ScanHeader(PGLOBAL g, PSZ fn, int lrecl, int *rln, char *defpath) int DBFBASE::ScanHeader(PGLOBAL g, PCSZ fn, int lrecl, int *rln, PCSZ defpath)
{ {
int rc; int rc;
char filename[_MAX_PATH]; char filename[_MAX_PATH];
...@@ -694,7 +694,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) ...@@ -694,7 +694,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
} // endif Headlen } // endif Headlen
/**************************************************************************/ /**************************************************************************/
/* Position the file at the beginning of the data. */ /* Position the file at the begining of the data. */
/**************************************************************************/ /**************************************************************************/
if (Tdbp->GetMode() == MODE_INSERT) if (Tdbp->GetMode() == MODE_INSERT)
rc = fseek(Stream, 0, SEEK_END); rc = fseek(Stream, 0, SEEK_END);
...@@ -1034,7 +1034,7 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g) ...@@ -1034,7 +1034,7 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
} // endif Headlen } // endif Headlen
/**************************************************************************/ /**************************************************************************/
/* Position the file at the beginning of the data. */ /* Position the file at the begining of the data. */
/**************************************************************************/ /**************************************************************************/
Fpos = Mempos = Memory + Headlen; Fpos = Mempos = Memory + Headlen;
Top--; // Because of EOF marker Top--; // Because of EOF marker
......
...@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM; ...@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM;
/****************************************************************************/ /****************************************************************************/
/* Functions used externally. */ /* Functions used externally. */
/****************************************************************************/ /****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info); PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info);
/****************************************************************************/ /****************************************************************************/
/* This is the base class for dBASE file access methods. */ /* This is the base class for dBASE file access methods. */
...@@ -31,7 +31,7 @@ class DllExport DBFBASE { ...@@ -31,7 +31,7 @@ class DllExport DBFBASE {
DBFBASE(PDBF txfp); DBFBASE(PDBF txfp);
// Implementation // Implementation
int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, int *rlen, char *defpath); int ScanHeader(PGLOBAL g, PCSZ fname, int lrecl, int *rlen, PCSZ defpath);
protected: protected:
// Default constructor, not to be used // Default constructor, not to be used
......
...@@ -761,7 +761,8 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) ...@@ -761,7 +761,8 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw); htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
if (!brc || nbw != len) { if (!brc || nbw != len) {
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile"; char buf[256];
PCSZ fn = (h == Hfile) ? To_File : "Tempfile";
if (brc) if (brc)
strcpy(buf, MSG(BAD_BYTE_NUM)); strcpy(buf, MSG(BAD_BYTE_NUM));
......
...@@ -920,7 +920,7 @@ int ZLBFAM::GetFileLength(PGLOBAL g) ...@@ -920,7 +920,7 @@ int ZLBFAM::GetFileLength(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool ZLBFAM::AllocateBuffer(PGLOBAL g) bool ZLBFAM::AllocateBuffer(PGLOBAL g)
{ {
char *msg; PCSZ msg;
int n, zrc; int n, zrc;
#if 0 #if 0
......
/*********** File AM Txt C++ Program Source Code File (.CPP) ***********/ /*********** File AM Txt C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMTXT */ /* PROGRAM NAME: FILAMTXT */
/* ------------- */ /* ------------- */
/* Version 1.6 */ /* Version 1.7 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -71,8 +71,23 @@ TXTFAM::TXTFAM(PDOSDEF tdp) ...@@ -71,8 +71,23 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
{ {
Tdbp = NULL; Tdbp = NULL;
To_Fb = NULL; To_Fb = NULL;
if (tdp) {
To_File = tdp->Fn; To_File = tdp->Fn;
Lrecl = tdp->Lrecl; Lrecl = tdp->Lrecl;
Eof = tdp->Eof;
Ending = tdp->Ending;
} else {
To_File = NULL;
Lrecl = 0;
Eof = false;
#if defined(__WIN__)
Ending = 2;
#else
Ending = 1;
#endif
} // endif tdp
Placed = false; Placed = false;
IsRead = true; IsRead = true;
Blocked = false; Blocked = false;
...@@ -103,8 +118,6 @@ TXTFAM::TXTFAM(PDOSDEF tdp) ...@@ -103,8 +118,6 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
Blksize = 0; Blksize = 0;
Fpos = Spos = Tpos = 0; Fpos = Spos = Tpos = 0;
Padded = false; Padded = false;
Eof = tdp->Eof;
Ending = tdp->Ending;
Abort = false; Abort = false;
CrLf = (char*)(Ending == 1 ? "\n" : "\r\n"); CrLf = (char*)(Ending == 1 ? "\n" : "\r\n");
} // end of TXTFAM standard constructor } // end of TXTFAM standard constructor
...@@ -1161,12 +1174,12 @@ int DOSFAM::RenameTempFile(PGLOBAL g) ...@@ -1161,12 +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));
longjmp(g->jumper[g->jump_level], 51); throw 51;
} 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
longjmp(g->jumper[g->jump_level], 52); throw 52;
} 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));
......
...@@ -80,7 +80,7 @@ class DllExport TXTFAM : public BLOCK { ...@@ -80,7 +80,7 @@ class DllExport TXTFAM : public BLOCK {
protected: protected:
// Members // Members
PTDBDOS Tdbp; // To table class PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name PCSZ To_File; // Points to table file name
PFBLOCK To_Fb; // Pointer to file block PFBLOCK To_Fb; // Pointer to file block
PPARM To_Pos; // Pointer to position list PPARM To_Pos; // Pointer to position list
PPARM To_Sos; // Pointer to start position list PPARM To_Sos; // Pointer to start position list
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -144,7 +144,7 @@ int VCTFAM::GetFileLength(PGLOBAL g) ...@@ -144,7 +144,7 @@ int VCTFAM::GetFileLength(PGLOBAL g)
if (Split) { if (Split) {
// Get the total file length // Get the total file length
char filename[_MAX_PATH]; char filename[_MAX_PATH];
char *savfile = To_File; PCSZ savfile = To_File;
int i, len = 0; int i, len = 0;
// Initialize the array of file structures // Initialize the array of file structures
...@@ -313,7 +313,7 @@ int VCTFAM::Cardinality(PGLOBAL g) ...@@ -313,7 +313,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
// and Last must be set from the file cardinality. // and Last must be set from the file cardinality.
// Only happens when called by sub classes. // Only happens when called by sub classes.
char filename[_MAX_PATH]; char filename[_MAX_PATH];
PSZ savfn = To_File; PCSZ savfn = To_File;
int len, clen, card = -1; int len, clen, card = -1;
PCOLDEF cdp = Tdbp->GetDef()->GetCols(); PCOLDEF cdp = Tdbp->GetDef()->GetCols();
...@@ -368,7 +368,7 @@ int VCTFAM::GetRowID(void) ...@@ -368,7 +368,7 @@ int VCTFAM::GetRowID(void)
/***********************************************************************/ /***********************************************************************/
/* VCT Create an empty file for Vector formatted tables. */ /* VCT Create an empty file for Vector formatted tables. */
/***********************************************************************/ /***********************************************************************/
bool VCTFAM::MakeEmptyFile(PGLOBAL g, char *fn) bool VCTFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
{ {
// Vector formatted file: this will create an empty file of the // Vector formatted file: this will create an empty file of the
// required length if it does not exists yet. // required length if it does not exists yet.
...@@ -559,41 +559,42 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g) ...@@ -559,41 +559,42 @@ 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;
// We come here in MODE_INSERT only // We come here in MODE_INSERT only
if (Last == Nrec) { if (Last == Nrec) {
CurBlk = Block; CurBlk = Block;
CurNum = 0; CurNum = 0;
AddBlock = !MaxBlk; AddBlock = !MaxBlk;
} else { } else {
int rc;
PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns(); PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
// The starting point must be at the end of file as for append. // The starting point must be at the end of file as for append.
CurBlk = Block - 1; CurBlk = Block - 1;
CurNum = Last; CurNum = Last;
// Prepare error return try {
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
// Last block must be updated by new values // Last block must be updated by new values
for (; cp; cp = (PVCTCOL)cp->Next) for (; cp; cp = (PVCTCOL)cp->Next)
cp->ReadBlock(g); cp->ReadBlock(g);
g->jump_level--; } catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
rc = true;
} catch (const char *msg) {
strcpy(g->Message, msg);
rc = true;
} // end catch
} // endif Last } // endif Last
if (!rc)
// We are not currently using a temporary file for Insert // We are not currently using a temporary file for Insert
T_Stream = Stream; T_Stream = Stream;
return false;
return rc;
} // end of InitInsert } // end of InitInsert
/***********************************************************************/ /***********************************************************************/
...@@ -878,7 +879,8 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -878,7 +879,8 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
bool VCTFAM::OpenTempFile(PGLOBAL g) bool VCTFAM::OpenTempFile(PGLOBAL g)
{ {
char *opmode, tempname[_MAX_PATH]; PCSZ opmode;
char tempname[_MAX_PATH];
bool rc = false; bool rc = false;
/*********************************************************************/ /*********************************************************************/
...@@ -1107,7 +1109,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort) ...@@ -1107,7 +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);
longjmp(g->jumper[g->jump_level], 44); throw 44;
} // endif } // endif
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {
...@@ -1527,8 +1529,8 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g) ...@@ -1527,8 +1529,8 @@ 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)
{ {
int rc; bool rc = false;
volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns(); volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
// We come here in MODE_INSERT only // We come here in MODE_INSERT only
...@@ -1542,24 +1544,22 @@ bool VCMFAM::InitInsert(PGLOBAL g) ...@@ -1542,24 +1544,22 @@ bool VCMFAM::InitInsert(PGLOBAL g)
CurNum = Last; CurNum = Last;
} // endif Last } // endif Last
// Prepare error return try {
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
// Initialize the column block pointer // Initialize the column block pointer
for (; cp; cp = (PVCTCOL)cp->Next) for (; cp; cp = (PVCTCOL)cp->Next)
cp->ReadBlock(g); cp->ReadBlock(g);
g->jump_level--; } catch (int n) {
return false; if (trace)
} // end of InitInsert htrc("Exception %d: %s\n", n, g->Message);
rc = true;
} catch (const char *msg) {
strcpy(g->Message, msg);
rc = true;
} // end catch
return rc;
} // end of InitInsert
/***********************************************************************/ /***********************************************************************/
/* Data Base write routine for VMP access method. */ /* Data Base write routine for VMP access method. */
...@@ -1998,7 +1998,7 @@ bool VECFAM::OpenTableFile(PGLOBAL g) ...@@ -1998,7 +1998,7 @@ bool VECFAM::OpenTableFile(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Open the file corresponding to one column. */ /* Open the file corresponding to one column. */
/***********************************************************************/ /***********************************************************************/
bool VECFAM::OpenColumnFile(PGLOBAL g, char *opmode, int i) bool VECFAM::OpenColumnFile(PGLOBAL g, PCSZ opmode, int i)
{ {
char filename[_MAX_PATH]; char filename[_MAX_PATH];
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
...@@ -2503,7 +2503,7 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort) ...@@ -2503,7 +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
longjmp(g->jumper[g->jump_level], 44); throw 44;
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {
if (UseTemp && !InitUpdate && !Abort) { if (UseTemp && !InitUpdate && !Abort) {
...@@ -3143,7 +3143,8 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) ...@@ -3143,7 +3143,8 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw); htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
if (!brc || nbw != len) { if (!brc || nbw != len) {
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile"; char buf[256];
PCSZ fn = (h == Hfile) ? To_File : "Tempfile";
if (brc) if (brc)
strcpy(buf, MSG(BAD_BYTE_NUM)); strcpy(buf, MSG(BAD_BYTE_NUM));
...@@ -3319,7 +3320,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g) ...@@ -3319,7 +3320,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* VEC Create an empty file for new Vector formatted tables. */ /* VEC Create an empty file for new Vector formatted tables. */
/***********************************************************************/ /***********************************************************************/
bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
{ {
// Vector formatted file this will create an empty file of the // Vector formatted file this will create an empty file of the
// required length if it does not exists yet. // required length if it does not exists yet.
...@@ -3329,7 +3330,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) ...@@ -3329,7 +3330,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
PlugSetPath(filename, fn, Tdbp->GetPath()); PlugSetPath(filename, fn, Tdbp->GetPath());
#if defined(__WIN__) #if defined(__WIN__)
char *p; PCSZ p;
DWORD rc; DWORD rc;
bool brc; bool brc;
LARGE_INTEGER of; LARGE_INTEGER of;
...@@ -4164,7 +4165,7 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort) ...@@ -4164,7 +4165,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);
longjmp(g->jumper[g->jump_level], 44); throw 44;
} // endif } // endif
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {
......
...@@ -61,7 +61,7 @@ class DllExport VCTFAM : public FIXFAM { ...@@ -61,7 +61,7 @@ class DllExport VCTFAM : public FIXFAM {
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected: protected:
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); virtual bool MakeEmptyFile(PGLOBAL g, PCSZ fn);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g) {return false;} virtual bool MoveLines(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
...@@ -160,7 +160,7 @@ class DllExport VECFAM : public VCTFAM { ...@@ -160,7 +160,7 @@ class DllExport VECFAM : public VCTFAM {
virtual bool MoveLines(PGLOBAL g); virtual bool MoveLines(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual int RenameTempFile(PGLOBAL g); virtual int RenameTempFile(PGLOBAL g);
bool OpenColumnFile(PGLOBAL g, char *opmode, int i); bool OpenColumnFile(PGLOBAL g, PCSZ opmode, int i);
// Members // Members
FILE* *Streams; // Points to Dos file structure array FILE* *Streams; // Points to Dos file structure array
...@@ -235,7 +235,7 @@ class BGVFAM : public VCTFAM { ...@@ -235,7 +235,7 @@ class BGVFAM : public VCTFAM {
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false); bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false);
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); virtual bool MakeEmptyFile(PGLOBAL g, PCSZ fn);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g); virtual bool CleanUnusedSpace(PGLOBAL g);
......
This diff is collapsed.
/************** filamzip H Declares Source Code File (.H) **************/ /************** filamzip H Declares Source Code File (.H) **************/
/* Name: filamzip.h Version 1.1 */ /* Name: filamzip.h Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2016-2017 */
/* */ /* */
...@@ -27,16 +27,13 @@ typedef class ZPXFAM *PZPXFAM; ...@@ -27,16 +27,13 @@ typedef class ZPXFAM *PZPXFAM;
class DllExport ZIPUTIL : public BLOCK { class DllExport ZIPUTIL : public BLOCK {
public: public:
// Constructor // Constructor
ZIPUTIL(PSZ tgt); ZIPUTIL(PCSZ tgt);
//ZIPUTIL(ZIPUTIL *zutp); //ZIPUTIL(ZIPUTIL *zutp);
// Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
// Methods // Methods
bool OpenTable(PGLOBAL g, MODE mode, char *fn, bool append); bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn, bool append);
bool open(PGLOBAL g, char *fn, bool append); bool open(PGLOBAL g, PCSZ fn, bool append);
bool addEntry(PGLOBAL g, char *entry); bool addEntry(PGLOBAL g, PCSZ entry);
void close(void); void close(void);
void closeEntry(void); void closeEntry(void);
int writeEntry(PGLOBAL g, char *buf, int len); int writeEntry(PGLOBAL g, char *buf, int len);
...@@ -44,15 +41,10 @@ class DllExport ZIPUTIL : public BLOCK { ...@@ -44,15 +41,10 @@ class DllExport ZIPUTIL : public BLOCK {
// Members // Members
zipFile zipfile; // The ZIP container file zipFile zipfile; // The ZIP container file
PSZ target; // The target file name PCSZ target; // The target file name
//unz_file_info finfo; // The current file info PCSZ pwd; // The ZIP file password
PFBLOCK fp; PFBLOCK fp;
//char *memory;
//uint size;
//int multiple; // Multiple targets
bool entryopen; // True when open current entry bool entryopen; // True when open current entry
//char fn[FILENAME_MAX]; // The current entry file name
//char mapCaseTable[256];
}; // end of ZIPUTIL }; // end of ZIPUTIL
/***********************************************************************/ /***********************************************************************/
...@@ -61,25 +53,27 @@ class DllExport ZIPUTIL : public BLOCK { ...@@ -61,25 +53,27 @@ class DllExport ZIPUTIL : public BLOCK {
class DllExport UNZIPUTL : public BLOCK { class DllExport UNZIPUTL : public BLOCK {
public: public:
// Constructor // Constructor
UNZIPUTL(PSZ tgt, bool mul); UNZIPUTL(PCSZ tgt, bool mul);
//UNZIPUTL(UNZIPUTL *zutp); UNZIPUTL(PDOSDEF tdp);
// Implementation // Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); } //PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
// Methods // Methods
bool OpenTable(PGLOBAL g, MODE mode, char *fn); bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn);
bool open(PGLOBAL g, char *fn); bool open(PGLOBAL g, PCSZ fn);
bool openEntry(PGLOBAL g); bool openEntry(PGLOBAL g);
void close(void); void close(void);
void closeEntry(void); void closeEntry(void);
bool WildMatch(PSZ pat, PSZ str); bool WildMatch(PCSZ pat, PCSZ str);
int findEntry(PGLOBAL g, bool next); int findEntry(PGLOBAL g, bool next);
int nextEntry(PGLOBAL g); int nextEntry(PGLOBAL g);
bool IsInsertOk(PGLOBAL g, PCSZ fn);
// Members // Members
unzFile zipfile; // The ZIP container file unzFile zipfile; // The ZIP container file
PSZ target; // The target file name PCSZ target; // The target file name
PCSZ pwd; // The ZIP file password
unz_file_info finfo; // The current file info unz_file_info finfo; // The current file info
PFBLOCK fp; PFBLOCK fp;
char *memory; char *memory;
...@@ -119,8 +113,7 @@ class DllExport UNZFAM : public MAPFAM { ...@@ -119,8 +113,7 @@ class DllExport UNZFAM : public MAPFAM {
protected: protected:
// Members // Members
UNZIPUTL *zutp; UNZIPUTL *zutp;
PSZ target; PDOSDEF tdfp;
bool mul;
}; // end of UNZFAM }; // end of UNZFAM
/***********************************************************************/ /***********************************************************************/
...@@ -147,8 +140,7 @@ class DllExport UZXFAM : public MPXFAM { ...@@ -147,8 +140,7 @@ class DllExport UZXFAM : public MPXFAM {
protected: protected:
// Members // Members
UNZIPUTL *zutp; UNZIPUTL *zutp;
PSZ target; PDOSDEF tdfp;
bool mul;
}; // end of UZXFAM }; // end of UZXFAM
/***********************************************************************/ /***********************************************************************/
...@@ -175,8 +167,9 @@ class DllExport ZIPFAM : public DOSFAM { ...@@ -175,8 +167,9 @@ class DllExport ZIPFAM : public DOSFAM {
protected: protected:
// Members // Members
ZIPUTIL *zutp; ZIPUTIL *zutp;
PSZ target; PCSZ target;
bool append; bool append;
//bool replace;
}; // end of ZIPFAM }; // end of ZIPFAM
/***********************************************************************/ /***********************************************************************/
...@@ -200,7 +193,7 @@ class DllExport ZPXFAM : public FIXFAM { ...@@ -200,7 +193,7 @@ class DllExport ZPXFAM : public FIXFAM {
protected: protected:
// Members // Members
ZIPUTIL *zutp; ZIPUTIL *zutp;
PSZ target; PCSZ target;
bool append; bool append;
}; // end of ZPXFAM }; // end of ZPXFAM
......
/***************** Filter C++ Class Filter Code (.CPP) *****************/ /***************** Filter C++ Class Filter Code (.CPP) *****************/
/* Name: FILTER.CPP Version 3.9 */ /* Name: FILTER.CPP Version 4.0 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
/* */ /* */
/* This file contains the class FILTER function code. */ /* This file contains the class FILTER function code. */
/***********************************************************************/ /***********************************************************************/
...@@ -38,6 +38,13 @@ ...@@ -38,6 +38,13 @@
//#include "token.h" //#include "token.h"
//#include "select.h" //#include "select.h"
#include "xindex.h" #include "xindex.h"
#if defined(MONGO_SUPPORT)
#include "filamtxt.h"
#include "tabdos.h"
#include "tabjson.h"
#include "tabext.h"
#include "tabmgo.h"
#endif // MONGO_SUPPORT
/***********************************************************************/ /***********************************************************************/
/* Utility routines. */ /* Utility routines. */
...@@ -87,7 +94,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc) ...@@ -87,7 +94,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);
longjmp(g->jumper[g->jump_level], TYPE_ARRAY); throw TYPE_ARRAY;
} // endswitch opc } // endswitch opc
return bt; return bt;
...@@ -1405,10 +1412,98 @@ PFIL FILTER::Copy(PTABS t) ...@@ -1405,10 +1412,98 @@ PFIL FILTER::Copy(PTABS t)
} // end of Copy } // end of Copy
#endif // 0 #endif // 0
/***********************************************************************/
/* Make selector json representation for Mongo tables. */
/***********************************************************************/
#if defined(MONGO_SUPPORT)
bool FILTER::MakeSelector(PGLOBAL g, PSTRG s, bool m)
{
s->Append('{');
if (Opc == OP_AND || Opc == OP_OR) {
if (GetArgType(0) != TYPE_FILTER || GetArgType(1) != TYPE_FILTER)
return true;
s->Append("\"$");
s->Append(Opc == OP_AND ? "and" : "or");
s->Append("\":[");
if (((PFIL)Arg(0))->MakeSelector(g, s, m))
return true;
s->Append(',');
if (((PFIL)Arg(1))->MakeSelector(g, s, m))
return true;
s->Append(']');
} else {
char *pth, buf[501];
if (GetArgType(0) != TYPE_COLBLK)
return true;
s->Append('"');
if (m)
pth = ((PMGOCOL)Arg(0))->Jpath;
else if (!(pth = ((PJCOL)Arg(0))->GetJpath(g, false)))
return true;
s->Append(pth);
s->Append("\":{\"$");
switch (Opc) {
case OP_EQ:
s->Append("eq");
break;
case OP_NE:
s->Append("ne");
break;
case OP_GT:
s->Append("gt");
break;
case OP_GE:
s->Append("gte");
break;
case OP_LT:
s->Append("lt");
break;
case OP_LE:
s->Append("lte");
break;
//case OP_NULL:
// s->Append("ne");
// break;
//case OP_LIKE:
// s->Append("ne");
// break;
//case OP_EXIST:
// s->Append("ne");
// break;
default:
return true;
} // endswitch Opc
s->Append("\":");
if (GetArgType(1) == TYPE_COLBLK)
return true;
Arg(1)->Prints(g, buf, 500);
s->Append(buf);
s->Append('}');
} // endif Opc
s->Append('}');
return false;
} // end of MakeSelector
#endif // MONGO_SUPPORT
/*********************************************************************/ /*********************************************************************/
/* Make file output of FILTER contents. */ /* Make file output of FILTER contents. */
/*********************************************************************/ /*********************************************************************/
void FILTER::Print(PGLOBAL g, FILE *f, uint n) void FILTER::Printf(PGLOBAL g, FILE *f, uint n)
{ {
char m[64]; char m[64];
...@@ -1430,18 +1525,18 @@ void FILTER::Print(PGLOBAL g, FILE *f, uint n) ...@@ -1430,18 +1525,18 @@ void FILTER::Print(PGLOBAL g, FILE *f, uint n)
if (lin && fp->GetArgType(i) == TYPE_FILTER) if (lin && fp->GetArgType(i) == TYPE_FILTER)
fprintf(f, "%s Filter at %p\n", m, fp->Arg(i)); fprintf(f, "%s Filter at %p\n", m, fp->Arg(i));
else else
fp->Arg(i)->Print(g, f, n + 2); fp->Arg(i)->Printf(g, f, n + 2);
} // endfor i } // endfor i
} // endfor fp } // endfor fp
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of TABLE contents (z should be checked). */ /* Make string output of TABLE contents (z should be checked). */
/***********************************************************************/ /***********************************************************************/
void FILTER::Print(PGLOBAL g, char *ps, uint z) void FILTER::Prints(PGLOBAL g, char *ps, uint z)
{ {
#define FLEN 100 #define FLEN 100
...@@ -1469,7 +1564,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z) ...@@ -1469,7 +1564,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
bcp = bxp; bcp = bxp;
p = bcp->Cold; p = bcp->Cold;
n = FLEN; n = FLEN;
fp->Arg(0)->Print(g, p, n); fp->Arg(0)->Prints(g, p, n);
n = FLEN - strlen(p); n = FLEN - strlen(p);
switch (fp->Opc) { switch (fp->Opc) {
...@@ -1515,7 +1610,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z) ...@@ -1515,7 +1610,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
n = FLEN - strlen(p); n = FLEN - strlen(p);
p += strlen(p); p += strlen(p);
fp->Arg(1)->Print(g, p, n); fp->Arg(1)->Prints(g, p, n);
} else } else
if (!bcp) { if (!bcp) {
strncat(ps, "???", z); strncat(ps, "???", z);
...@@ -1578,7 +1673,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z) ...@@ -1578,7 +1673,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
bcp = bxp; bcp = bxp;
} while (bcp); // enddo } while (bcp); // enddo
} // end of Print } // end of Prints
/* -------------------- Derived Classes Functions -------------------- */ /* -------------------- Derived Classes Functions -------------------- */
...@@ -1696,8 +1791,6 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having) ...@@ -1696,8 +1791,6 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
if (trace) if (trace)
htrc("PrepareFilter: fp=%p having=%d\n", fp, having); htrc("PrepareFilter: fp=%p having=%d\n", fp, having);
//if (fp)
// fp->Print(g, debug, 0);
while (fp) { while (fp) {
if (fp->Opc == OP_SEP) if (fp->Opc == OP_SEP)
...@@ -1711,7 +1804,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having) ...@@ -1711,7 +1804,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))
// longjmp(g->jumper[g->jump_level], TYPE_FILTER); // throw TYPE_ARRAY;
filp = fp; filp = fp;
fp = fp->Next; fp = fp->Next;
...@@ -1744,7 +1837,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp) ...@@ -1744,7 +1837,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
// return TRUE; // return TRUE;
if (filp->Eval(g)) if (filp->Eval(g))
longjmp(g->jumper[g->jump_level], TYPE_FILTER); throw TYPE_FILTER;
if (trace > 1) if (trace > 1)
htrc("PlugFilter filp=%p result=%d\n", htrc("PlugFilter filp=%p result=%d\n",
......
...@@ -61,8 +61,11 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */ ...@@ -61,8 +61,11 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */
//virtual PXOB CheckSubQuery(PGLOBAL, PSQL); //virtual PXOB CheckSubQuery(PGLOBAL, PSQL);
//virtual bool CheckLocal(PTDB); //virtual bool CheckLocal(PTDB);
//virtual int CheckSpcCol(PTDB tdbp, int n); //virtual int CheckSpcCol(PTDB tdbp, int n);
virtual void Print(PGLOBAL g, FILE *f, uint n); #if defined(MONGO_SUPPORT)
virtual void Print(PGLOBAL g, char *ps, uint z); bool MakeSelector(PGLOBAL g, PSTRG s, bool m);
#endif // MONGO_SUPPORT
virtual void Printf(PGLOBAL g, FILE *f, uint n);
virtual void Prints(PGLOBAL g, char *ps, uint z);
// PFIL Linearize(bool nosep); // PFIL Linearize(bool nosep);
// PFIL Link(PGLOBAL g, PFIL fil2); // PFIL Link(PGLOBAL g, PFIL fil2);
// PFIL RemoveLastSep(void); // PFIL RemoveLastSep(void);
......
/***********************************************************************/ /***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */ /* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright Olivier Bertrand 1993-2014 */ /* (C) Copyright Olivier Bertrand 1993-2017 */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#define NO_IVAL -95684275 /* Used by GetIntegerOption */ #define NO_IVAL -95684275 /* Used by GetIntegerOption */
#define VMLANG 370 /* Size of olf VM lang blocks */ #define VMLANG 370 /* Size of olf VM lang blocks */
#define MAX_JUMP 24 /* Maximum jump level number */ #define MAX_JUMP 24 /* Maximum jump level number */
#define MAX_STR 1024 /* Maximum string length */ #define MAX_STR 4160 /* Maximum message length */
#define STR_SIZE 501 /* Length of char strings. */ #define STR_SIZE 501 /* Length of char strings. */
#define STD_INPUT 0 /* Standard language input */ #define STD_INPUT 0 /* Standard language input */
#define STD_OUTPUT 1 /* Standard language output */ #define STD_OUTPUT 1 /* Standard language output */
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
#define TYPE_BIGINT 5 #define TYPE_BIGINT 5
#define TYPE_LIST 6 #define TYPE_LIST 6
#define TYPE_INT 7 #define TYPE_INT 7
#define TYPE_DATE 8
#define TYPE_DECIM 9 #define TYPE_DECIM 9
#define TYPE_BIN 10 #define TYPE_BIN 10
#define TYPE_PCHAR 11 #define TYPE_PCHAR 11
...@@ -229,8 +230,9 @@ typedef struct _parm { ...@@ -229,8 +230,9 @@ typedef struct _parm {
typedef struct _global { /* Global structure */ typedef struct _global { /* Global structure */
void *Sarea; /* Points to work area */ void *Sarea; /* Points to work area */
uint Sarea_Size; /* Work area size */ uint Sarea_Size; /* Work area size */
PACTIVITY Activityp, ActivityStart; PACTIVITY Activityp;
char Message[MAX_STR]; char Message[MAX_STR];
ulong More; /* Used by jsonudf */
int Createas; /* To pass info to created table */ int Createas; /* To pass info to created table */
void *Xchk; /* indexes in create/alter */ void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */ short Alchecked; /* Checked for ALTER */
......
This diff is collapsed.
...@@ -61,7 +61,7 @@ class XCHK : public BLOCK { ...@@ -61,7 +61,7 @@ class XCHK : public BLOCK {
oldopn= newopn= NULL; oldopn= newopn= NULL;
oldpix= newpix= NULL;} oldpix= newpix= NULL;}
inline char *SetName(PGLOBAL g, char *name) {return PlugDup(g, name);} inline char *SetName(PGLOBAL g, PCSZ name) {return PlugDup(g, name);}
bool oldsep; // Sepindex before create/alter bool oldsep; // Sepindex before create/alter
bool newsep; // Sepindex after create/alter bool newsep; // Sepindex after create/alter
...@@ -168,18 +168,18 @@ class ha_connect: public handler ...@@ -168,18 +168,18 @@ class ha_connect: public handler
static bool connect_init(void); static bool connect_init(void);
static bool connect_end(void); static bool connect_end(void);
TABTYPE GetRealType(PTOS pos= NULL); TABTYPE GetRealType(PTOS pos= NULL);
char *GetRealString(const char *s); char *GetRealString(PCSZ s);
char *GetStringOption(char *opname, char *sdef= NULL); PCSZ GetStringOption(PCSZ opname, PCSZ sdef= NULL);
PTOS GetTableOptionStruct(TABLE_SHARE *s= NULL); PTOS GetTableOptionStruct(TABLE_SHARE *s= NULL);
bool GetBooleanOption(char *opname, bool bdef); bool GetBooleanOption(PCSZ opname, bool bdef);
bool SetBooleanOption(char *opname, bool b); bool SetBooleanOption(PCSZ opname, bool b);
int GetIntegerOption(char *opname); int GetIntegerOption(PCSZ opname);
bool GetIndexOption(KEY *kp, char *opname); bool GetIndexOption(KEY *kp, PCSZ opname);
bool CheckString(const char *str1, const char *str2); bool CheckString(PCSZ str1, PCSZ str2);
bool SameString(TABLE *tab, char *opn); bool SameString(TABLE *tab, PCSZ opn);
bool SetIntegerOption(char *opname, int n); bool SetIntegerOption(PCSZ opname, int n);
bool SameInt(TABLE *tab, char *opn); bool SameInt(TABLE *tab, PCSZ opn);
bool SameBool(TABLE *tab, char *opn); bool SameBool(TABLE *tab, PCSZ opn);
bool FileExists(const char *fn, bool bf); bool FileExists(const char *fn, bool bf);
bool NoFieldOptionChange(TABLE *tab); bool NoFieldOptionChange(TABLE *tab);
PFOS GetFieldOptionStruct(Field *fp); PFOS GetFieldOptionStruct(Field *fp);
...@@ -187,8 +187,8 @@ class ha_connect: public handler ...@@ -187,8 +187,8 @@ class ha_connect: public handler
PXOS GetIndexOptionStruct(KEY *kp); PXOS GetIndexOptionStruct(KEY *kp);
PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL); PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL);
bool CheckVirtualIndex(TABLE_SHARE *s); bool CheckVirtualIndex(TABLE_SHARE *s);
const char *GetDBName(const char *name); PCSZ GetDBName(PCSZ name);
const char *GetTableName(void); PCSZ GetTableName(void);
char *GetPartName(void); char *GetPartName(void);
//int GetColNameLen(Field *fp); //int GetColNameLen(Field *fp);
//char *GetColName(Field *fp); //char *GetColName(Field *fp);
...@@ -197,9 +197,9 @@ class ha_connect: public handler ...@@ -197,9 +197,9 @@ class ha_connect: public handler
bool IsSameIndex(PIXDEF xp1, PIXDEF xp2); bool IsSameIndex(PIXDEF xp1, PIXDEF xp2);
bool IsPartitioned(void); bool IsPartitioned(void);
bool IsUnique(uint n); bool IsUnique(uint n);
char *GetDataPath(void) {return (char*)datapath;} PCSZ GetDataPath(void) {return datapath;}
void SetDataPath(PGLOBAL g, const char *path); bool SetDataPath(PGLOBAL g, PCSZ path);
PTDB GetTDB(PGLOBAL g); PTDB GetTDB(PGLOBAL g);
int OpenTable(PGLOBAL g, bool del= false); int OpenTable(PGLOBAL g, bool del= false);
bool CheckColumnList(PGLOBAL g); bool CheckColumnList(PGLOBAL g);
...@@ -513,7 +513,7 @@ int index_prev(uchar *buf); ...@@ -513,7 +513,7 @@ int index_prev(uchar *buf);
ulong hnum; // The number of this handler ulong hnum; // The number of this handler
query_id_t valid_query_id; // The one when tdbp was allocated query_id_t valid_query_id; // The one when tdbp was allocated
query_id_t creat_query_id; // The one when handler was allocated query_id_t creat_query_id; // The one when handler was allocated
char *datapath; // Is the Path of DB data directory PCSZ datapath; // Is the Path of DB data directory
PTDB tdbp; // To table class object PTDB tdbp; // To table class object
PVAL sdvalin1; // Used to convert date values PVAL sdvalin1; // Used to convert date values
PVAL sdvalin2; // Used to convert date values PVAL sdvalin2; // Used to convert date values
......
...@@ -193,7 +193,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section ) ...@@ -193,7 +193,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section )
} }
for (key = section->key; key; key = key->next) for (key = section->key; key; key = key->next)
if (key->name[0]) { if (key->name && key->name[0]) {
fprintf(file, "%s", SVP(key->name)); fprintf(file, "%s", SVP(key->name));
if (key->value) if (key->value)
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
typedef struct jdbc_parms { typedef struct jdbc_parms {
int CheckSize(int rows); int CheckSize(int rows);
char *Driver; // JDBC driver PCSZ Driver; // JDBC driver
char *Url; // Driver URL PCSZ Url; // Driver URL
char *User; // User connect info PCSZ User; // User connect info
char *Pwd; // Password connect info PCSZ Pwd; // Password connect info
//char *Properties; // Connection property list //char *Properties; // Connection property list
//int Cto; // Connect timeout //int Cto; // Connect timeout
//int Qto; // Query timeout //int Qto; // Query timeout
...@@ -19,12 +19,12 @@ typedef struct jdbc_parms { ...@@ -19,12 +19,12 @@ typedef struct jdbc_parms {
/* JDBC catalog function prototypes. */ /* JDBC catalog function prototypes. */
/***********************************************************************/ /***********************************************************************/
#if defined(PROMPT_OK) #if defined(PROMPT_OK)
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop); char *JDBCCheckConnection(PGLOBAL g, PCSZ dsn, int cop);
#endif // PROMPT_OK #endif // PROMPT_OK
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info); //PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table,
char *colpat, int maxres, bool info, PJPARM sop); PCSZ colpat, int maxres, bool info, PJPARM sop);
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sop); PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sop);
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat, PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat,
char *tabtyp, int maxres, bool info, PJPARM sop); PCSZ tabtyp, int maxres, bool info, PJPARM sop);
PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info); PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info);
...@@ -189,8 +189,8 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v) ...@@ -189,8 +189,8 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
/***********************************************************************/ /***********************************************************************/
/* Allocate the structure used to refer to the result set. */ /* Allocate the structure used to refer to the result set. */
/***********************************************************************/ /***********************************************************************/
static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db, static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
char *tab, PQRYRES qrp) PCSZ tab, PQRYRES qrp)
{ {
JCATPARM *cap; JCATPARM *cap;
...@@ -213,7 +213,7 @@ static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db, ...@@ -213,7 +213,7 @@ static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db,
/* JDBCColumns: constructs the result blocks containing all columns */ /* JDBCColumns: constructs the result blocks containing all columns */
/* of a JDBC table that will be retrieved by GetData commands. */ /* of a JDBC table that will be retrieved by GetData commands. */
/***********************************************************************/ /***********************************************************************/
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat, PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat,
int maxres, bool info, PJPARM sjp) int maxres, bool info, PJPARM sjp)
{ {
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
...@@ -316,7 +316,7 @@ PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat, ...@@ -316,7 +316,7 @@ PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat,
/* JDBCSrcCols: constructs the result blocks containing the */ /* JDBCSrcCols: constructs the result blocks containing the */
/* description of all the columns of a Srcdef option. */ /* description of all the columns of a Srcdef option. */
/**************************************************************************/ /**************************************************************************/
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp) PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sjp)
{ {
char *sqry; char *sqry;
PQRYRES qrp; PQRYRES qrp;
...@@ -330,7 +330,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp) ...@@ -330,7 +330,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 2); sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 2);
sprintf(sqry, src, "1=1"); // dummy where clause sprintf(sqry, src, "1=1"); // dummy where clause
} else } else
sqry = src; sqry = (char*)src;
qrp = jcp->GetMetaData(g, sqry); qrp = jcp->GetMetaData(g, sqry);
jcp->Close(); jcp->Close();
...@@ -341,7 +341,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp) ...@@ -341,7 +341,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
/* JDBCTables: constructs the result blocks containing all tables in */ /* JDBCTables: constructs the result blocks containing all tables in */
/* an JDBC database that will be retrieved by GetData commands. */ /* an JDBC database that will be retrieved by GetData commands. */
/**************************************************************************/ /**************************************************************************/
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat, char *tabtyp, PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat, PCSZ tabtyp,
int maxres, bool info, PJPARM sjp) int maxres, bool info, PJPARM sjp)
{ {
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
...@@ -1059,7 +1059,7 @@ int JDBConn::Open(PJPARM sop) ...@@ -1059,7 +1059,7 @@ int JDBConn::Open(PJPARM sop)
/***********************************************************************/ /***********************************************************************/
/* Execute an SQL command. */ /* Execute an SQL command. */
/***********************************************************************/ /***********************************************************************/
int JDBConn::ExecSQLcommand(char *sql) int JDBConn::ExecSQLcommand(PCSZ sql)
{ {
int rc; int rc;
jint n; jint n;
...@@ -1142,7 +1142,7 @@ int JDBConn::Fetch(int pos) ...@@ -1142,7 +1142,7 @@ int JDBConn::Fetch(int pos)
/***********************************************************************/ /***********************************************************************/
/* Restart from beginning of result set */ /* Restart from beginning of result set */
/***********************************************************************/ /***********************************************************************/
int JDBConn::Rewind(char *sql) int JDBConn::Rewind(PCSZ sql)
{ {
int rbuf = -1; int rbuf = -1;
...@@ -1200,7 +1200,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1200,7 +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));
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC); throw TYPE_AM_JDBC;
} // endif name } // endif name
// Returns 666 is case of error // Returns 666 is case of error
...@@ -1208,7 +1208,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1208,7 +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);
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC); throw TYPE_AM_JDBC;
} // endif Check } // endif Check
if (val->GetNullable()) if (val->GetNullable())
...@@ -1227,7 +1227,8 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1227,7 +1227,8 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
case 12: // VARCHAR case 12: // VARCHAR
case -1: // LONGVARCHAR case -1: // LONGVARCHAR
case 1: // CHAR case 1: // CHAR
if (jb) case 3: // DECIMAL
if (jb && ctyp != 3)
cn = (jstring)jb; cn = (jstring)jb;
else if (!gmID(g, chrfldid, "StringField", "(ILjava/lang/String;)Ljava/lang/String;")) else if (!gmID(g, chrfldid, "StringField", "(ILjava/lang/String;)Ljava/lang/String;"))
cn = (jstring)env->CallObjectMethod(job, chrfldid, (jint)rank, jn); cn = (jstring)env->CallObjectMethod(job, chrfldid, (jint)rank, jn);
...@@ -1253,7 +1254,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1253,7 +1254,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
break; break;
case 8: // DOUBLE case 8: // DOUBLE
case 2: // NUMERIC case 2: // NUMERIC
case 3: // DECIMAL //case 3: // DECIMAL
if (!gmID(g, dblfldid, "DoubleField", "(ILjava/lang/String;)D")) if (!gmID(g, dblfldid, "DoubleField", "(ILjava/lang/String;)D"))
val->SetValue((double)env->CallDoubleMethod(job, dblfldid, rank, jn)); val->SetValue((double)env->CallDoubleMethod(job, dblfldid, rank, jn));
else else
...@@ -1314,7 +1315,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1314,7 +1315,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);
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC); throw TYPE_AM_JDBC;
} // endif Check } // endif Check
if (rank == 0) if (rank == 0)
...@@ -1325,7 +1326,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1325,7 +1326,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
/***********************************************************************/ /***********************************************************************/
/* Prepare an SQL statement for insert. */ /* Prepare an SQL statement for insert. */
/***********************************************************************/ /***********************************************************************/
bool JDBConn::PrepareSQL(char *sql) bool JDBConn::PrepareSQL(PCSZ sql)
{ {
bool b = true; bool b = true;
PGLOBAL& g = m_G; PGLOBAL& g = m_G;
...@@ -1348,7 +1349,7 @@ bool JDBConn::PrepareSQL(char *sql) ...@@ -1348,7 +1349,7 @@ bool JDBConn::PrepareSQL(char *sql)
/***********************************************************************/ /***********************************************************************/
/* Execute an SQL query that returns a result set. */ /* Execute an SQL query that returns a result set. */
/***********************************************************************/ /***********************************************************************/
int JDBConn::ExecuteQuery(char *sql) int JDBConn::ExecuteQuery(PCSZ sql)
{ {
int rc = RC_FX; int rc = RC_FX;
jint ncol; jint ncol;
...@@ -1376,7 +1377,7 @@ int JDBConn::ExecuteQuery(char *sql) ...@@ -1376,7 +1377,7 @@ int JDBConn::ExecuteQuery(char *sql)
/***********************************************************************/ /***********************************************************************/
/* Execute an SQL query and get the affected rows. */ /* Execute an SQL query and get the affected rows. */
/***********************************************************************/ /***********************************************************************/
int JDBConn::ExecuteUpdate(char *sql) int JDBConn::ExecuteUpdate(PCSZ sql)
{ {
int rc = RC_FX; int rc = RC_FX;
jint n; jint n;
...@@ -1404,7 +1405,7 @@ int JDBConn::ExecuteUpdate(char *sql) ...@@ -1404,7 +1405,7 @@ int JDBConn::ExecuteUpdate(char *sql)
/***********************************************************************/ /***********************************************************************/
/* Get the number of lines of the result set. */ /* Get the number of lines of the result set. */
/***********************************************************************/ /***********************************************************************/
int JDBConn::GetResultSize(char *sql, JDBCCOL *colp) int JDBConn::GetResultSize(PCSZ sql, JDBCCOL *colp)
{ {
int rc, n = 0; int rc, n = 0;
...@@ -1642,7 +1643,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1642,7 +1643,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
/* GetMetaData: constructs the result blocks containing the */ /* GetMetaData: constructs the result blocks containing the */
/* description of all the columns of an SQL command. */ /* description of all the columns of an SQL command. */
/**************************************************************************/ /**************************************************************************/
PQRYRES JDBConn::GetMetaData(PGLOBAL g, char *src) PQRYRES JDBConn::GetMetaData(PGLOBAL g, PCSZ src)
{ {
static int buftyp[] = {TYPE_STRING, TYPE_INT, TYPE_INT, static int buftyp[] = {TYPE_STRING, TYPE_INT, TYPE_INT,
TYPE_INT, TYPE_INT}; TYPE_INT, TYPE_INT};
...@@ -1844,7 +1845,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1844,7 +1845,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
PGLOBAL& g = m_G; PGLOBAL& g = m_G;
// void *buffer; // void *buffer;
int i, ncol; int i, ncol;
PSZ fnc = "Unknown"; PCSZ fnc = "Unknown";
uint n; uint n;
short len, tp; short len, tp;
int crow = 0; int crow = 0;
...@@ -1942,6 +1943,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1942,6 +1943,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
} // endif len } // endif len
pval[n] = AllocateValue(g, crp->Type, len); pval[n] = AllocateValue(g, crp->Type, len);
pval[n]->SetNullable(true);
if (crp->Type == TYPE_STRING) { if (crp->Type == TYPE_STRING) {
pbuf[n] = (char*)PlugSubAlloc(g, NULL, len); pbuf[n] = (char*)PlugSubAlloc(g, NULL, len);
......
...@@ -46,9 +46,9 @@ enum JCATINFO { ...@@ -46,9 +46,9 @@ enum JCATINFO {
typedef struct tagJCATPARM { typedef struct tagJCATPARM {
JCATINFO Id; // Id to indicate function JCATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer PQRYRES Qrp; // Result set pointer
char *DB; // Database (Schema) PCSZ DB; // Database (Schema)
char *Tab; // Table name or pattern PCSZ Tab; // Table name or pattern
char *Pat; // Table type or column pattern PCSZ Pat; // Table type or column pattern
} JCATPARM; } JCATPARM;
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *); typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
...@@ -77,7 +77,7 @@ class JDBConn : public BLOCK { ...@@ -77,7 +77,7 @@ class JDBConn : public BLOCK {
JDBConn(PGLOBAL g, TDBJDBC *tdbp); JDBConn(PGLOBAL g, TDBJDBC *tdbp);
int Open(PJPARM sop); int Open(PJPARM sop);
int Rewind(char *sql); int Rewind(PCSZ sql);
void Close(void); void Close(void);
PQRYRES AllocateResult(PGLOBAL g); PQRYRES AllocateResult(PGLOBAL g);
...@@ -96,19 +96,19 @@ class JDBConn : public BLOCK { ...@@ -96,19 +96,19 @@ class JDBConn : public BLOCK {
//void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;} //void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
//void SetUserName(PSZ user) {m_User = user;} //void SetUserName(PSZ user) {m_User = user;}
//void SetUserPwd(PSZ pwd) {m_Pwd = pwd;} //void SetUserPwd(PSZ pwd) {m_Pwd = pwd;}
int GetResultSize(char *sql, JDBCCOL *colp); int GetResultSize(PCSZ sql, JDBCCOL *colp);
int ExecuteQuery(char *sql); int ExecuteQuery(PCSZ sql);
int ExecuteUpdate(char *sql); int ExecuteUpdate(PCSZ sql);
int Fetch(int pos = 0); int Fetch(int pos = 0);
bool PrepareSQL(char *sql); bool PrepareSQL(PCSZ sql);
int ExecuteSQL(void); int ExecuteSQL(void);
bool SetParam(JDBCCOL *colp); bool SetParam(JDBCCOL *colp);
int ExecSQLcommand(char *sql); int ExecSQLcommand(PCSZ sql);
void SetColumnValue(int rank, PSZ name, PVAL val); void SetColumnValue(int rank, PSZ name, PVAL val);
int GetCatInfo(JCATPARM *cap); int GetCatInfo(JCATPARM *cap);
//bool GetDataSources(PQRYRES qrp); //bool GetDataSources(PQRYRES qrp);
bool GetDrivers(PQRYRES qrp); bool GetDrivers(PQRYRES qrp);
PQRYRES GetMetaData(PGLOBAL g, char *src); PQRYRES GetMetaData(PGLOBAL g, PCSZ src);
public: public:
// Set static variables // Set static variables
...@@ -174,16 +174,10 @@ class JDBConn : public BLOCK { ...@@ -174,16 +174,10 @@ class JDBConn : public BLOCK {
jmethodID timfldid; // The TimeField method ID jmethodID timfldid; // The TimeField method ID
jmethodID tspfldid; // The TimestampField method ID jmethodID tspfldid; // The TimestampField method ID
jmethodID bigfldid; // The BigintField method ID jmethodID bigfldid; // The BigintField method ID
//DWORD m_LoginTimeout; PCSZ Msg;
//DWORD m_QueryTimeout;
//DWORD m_UpdateOptions;
char *Msg;
char *m_Wrap; char *m_Wrap;
char m_IDQuoteChar[2]; char m_IDQuoteChar[2];
//PSZ m_Driver; PCSZ m_Pwd;
//PSZ m_Url;
//PSZ m_User;
PSZ m_Pwd;
int m_Ncol; int m_Ncol;
int m_Aff; int m_Aff;
int m_Rows; int m_Rows;
......
...@@ -53,6 +53,36 @@ void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp) ...@@ -53,6 +53,36 @@ void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp)
char *GetExceptionDesc(PGLOBAL g, unsigned int e); char *GetExceptionDesc(PGLOBAL g, unsigned int e);
#endif // SE_CATCH #endif // SE_CATCH
/***********************************************************************/
/* IsNum: check whether this string is all digits. */
/***********************************************************************/
bool IsNum(PSZ s)
{
for (char *p = s; *p; p++)
if (*p == ']')
break;
else if (!isdigit(*p) || *p == '-')
return false;
return true;
} // end of IsNum
/***********************************************************************/
/* NextChr: return the first found '[' or Sep pointer. */
/***********************************************************************/
char *NextChr(PSZ s, char sep)
{
char *p1 = strchr(s, '[');
char *p2 = strchr(s, sep);
if (!p2)
return p1;
else if (p1)
return MY_MIN(p1, p2);
return p2;
} // end of NextChr
/***********************************************************************/ /***********************************************************************/
/* Parse a json string. */ /* Parse a json string. */
...@@ -60,7 +90,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e); ...@@ -60,7 +90,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e);
/***********************************************************************/ /***********************************************************************/
PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
{ {
int i, rc, pretty = (ptyp) ? *ptyp : 3; int i, pretty = (ptyp) ? *ptyp : 3;
bool b = false, pty[3] = {true, true, true}; bool b = false, pty[3] = {true, true, true};
PJSON jsp = NULL; PJSON jsp = NULL;
STRG src; STRG src;
...@@ -81,52 +111,21 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) ...@@ -81,52 +111,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'))) if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')))
pty[0] = false; pty[0] = false;
// 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 --------------------
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
goto err;
} // 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
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
switch (s[i]) { switch (s[i]) {
case '[': case '[':
if (jsp) if (jsp)
goto tryit; goto tryit;
else if (!(jsp = ParseArray(g, ++i, src, pty))) else if (!(jsp = ParseArray(g, ++i, src, pty)))
goto err; throw 1;
break; break;
case '{': case '{':
if (jsp) if (jsp)
goto tryit; goto tryit;
else if (!(jsp = ParseObject(g, ++i, src, pty))) else if (!(jsp = ParseObject(g, ++i, src, pty)))
goto err; throw 2;
break; break;
case ' ': case ' ':
...@@ -144,7 +143,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) ...@@ -144,7 +143,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
} // endif pretty } // endif pretty
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty); sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty);
goto err; throw 3;
case '(': case '(':
b = true; b = true;
break; break;
...@@ -158,7 +157,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) ...@@ -158,7 +157,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
if (jsp) if (jsp)
goto tryit; goto tryit;
else if (!(jsp = ParseValue(g, i, src, pty))) else if (!(jsp = ParseValue(g, i, src, pty)))
goto err; throw 4;
break; break;
}; // endswitch s[i] }; // endswitch s[i]
...@@ -176,7 +175,15 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) ...@@ -176,7 +175,15 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
} // endif ptyp } // endif ptyp
g->jump_level--; } catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
jsp = NULL;
} catch (const char *msg) {
strcpy(g->Message, msg);
jsp = NULL;
} // end catch
return jsp; return jsp;
tryit: tryit:
...@@ -184,13 +191,10 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) ...@@ -184,13 +191,10 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
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;
g->jump_level--;
return jsp; return jsp;
} else } else
strcpy(g->Message, "More than one item in file"); strcpy(g->Message, "More than one item in file");
err:
g->jump_level--;
return NULL; return NULL;
} // end of ParseJson } // end of ParseJson
...@@ -591,20 +595,10 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty) ...@@ -591,20 +595,10 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
g->Message[0] = 0; g->Message[0] = 0;
// Save stack and allocation environment and prepare error return try {
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
if (!jsp) { if (!jsp) {
strcpy(g->Message, "Null json tree"); strcpy(g->Message, "Null json tree");
goto fin; throw 1;
} else if (!fn) { } else if (!fn) {
// Serialize to a string // Serialize to a string
jp = new(g) JOUTSTR(g); jp = new(g) JOUTSTR(g);
...@@ -614,7 +608,7 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty) ...@@ -614,7 +608,7 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
sprintf(g->Message, MSG(OPEN_MODE_ERROR), sprintf(g->Message, MSG(OPEN_MODE_ERROR),
"w", (int)errno, fn); "w", (int)errno, fn);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
goto fin;; throw 2;
} else if (pretty >= 2) { } else if (pretty >= 2) {
// Serialize to a pretty file // Serialize to a pretty file
jp = new(g)JOUTPRT(g, fs); jp = new(g)JOUTPRT(g, fs);
...@@ -655,8 +649,15 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty) ...@@ -655,8 +649,15 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
} // endif's } // endif's
fin: } catch (int n) {
g->jump_level--; if (trace)
htrc("Exception %d: %s\n", n, g->Message);
str = NULL;
} catch (const char *msg) {
strcpy(g->Message, msg);
str = NULL;
} // end catch
return str; return str;
} // end of Serialize } // end of Serialize
...@@ -965,7 +966,7 @@ return false; ...@@ -965,7 +966,7 @@ return false;
/***********************************************************************/ /***********************************************************************/
/* Add a new pair to an Object. */ /* Add a new pair to an Object. */
/***********************************************************************/ /***********************************************************************/
PJPR JOBJECT::AddPair(PGLOBAL g, PSZ key) PJPR JOBJECT::AddPair(PGLOBAL g, PCSZ key)
{ {
PJPR jpp = new(g) JPAIR(key); PJPR jpp = new(g) JPAIR(key);
...@@ -1021,7 +1022,24 @@ PSZ JOBJECT::GetText(PGLOBAL g, PSZ text) ...@@ -1021,7 +1022,24 @@ PSZ JOBJECT::GetText(PGLOBAL g, PSZ text)
if (!First && n) if (!First && n)
return NULL; return NULL;
else for (PJPR jp = First; jp; jp = jp->Next) else if (n == 1 && Size == 1 && !strcmp(First->GetKey(), "$date")) {
int i;
First->Val->GetText(g, text);
i = (text[1] == '-' ? 2 : 1);
if (IsNum(text + i)) {
// Date is in milliseconds
int j = (int)strlen(text);
if (j >= 4 + i)
text[j - 3] = 0; // Change it to seconds
else
strcpy(text, " 0");
} // endif text
} else for (PJPR jp = First; jp; jp = jp->Next)
jp->Val->GetText(g, text); jp->Val->GetText(g, text);
if (n) if (n)
...@@ -1051,7 +1069,7 @@ bool JOBJECT::Merge(PGLOBAL g, PJSON jsp) ...@@ -1051,7 +1069,7 @@ bool JOBJECT::Merge(PGLOBAL g, PJSON jsp)
/***********************************************************************/ /***********************************************************************/
/* Set or add a value corresponding to the given key. */ /* Set or add a value corresponding to the given key. */
/***********************************************************************/ /***********************************************************************/
void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key) void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PCSZ key)
{ {
PJPR jp; PJPR jp;
...@@ -1071,7 +1089,7 @@ void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key) ...@@ -1071,7 +1089,7 @@ void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key)
/***********************************************************************/ /***********************************************************************/
/* Delete a value corresponding to the given key. */ /* Delete a value corresponding to the given key. */
/***********************************************************************/ /***********************************************************************/
void JOBJECT::DeleteKey(PSZ key) void JOBJECT::DeleteKey(PCSZ key)
{ {
PJPR jp, *pjp = &First; PJPR jp, *pjp = &First;
...@@ -1250,10 +1268,10 @@ JVALUE::JVALUE(PGLOBAL g, PVAL valp) : JSON() ...@@ -1250,10 +1268,10 @@ JVALUE::JVALUE(PGLOBAL g, PVAL valp) : JSON()
/***********************************************************************/ /***********************************************************************/
/* Constructor for a given string. */ /* Constructor for a given string. */
/***********************************************************************/ /***********************************************************************/
JVALUE::JVALUE(PGLOBAL g, PSZ strp) : JSON() JVALUE::JVALUE(PGLOBAL g, PCSZ strp) : JSON()
{ {
Jsp = NULL; Jsp = NULL;
Value = AllocateValue(g, strp, TYPE_STRING); Value = AllocateValue(g, (void*)strp, TYPE_STRING);
Next = NULL; Next = NULL;
Del = false; Del = false;
} // end of JVALUE constructor } // end of JVALUE constructor
...@@ -1341,7 +1359,7 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text) ...@@ -1341,7 +1359,7 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
if (s) if (s)
strcat(strcat(text, " "), s); strcat(strcat(text, " "), s);
else else
strcat(text, " ???"); strcat(text, " <null>");
return text; return text;
} // end of GetText } // end of GetText
...@@ -1374,7 +1392,7 @@ void JVALUE::SetTiny(PGLOBAL g, char n) ...@@ -1374,7 +1392,7 @@ void JVALUE::SetTiny(PGLOBAL g, char n)
{ {
Value = AllocateValue(g, &n, TYPE_TINY); Value = AllocateValue(g, &n, TYPE_TINY);
Jsp = NULL; Jsp = NULL;
} // end of SetInteger } // end of SetTiny
/***********************************************************************/ /***********************************************************************/
/* Set the Value's value as the given big integer. */ /* Set the Value's value as the given big integer. */
...@@ -1408,6 +1426,6 @@ void JVALUE::SetString(PGLOBAL g, PSZ s, short c) ...@@ -1408,6 +1426,6 @@ void JVALUE::SetString(PGLOBAL g, PSZ s, short c)
/***********************************************************************/ /***********************************************************************/
bool JVALUE::IsNull(void) bool JVALUE::IsNull(void)
{ {
return (Jsp) ? Jsp->IsNull() : (Value) ? Value->IsZero() : true; return (Jsp) ? Jsp->IsNull() : (Value) ? Value->IsNull() : true;
} // end of IsNull } // end of IsNull
/**************** json H Declares Source Code File (.H) ****************/ /**************** json H Declares Source Code File (.H) ****************/
/* Name: json.h Version 1.2 */ /* Name: json.h Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
/* */ /* */
/* This file contains the JSON classes declares. */ /* This file contains the JSON classes declares. */
/***********************************************************************/ /***********************************************************************/
...@@ -13,11 +13,12 @@ ...@@ -13,11 +13,12 @@
#define X #define X
#endif #endif
enum JTYP {TYPE_STRG = 1, enum JTYP {TYPE_STRG = TYPE_STRING,
TYPE_DBL = 2, TYPE_DBL = TYPE_DOUBLE,
TYPE_BOOL = 4, TYPE_BOOL = TYPE_TINY,
TYPE_BINT = 5, TYPE_BINT = TYPE_BIGINT,
TYPE_INTG = 7, TYPE_DTM = TYPE_DATE,
TYPE_INTG = TYPE_INT,
TYPE_JSON = 12, TYPE_JSON = 12,
TYPE_JAR, TYPE_JAR,
TYPE_JOB, TYPE_JOB,
...@@ -125,14 +126,14 @@ class JPAIR : public BLOCK { ...@@ -125,14 +126,14 @@ class JPAIR : public BLOCK {
friend PJOB ParseObject(PGLOBAL, int&, STRG&, bool*); friend PJOB ParseObject(PGLOBAL, int&, STRG&, bool*);
friend bool SerializeObject(JOUT *, PJOB); friend bool SerializeObject(JOUT *, PJOB);
public: public:
JPAIR(PSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;} JPAIR(PCSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;}
inline PSZ GetKey(void) {return Key;} inline PCSZ GetKey(void) {return Key;}
inline PJVAL GetVal(void) {return Val;} inline PJVAL GetVal(void) {return Val;}
inline PJPR GetNext(void) {return Next;} inline PJPR GetNext(void) {return Next;}
protected: protected:
PSZ Key; // This pair key name PCSZ Key; // This pair key name
PJVAL Val; // To the value of the pair PJVAL Val; // To the value of the pair
PJPR Next; // To the next pair PJPR Next; // To the next pair
}; // end of class JPAIR }; // end of class JPAIR
...@@ -150,7 +151,7 @@ class JSON : public BLOCK { ...@@ -150,7 +151,7 @@ class JSON : public BLOCK {
virtual JTYP GetValType(void) {X return TYPE_JSON;} virtual JTYP GetValType(void) {X return TYPE_JSON;}
virtual void InitArray(PGLOBAL g) {X} virtual void InitArray(PGLOBAL g) {X}
//virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;} //virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;}
virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;} virtual PJPR AddPair(PGLOBAL g, PCSZ key) {X return NULL;}
virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;} virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;}
virtual PJVAL GetValue(const char *key) {X return NULL;} virtual PJVAL GetValue(const char *key) {X return NULL;}
virtual PJOB GetObject(void) {return NULL;} virtual PJOB GetObject(void) {return NULL;}
...@@ -166,13 +167,13 @@ class JSON : public BLOCK { ...@@ -166,13 +167,13 @@ class JSON : public BLOCK {
virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;} virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;}
virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; } virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; }
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; } virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; }
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key) {X} virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key) {X}
virtual void SetValue(PVAL valp) {X} virtual void SetValue(PVAL valp) {X}
virtual void SetValue(PJSON jsp) {X} virtual void SetValue(PJSON jsp) {X}
virtual void SetString(PGLOBAL g, PSZ s, short c) {X} virtual void SetString(PGLOBAL g, PSZ s, short c) {X}
virtual void SetInteger(PGLOBAL g, int n) {X} virtual void SetInteger(PGLOBAL g, int n) {X}
virtual void SetFloat(PGLOBAL g, double f) {X} virtual void SetFloat(PGLOBAL g, double f) {X}
virtual void DeleteKey(char *k) {X} virtual void DeleteKey(PCSZ k) {X}
virtual bool DeleteValue(int i) {X return true;} virtual bool DeleteValue(int i) {X return true;}
virtual bool IsNull(void) {X return true;} virtual bool IsNull(void) {X return true;}
...@@ -195,14 +196,14 @@ class JOBJECT : public JSON { ...@@ -195,14 +196,14 @@ class JOBJECT : public JSON {
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JOB;} virtual JTYP GetType(void) {return TYPE_JOB;}
virtual PJPR GetFirst(void) {return First;} virtual PJPR GetFirst(void) {return First;}
virtual PJPR AddPair(PGLOBAL g, PSZ key); virtual PJPR AddPair(PGLOBAL g, PCSZ key);
virtual PJOB GetObject(void) {return this;} virtual PJOB GetObject(void) {return this;}
virtual PJVAL GetValue(const char* key); virtual PJVAL GetValue(const char* key);
virtual PJAR GetKeyList(PGLOBAL g); virtual PJAR GetKeyList(PGLOBAL g);
virtual PSZ GetText(PGLOBAL g, PSZ text); virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual bool Merge(PGLOBAL g, PJSON jsp); virtual bool Merge(PGLOBAL g, PJSON jsp);
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key); virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key);
virtual void DeleteKey(char *k); virtual void DeleteKey(PCSZ k);
virtual bool IsNull(void); virtual bool IsNull(void);
protected: protected:
...@@ -253,7 +254,7 @@ class JVALUE : public JSON { ...@@ -253,7 +254,7 @@ class JVALUE : public JSON {
JVALUE(PJSON jsp) : JSON() JVALUE(PJSON jsp) : JSON()
{Jsp = jsp; Value = NULL; Next = NULL; Del = false;} {Jsp = jsp; Value = NULL; Next = NULL; Del = false;}
JVALUE(PGLOBAL g, PVAL valp); JVALUE(PGLOBAL g, PVAL valp);
JVALUE(PGLOBAL g, PSZ strp); JVALUE(PGLOBAL g, PCSZ strp);
using JSON::GetValue; using JSON::GetValue;
using JSON::SetValue; using JSON::SetValue;
......
This diff is collapsed.
/******************** tabjson H Declares Source Code File (.H) *******************/ /******************** tabjson H Declares Source Code File (.H) *******************/
/* Name: jsonudf.h Version 1.2 */ /* Name: jsonudf.h Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2015-2017 */
/* */ /* */
/* This file contains the JSON UDF function and class declares. */ /* This file contains the JSON UDF function and class declares. */
/*********************************************************************************/ /*********************************************************************************/
...@@ -37,9 +37,9 @@ extern "C" { ...@@ -37,9 +37,9 @@ extern "C" {
DllExport char *jsonvalue(UDF_EXEC_ARGS); DllExport char *jsonvalue(UDF_EXEC_ARGS);
DllExport void jsonvalue_deinit(UDF_INIT*); DllExport void jsonvalue_deinit(UDF_INIT*);
DllExport my_bool json_array_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_make_array_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_array(UDF_EXEC_ARGS); DllExport char *json_make_array(UDF_EXEC_ARGS);
DllExport void json_array_deinit(UDF_INIT*); DllExport void json_make_array_deinit(UDF_INIT*);
DllExport my_bool json_array_add_values_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_array_add_values_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_array_add_values(UDF_EXEC_ARGS); DllExport char *json_array_add_values(UDF_EXEC_ARGS);
...@@ -53,9 +53,9 @@ extern "C" { ...@@ -53,9 +53,9 @@ extern "C" {
DllExport char *json_array_delete(UDF_EXEC_ARGS); DllExport char *json_array_delete(UDF_EXEC_ARGS);
DllExport void json_array_delete_deinit(UDF_INIT*); DllExport void json_array_delete_deinit(UDF_INIT*);
DllExport my_bool json_object_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_make_object_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_object(UDF_EXEC_ARGS); DllExport char *json_make_object(UDF_EXEC_ARGS);
DllExport void json_object_deinit(UDF_INIT*); DllExport void json_make_object_deinit(UDF_INIT*);
DllExport my_bool json_object_nonull_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_object_nonull_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_object_nonull(UDF_EXEC_ARGS); DllExport char *json_object_nonull(UDF_EXEC_ARGS);
...@@ -232,7 +232,7 @@ extern "C" { ...@@ -232,7 +232,7 @@ extern "C" {
/*********************************************************************************/ /*********************************************************************************/
typedef struct _jpn { typedef struct _jpn {
enum JTYP Type; enum JTYP Type;
PSZ Key; PCSZ Key;
int N; int N;
} JPN, *PJPN; } JPN, *PJPN;
......
This diff is collapsed.
...@@ -192,7 +192,7 @@ bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv) ...@@ -192,7 +192,7 @@ bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv)
case 23: case 23:
break; break;
default: default:
p = ""; p = PlugDup(g, "");
} // endswitch flag } // endswitch flag
} else switch (flag) { } else switch (flag) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -98,10 +98,7 @@ class MYCAT : public CATALOG { ...@@ -98,10 +98,7 @@ class MYCAT : public CATALOG {
// Methods // Methods
void Reset(void); void Reset(void);
//void SetDataPath(PGLOBAL g, const char *path)
// {SetPath(g, &DataPath, path);}
bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary
// PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
PRELDEF GetTableDesc(PGLOBAL g, PTABLE tablep, PRELDEF GetTableDesc(PGLOBAL g, PTABLE tablep,
LPCSTR type, PRELDEF *prp = NULL); LPCSTR type, PRELDEF *prp = NULL);
PTDB GetTable(PGLOBAL g, PTABLE tablep, PTDB GetTable(PGLOBAL g, PTABLE tablep,
...@@ -109,9 +106,7 @@ class MYCAT : public CATALOG { ...@@ -109,9 +106,7 @@ class MYCAT : public CATALOG {
void ClearDB(PGLOBAL g); void ClearDB(PGLOBAL g);
protected: protected:
// PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
PRELDEF MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am); PRELDEF MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am);
//void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
// Members // Members
ha_connect *Hc; // The Connect handler ha_connect *Hc; // The Connect handler
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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