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")
SET(CONNECT_SOURCES
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
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp filter.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
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
......@@ -291,6 +291,31 @@ IF(CONNECT_WITH_ZIP)
add_definitions(-DZIP_SUPPORT -DNOCRYPT)
ENDIF(CONNECT_WITH_ZIP)
#
# MONGO (CMAKE NOT YET WORKING)
#
#OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON)
#IF(CONNECT_WITH_MONGO)
# IF(WIN32)
# # Adding some typical places to search in
# SET(PC_MONGO_INCLUDE_DIRS
# C:/mongo-c-driver/include
# D:/mongo-c-driver/include)
# SET(PC_MONGO_LIBRARY_DIRS
# C:/mongo-c-driver/lib
# D:/mongo-c-driver/lib)
# ENDIF(WIN32)
# FIND_PACKAGE(libmongoc)
# IF (MONGO_FOUND)
# INCLUDE_DIRECTORIES(${MONGO_INCLUDE_DIR})
# SET(MONGO_LIBRARY ${MONGO_LIBRARIES})
# SET(CONNECT_SOURCES ${CONNECT_SOURCES} mongofam.cpp mongofam.h)
# add_definitions(-DMONGO_SUPPORT)
# ENDIF(MONGO_FOUND)
#ENDIF(CONNECT_WITH_MONGO)
#
# XMAP
......@@ -310,6 +335,7 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
STORAGE_ENGINE
COMPONENT connect-engine
RECOMPILE_FOR_EMBEDDED
# LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} $(MONGO_LIBRARY)
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY})
......@@ -518,8 +518,8 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
vp = valp;
} else if (opc != OP_EXIST) {
sprintf(g->Message, MSG(MISSING_ARG), opc);
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
sprintf(g->Message, MSG(MISSING_ARG), opc);
throw TYPE_ARRAY;
} else // OP_EXIST
return Nval > 0;
......@@ -681,15 +681,15 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
{
if (Vblp == NULL) {
strcpy(g->Message, MSG(PREC_VBLP_NULL));
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
throw TYPE_ARRAY;
} // endif Vblp
bool was = Vblp->IsCi();
if (was && !p) {
strcpy(g->Message, MSG(BAD_SET_CASE));
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
} // endif Vblp
throw TYPE_ARRAY;
} // endif Vblp
if (was || !p)
return;
......@@ -699,7 +699,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
if (!was && Type == TYPE_STRING)
// Must be resorted to eliminate duplicate strings
if (Sort(g))
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
throw TYPE_ARRAY;
} // end of SetPrecision
......@@ -973,18 +973,18 @@ int ARRAY::BlockTest(PGLOBAL, int opc, int opm,
PSZ ARRAY::MakeArrayList(PGLOBAL g)
{
char *p, *tp;
int i;
int i;
size_t z, len = 2;
if (Type == TYPE_LIST)
return "(?" "?" "?)"; // To be implemented
return (PSZ)("(?" "?" "?)"); // To be implemented
z = MY_MAX(24, GetTypeSize(Type, Len) + 4);
tp = (char*)PlugSubAlloc(g, NULL, z);
for (i = 0; i < Nval; i++) {
Value->SetValue_pvblk(Vblp, i);
Value->Print(g, tp, z);
Value->Prints(g, tp, z);
len += strlen(tp);
} // enfor i
......@@ -996,7 +996,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
for (i = 0; i < Nval;) {
Value->SetValue_pvblk(Vblp, i);
Value->Print(g, tp, z);
Value->Prints(g, tp, z);
strcat(p, tp);
strcat(p, (++i == Nval) ? ")" : ",");
} // enfor i
......@@ -1010,7 +1010,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
/***********************************************************************/
/* 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];
int lim = MY_MIN(Nval,10);
......@@ -1027,25 +1027,25 @@ void ARRAY::Print(PGLOBAL g, FILE *f, uint n)
if (Vblp)
for (int i = 0; i < lim; i++) {
Value->SetValue_pvblk(Vblp, i);
Value->Print(g, f, n+4);
Value->Printf(g, f, n+4);
} // endfor i
} else
fprintf(f, "%sVALLST: numval=%d\n", m, Nval);
} // end of Print
} // end of Printf
/***********************************************************************/
/* 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)
return;
sprintf(ps, "ARRAY: type=%d\n", Type);
// More to be implemented later
} // end of Print
} // end of Prints
/* -------------------------- Class MULAR ---------------------------- */
......
......@@ -56,8 +56,8 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
virtual bool Compare(PXOB) {assert(false); return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(false); return false;}
//virtual int CheckSpcCol(PTDB, int) {return 0;}
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
virtual void Printf(PGLOBAL g, FILE *f, uint n);
virtual void Prints(PGLOBAL g, char *ps, uint z);
// void Empty(void);
void SetPrecision(PGLOBAL g, int p);
bool AddValue(PGLOBAL g, PSZ sp);
......
/************* BlkFil C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: BLKFIL */
/* ------------- */
/* Version 2.5 */
/* Version 2.6 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
/* (C) Copyright to the author Olivier BERTRAND 2004-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -56,7 +56,7 @@ BLOCKFILTER::BLOCKFILTER(PTDBDOS tdbp, int op)
/***********************************************************************/
/* 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];
......@@ -65,15 +65,15 @@ void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n)
fprintf(f, "%sBLOCKFILTER: at %p opc=%d opm=%d result=%d\n",
m, this, Opc, Opm, Result);
} // end of Print
} // end of Printf
/***********************************************************************/
/* Make string output of BLOCKFILTER contents. */
/***********************************************************************/
void BLOCKFILTER::Print(PGLOBAL, char *ps, uint z)
void BLOCKFILTER::Prints(PGLOBAL, char *ps, uint z)
{
strncat(ps, "BlockFilter(s)", z);
} // end of Print
} // end of Prints
/* ---------------------- Class BLKFILLOG ---------------------------- */
......@@ -412,7 +412,7 @@ void BLKFILMR2::MakeValueBitmap(void)
Void = !Bmp[N]; // There are no good values in the file
for (i = 0; i < N; i++) {
Bxp[i] = ~0U;
Bxp[i] = ~0;
if (noteq)
Bmp[i] = Bxp[i];
......@@ -595,8 +595,8 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
if (Colp->GetResultType() != Type) {
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
longjmp(g->jumper[g->jump_level], 99);
} else if (Colp->GetValue()->IsCi())
throw g->Message;
} else if (Colp->GetValue()->IsCi())
Arap->SetPrecision(g, 1); // Case insensitive
Sorted = Colp->IsSorted() > 0;
......@@ -708,7 +708,7 @@ void BLKFILIN2::MakeValueBitmap(void)
Void = !Bmp[N]; // There are no good values in the file
for (i = 0; i < N; i++) {
Bxp[i] = ~0U;
Bxp[i] = ~0;
if (noteq) {
Bmp[i] = Bxp[i];
......@@ -828,7 +828,7 @@ BLKFILIN2::BLKFILIN2(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
Bxp[i] |= btp;
for (N = i--; i >= 0; i--)
Bxp[i] = ~0U;
Bxp[i] = ~0;
break;
} // endif Bmp
......@@ -995,7 +995,7 @@ int BLOCKINDEX::BlockEval(PGLOBAL g)
/***********************************************************************/
/* 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];
......@@ -1006,17 +1006,17 @@ void BLOCKINDEX::Print(PGLOBAL g, FILE *f, UINT n)
m, this, Next, (Colp) ? Colp->GetName() : "Rowid", Kxp, Result);
if (Next)
Next->Print(g, f, n);
Next->Printf(g, f, n);
} // end of Print
} // end of Printf
/***********************************************************************/
/* Make string output of BLOCKINDEX contents. */
/***********************************************************************/
void BLOCKINDEX::Print(PGLOBAL g, char *ps, UINT z)
void BLOCKINDEX::Prints(PGLOBAL g, char *ps, UINT z)
{
strncat(ps, "BlockIndex(es)", z);
} // end of Print
} // end of Prints
/* ------------------------------------------------------------------- */
......
......@@ -27,8 +27,8 @@ class DllExport BLOCKFILTER : public BLOCK { /* Block Filter */
// Methods
virtual void Reset(PGLOBAL) = 0;
virtual int BlockEval(PGLOBAL) = 0;
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
virtual void Printf(PGLOBAL g, FILE *f, uint n);
virtual void Prints(PGLOBAL g, char *ps, uint z);
protected:
BLOCKFILTER(void) {} // Standard constructor not to be used
......@@ -234,8 +234,8 @@ class DllExport BLOCKINDEX : public BLOCK { /* Indexing Test Block */
// Methods
void Reset(void);
virtual int BlockEval(PGLOBAL);
virtual void Print(PGLOBAL g, FILE *f, UINT n);
virtual void Print(PGLOBAL g, char *ps, UINT z);
virtual void Printf(PGLOBAL g, FILE *f, UINT n);
virtual void Prints(PGLOBAL g, char *ps, UINT z);
protected:
BLOCKINDEX(void) {} // Standard constructor not to be used
......
......@@ -44,8 +44,8 @@ class DllExport BLOCK {
return (PlugSubAlloc(g, p, size));
} // end of new
virtual void Print(PGLOBAL, FILE *, uint) {} // Produce file desc
virtual void Print(PGLOBAL, char *, uint) {} // Produce string desc
virtual void Printf(PGLOBAL, FILE *, uint) {} // Produce file desc
virtual void Prints(PGLOBAL, char *, uint) {} // Produce string desc
#if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator
......
......@@ -36,7 +36,7 @@ typedef struct _curtab {
/* Defines the structure used to get column catalog info. */
/***********************************************************************/
typedef struct _colinfo {
char *Name;
PCSZ Name;
int Type;
int Offset;
int Length;
......@@ -45,9 +45,9 @@ typedef struct _colinfo {
int Scale;
int Opt;
int Freq;
char *Remark;
char *Datefmt;
char *Fieldfmt;
PCSZ Remark;
PCSZ Datefmt;
PCSZ Fieldfmt;
ushort Flags; // Used by MariaDB CONNECT handlers
} COLINFO, *PCOLINFO;
......@@ -68,11 +68,9 @@ class DllExport CATALOG {
bool GetDefHuge(void) {return DefHuge;}
void SetDefHuge(bool b) {DefHuge = b;}
char *GetCbuf(void) {return Cbuf;}
//char *GetDataPath(void) {return (char*)DataPath;}
// Methods
virtual void Reset(void) {}
//virtual void SetDataPath(PGLOBAL g, const char *path) {}
virtual bool CheckName(PGLOBAL, char*) {return true;}
virtual bool ClearName(PGLOBAL, PSZ) {return true;}
virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}
......@@ -102,7 +100,6 @@ class DllExport CATALOG {
int Cblen; /* Length of suballoc. buffer */
CURTAB Ctb; /* Used to enumerate tables */
bool DefHuge; /* true: tables default to huge */
//LPCSTR DataPath; /* Is the Path of DB data dir */
}; // end of class CATALOG
#endif // __CATALOG__H
......@@ -195,10 +195,10 @@ int COLBLK::GetLengthEx(void)
/* corresponding to this column and convert it to buffer type. */
/***********************************************************************/
void COLBLK::ReadColumn(PGLOBAL g)
{
{
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of ReadColumn
throw TYPE_COLBLK;
} // end of ReadColumn
/***********************************************************************/
/* WriteColumn: what this routine does is to access the last line */
......@@ -206,15 +206,15 @@ void COLBLK::ReadColumn(PGLOBAL g)
/* corresponding to this column from the column buffer and type. */
/***********************************************************************/
void COLBLK::WriteColumn(PGLOBAL g)
{
{
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of WriteColumn
throw TYPE_COLBLK;
} // end of WriteColumn
/***********************************************************************/
/* 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];
int i;
......@@ -232,15 +232,15 @@ void COLBLK::Print(PGLOBAL, FILE *f, uint n)
fprintf(f,
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n",
ColUse, Status, Buf_Type, Value, Name);
} // end of Print
} // end of Printf
/***********************************************************************/
/* Make string output of a column descriptor block. */
/***********************************************************************/
void COLBLK::Print(PGLOBAL, char *ps, uint)
void COLBLK::Prints(PGLOBAL, char *ps, uint)
{
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
} // end of Print
} // end of Prints
/***********************************************************************/
......@@ -260,10 +260,10 @@ SPCBLK::SPCBLK(PCOLUMN cp)
/* corresponding to this column from the column buffer and type. */
/***********************************************************************/
void SPCBLK::WriteColumn(PGLOBAL g)
{
{
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of WriteColumn
throw TYPE_COLBLK;
} // end of WriteColumn
/***********************************************************************/
/* RIDBLK constructor for the ROWID special column. */
......@@ -377,7 +377,7 @@ PRTBLK::PRTBLK(PCOLUMN cp) : SPCBLK(cp)
void PRTBLK::ReadColumn(PGLOBAL g)
{
if (Pname == NULL) {
char *p;
const char *p;
Pname = To_Tdb->GetDef()->GetStringCatInfo(g, "partname", "?");
p = strrchr(Pname, '#');
......@@ -407,7 +407,7 @@ SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp)
void SIDBLK::ReadColumn(PGLOBAL)
{
//if (Sname == NULL) {
Sname = (char*)To_Tdb->GetServer();
Sname = To_Tdb->GetServer();
Value->SetValue_psz(Sname);
// } // endif Sname
......
......@@ -72,8 +72,8 @@ class DllExport COLBLK : public XOBJECT {
virtual void SetTo_Val(PVAL) {}
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
virtual void Printf(PGLOBAL g, FILE *, uint);
virtual void Prints(PGLOBAL g, char *, uint);
virtual bool VarSize(void) {return false;}
bool InitValue(PGLOBAL g);
......@@ -154,7 +154,7 @@ class DllExport FIDBLK : public SPCBLK {
virtual void ReadColumn(PGLOBAL g);
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
}; // end of class FIDBLK
......@@ -178,7 +178,7 @@ class DllExport TIDBLK : public SPCBLK {
TIDBLK(void) {}
// Members
PSZ Tname; // The current table name
PCSZ Tname; // The current table name
}; // end of class TIDBLK
/***********************************************************************/
......@@ -201,7 +201,7 @@ class DllExport PRTBLK : public SPCBLK {
PRTBLK(void) {}
// Members
PSZ Pname; // The current partition name
PCSZ Pname; // The current partition name
}; // end of class PRTBLK
/***********************************************************************/
......@@ -224,7 +224,7 @@ class DllExport SIDBLK : public SPCBLK {
SIDBLK(void) {}
// Members
PSZ Sname; // The current server name
PCSZ Sname; // The current server name
}; // end of class SIDBLK
#endif // __COLBLK__H
This diff is collapsed.
......@@ -49,8 +49,8 @@ class DllExport CSORT {
public:
// Methods
int Qsort(PGLOBAL g, int n); /* Sort calling routine */
//virtual void Print(PGLOBAL g, FILE *f, uint n);
//virtual void Print(PGLOBAL g, char *ps, uint z);
//virtual void Printf(PGLOBAL g, FILE *f, uint n);
//virtual void Prints(PGLOBAL g, char *ps, uint z);
#ifdef DEBTRACE
int GetNcmp(void) {return num_comp;}
#endif
......
......@@ -58,13 +58,15 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all)
if (xp && xp->Count > 1 && !all) {
xp->Count--;
} else if (xp && xp->Count > 0) {
try {
try {
if (xp->Docp)
xp->Docp->Release();
} catch(_com_error e) {
sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description());
} catch(...) {}
} catch(_com_error e) {
char *p = _com_util::ConvertBSTRToString(e.Description());
sprintf(g->Message, "%s %s", MSG(COM_ERROR), p);
delete[] p;
} catch(...) {}
CoUninitialize();
xp->Count = 0;
......@@ -89,7 +91,7 @@ DOMDOC::DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
/******************************************************************/
/* 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))
return true;
......@@ -155,7 +157,7 @@ PFBLOCK DOMDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn)
/******************************************************************/
/* Create the XML node. */
/******************************************************************/
bool DOMDOC::NewDoc(PGLOBAL g, char *ver)
bool DOMDOC::NewDoc(PGLOBAL g, PCSZ ver)
{
char buf[64];
MSXML2::IXMLDOMProcessingInstructionPtr pip;
......@@ -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. */
/******************************************************************/
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;
MSXML2::IXMLDOMNodePtr ep;
// _bstr_t uri((wchar_t*)NULL);
......@@ -585,7 +587,7 @@ PXATTR DOMNODE::AddProperty(PGLOBAL g, char *name, PXATTR ap)
/******************************************************************/
/* 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);
......
......@@ -37,9 +37,9 @@ class DOMDOC : public XMLDOCUMENT {
virtual void SetNofree(bool b) {} // Only libxml2
// 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 NewDoc(PGLOBAL g, char *ver);
virtual bool NewDoc(PGLOBAL g, PCSZ ver);
virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g);
virtual PXNODE NewRoot(PGLOBAL g, char *name);
......@@ -78,9 +78,9 @@ class DOMNODE : public XMLNODE {
virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
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 void AddText(PGLOBAL g, char *txtp);
virtual void AddText(PGLOBAL g, PCSZ txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected:
......
......@@ -301,10 +301,9 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header)
PDBUSER dup = (PDBUSER)g->Activityp->Aptr;
// Skip this record
while (*Mempos++ != '\n') ; // What about Unix ???
if (Mempos >= Top)
return RC_EF;
while (*Mempos++ != '\n') // What about Unix ???
if (Mempos == Top)
return RC_EF;
// Update progress information
dup->ProgCur = GetPos();
......@@ -320,7 +319,7 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/
int MAPFAM::ReadBuffer(PGLOBAL g)
{
int rc, len;
int rc, len, n = 1;
// Are we at the end of the memory
if (Mempos >= Top) {
......@@ -362,10 +361,14 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
Placed = false;
// 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
len = (Mempos - Fpos) - 1;
len = (Mempos - Fpos) - n;
// Don't rely on ENDING setting
if (len > 0 && *(Mempos - 2) == '\r')
......@@ -619,7 +622,9 @@ int MBKFAM::ReadBuffer(PGLOBAL g)
} // endif's
// 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
len = (Mempos - Fpos) - Ending;
......
......@@ -128,7 +128,7 @@ typedef struct _descriptor {
/* Moves file pointer to byte 32; fills buffer at buf with */
/* 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];
int dbc = 2, rc = RC_OK;
......@@ -186,7 +186,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
/* DBFColumns: constructs the result blocks containing the description */
/* 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,
TYPE_INT, TYPE_INT, TYPE_SHORT};
......@@ -393,7 +393,7 @@ DBFBASE::DBFBASE(DBFBASE *txfp)
/* and header length. Set Records, check that Reclen is equal to lrecl and */
/* 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;
char filename[_MAX_PATH];
......@@ -694,7 +694,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
} // endif Headlen
/**************************************************************************/
/* Position the file at the beginning of the data. */
/* Position the file at the begining of the data. */
/**************************************************************************/
if (Tdbp->GetMode() == MODE_INSERT)
rc = fseek(Stream, 0, SEEK_END);
......@@ -1034,7 +1034,7 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
} // endif Headlen
/**************************************************************************/
/* Position the file at the beginning of the data. */
/* Position the file at the begining of the data. */
/**************************************************************************/
Fpos = Mempos = Memory + Headlen;
Top--; // Because of EOF marker
......
......@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM;
/****************************************************************************/
/* 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. */
......@@ -31,7 +31,7 @@ class DllExport DBFBASE {
DBFBASE(PDBF txfp);
// 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:
// Default constructor, not to be used
......
......@@ -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);
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)
strcpy(buf, MSG(BAD_BYTE_NUM));
......
......@@ -920,8 +920,8 @@ int ZLBFAM::GetFileLength(PGLOBAL g)
/***********************************************************************/
bool ZLBFAM::AllocateBuffer(PGLOBAL g)
{
char *msg;
int n, zrc;
PCSZ msg;
int n, zrc;
#if 0
if (!Optimized && Tdbp->NeedIndexing(g)) {
......
/*********** File AM Txt C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMTXT */
/* ------------- */
/* Version 1.6 */
/* Version 1.7 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -71,8 +71,23 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
{
Tdbp = NULL;
To_Fb = NULL;
To_File = tdp->Fn;
Lrecl = tdp->Lrecl;
if (tdp) {
To_File = tdp->Fn;
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;
IsRead = true;
Blocked = false;
......@@ -103,8 +118,6 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
Blksize = 0;
Fpos = Spos = Tpos = 0;
Padded = false;
Eof = tdp->Eof;
Ending = tdp->Ending;
Abort = false;
CrLf = (char*)(Ending == 1 ? "\n" : "\r\n");
} // end of TXTFAM standard constructor
......@@ -973,7 +986,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
} else {
/*****************************************************************/
/* Move of eventual preceding lines is not required here. */
/* Move of eventual preceding lines is not required here. */
/* Set the target file as being the source file itself. */
/* Set the future Tpos, and give Spos a value to block copying. */
/*****************************************************************/
......@@ -1161,13 +1174,13 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
if (rename(filename, filetemp)) { // Save file for security
sprintf(g->Message, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno));
longjmp(g->jumper[g->jump_level], 51);
} else if (rename(tempname, filename)) {
throw 51;
} else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR),
tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file
longjmp(g->jumper[g->jump_level], 52);
} else if (remove(filetemp)) {
throw 52;
} else if (remove(filetemp)) {
sprintf(g->Message, MSG(REMOVE_ERROR),
filetemp, strerror(errno));
rc = RC_INFO; // Acceptable
......
......@@ -80,7 +80,7 @@ class DllExport TXTFAM : public BLOCK {
protected:
// Members
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
PPARM To_Pos; // Pointer to position list
PPARM To_Sos; // Pointer to start position list
......
......@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -143,9 +143,9 @@ int VCTFAM::GetFileLength(PGLOBAL g)
{
if (Split) {
// Get the total file length
char filename[_MAX_PATH];
char *savfile = To_File;
int i, len = 0;
char filename[_MAX_PATH];
PCSZ savfile = To_File;
int i, len = 0;
// Initialize the array of file structures
if (!Colfn) {
......@@ -313,8 +313,8 @@ int VCTFAM::Cardinality(PGLOBAL g)
// and Last must be set from the file cardinality.
// Only happens when called by sub classes.
char filename[_MAX_PATH];
PSZ savfn = To_File;
int len, clen, card = -1;
PCSZ savfn = To_File;
int len, clen, card = -1;
PCOLDEF cdp = Tdbp->GetDef()->GetCols();
if (!Colfn) {
......@@ -368,7 +368,7 @@ int VCTFAM::GetRowID(void)
/***********************************************************************/
/* 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
// required length if it does not exists yet.
......@@ -559,41 +559,42 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
/* Do initial action when inserting. */
/***********************************************************************/
bool VCTFAM::InitInsert(PGLOBAL g)
{
{
bool rc = false;
// We come here in MODE_INSERT only
if (Last == Nrec) {
CurBlk = Block;
CurNum = 0;
AddBlock = !MaxBlk;
} else {
int rc;
PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
// The starting point must be at the end of file as for append.
CurBlk = Block - 1;
CurNum = Last;
// Prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true;
} // endif
try {
// Last block must be updated by new values
for (; cp; cp = (PVCTCOL)cp->Next)
cp->ReadBlock(g);
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
g->jump_level--;
return true;
} // endif
} 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
// Last block must be updated by new values
for (; cp; cp = (PVCTCOL)cp->Next)
cp->ReadBlock(g);
g->jump_level--;
} // endif Last
// We are not currently using a temporary file for Insert
T_Stream = Stream;
return false;
if (!rc)
// We are not currently using a temporary file for Insert
T_Stream = Stream;
return rc;
} // end of InitInsert
/***********************************************************************/
......@@ -878,8 +879,9 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
bool VCTFAM::OpenTempFile(PGLOBAL g)
{
char *opmode, tempname[_MAX_PATH];
bool rc = false;
PCSZ opmode;
char tempname[_MAX_PATH];
bool rc = false;
/*********************************************************************/
/* Open the temporary file, Spos is at the beginning of file. */
......@@ -1107,7 +1109,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
} else if (AddBlock) {
// Last block was not written
rc = ResetTableSize(g, CurBlk, Nrec);
longjmp(g->jumper[g->jump_level], 44);
throw 44;
} // endif
} else if (mode == MODE_UPDATE) {
......@@ -1527,8 +1529,8 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g)
/* Do initial action when inserting. */
/***********************************************************************/
bool VCMFAM::InitInsert(PGLOBAL g)
{
int rc;
{
bool rc = false;
volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
// We come here in MODE_INSERT only
......@@ -1542,24 +1544,22 @@ bool VCMFAM::InitInsert(PGLOBAL g)
CurNum = Last;
} // endif Last
// Prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true;
} // endif
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
g->jump_level--;
return true;
} // endif
try {
// Initialize the column block pointer
for (; cp; cp = (PVCTCOL)cp->Next)
cp->ReadBlock(g);
// Initialize the column block pointer
for (; cp; cp = (PVCTCOL)cp->Next)
cp->ReadBlock(g);
} 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
g->jump_level--;
return false;
} // end of InitInsert
return rc;
} // end of InitInsert
/***********************************************************************/
/* Data Base write routine for VMP access method. */
......@@ -1998,7 +1998,7 @@ bool VECFAM::OpenTableFile(PGLOBAL g)
/***********************************************************************/
/* 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];
PDBUSER dup = PlgGetUser(g);
......@@ -2503,7 +2503,7 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
if (wrc != RC_FX)
rc = ResetTableSize(g, Block, Last);
else
longjmp(g->jumper[g->jump_level], 44);
throw 44;
} else if (mode == MODE_UPDATE) {
if (UseTemp && !InitUpdate && !Abort) {
......@@ -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);
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)
strcpy(buf, MSG(BAD_BYTE_NUM));
......@@ -3319,7 +3320,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
/***********************************************************************/
/* 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
// required length if it does not exists yet.
......@@ -3329,7 +3330,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
PlugSetPath(filename, fn, Tdbp->GetPath());
#if defined(__WIN__)
char *p;
PCSZ p;
DWORD rc;
bool brc;
LARGE_INTEGER of;
......@@ -4164,8 +4165,8 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
} else if (AddBlock) {
// Last block was not written
rc = ResetTableSize(g, CurBlk, Nrec);
longjmp(g->jumper[g->jump_level], 44);
} // endif
throw 44;
} // endif
} else if (mode == MODE_UPDATE) {
// Write back to file any pending modifications
......
......@@ -61,7 +61,7 @@ class DllExport VCTFAM : public FIXFAM {
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected:
virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool MakeEmptyFile(PGLOBAL g, PCSZ fn);
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
......@@ -160,7 +160,7 @@ class DllExport VECFAM : public VCTFAM {
virtual bool MoveLines(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual int RenameTempFile(PGLOBAL g);
bool OpenColumnFile(PGLOBAL g, char *opmode, int i);
bool OpenColumnFile(PGLOBAL g, PCSZ opmode, int i);
// Members
FILE* *Streams; // Points to Dos file structure array
......@@ -235,7 +235,7 @@ class BGVFAM : public VCTFAM {
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false);
bool BigRead(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 MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g);
......
This diff is collapsed.
/************** 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 */
/* */
......@@ -27,16 +27,13 @@ typedef class ZPXFAM *PZPXFAM;
class DllExport ZIPUTIL : public BLOCK {
public:
// Constructor
ZIPUTIL(PSZ tgt);
ZIPUTIL(PCSZ tgt);
//ZIPUTIL(ZIPUTIL *zutp);
// Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
// Methods
bool OpenTable(PGLOBAL g, MODE mode, char *fn, bool append);
bool open(PGLOBAL g, char *fn, bool append);
bool addEntry(PGLOBAL g, char *entry);
bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn, bool append);
bool open(PGLOBAL g, PCSZ fn, bool append);
bool addEntry(PGLOBAL g, PCSZ entry);
void close(void);
void closeEntry(void);
int writeEntry(PGLOBAL g, char *buf, int len);
......@@ -44,15 +41,10 @@ class DllExport ZIPUTIL : public BLOCK {
// Members
zipFile zipfile; // The ZIP container file
PSZ target; // The target file name
//unz_file_info finfo; // The current file info
PCSZ target; // The target file name
PCSZ pwd; // The ZIP file password
PFBLOCK fp;
//char *memory;
//uint size;
//int multiple; // Multiple targets
bool entryopen; // True when open current entry
//char fn[FILENAME_MAX]; // The current entry file name
//char mapCaseTable[256];
}; // end of ZIPUTIL
/***********************************************************************/
......@@ -61,25 +53,27 @@ class DllExport ZIPUTIL : public BLOCK {
class DllExport UNZIPUTL : public BLOCK {
public:
// Constructor
UNZIPUTL(PSZ tgt, bool mul);
//UNZIPUTL(UNZIPUTL *zutp);
UNZIPUTL(PCSZ tgt, bool mul);
UNZIPUTL(PDOSDEF tdp);
// Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
// Methods
bool OpenTable(PGLOBAL g, MODE mode, char *fn);
bool open(PGLOBAL g, char *fn);
bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn);
bool open(PGLOBAL g, PCSZ fn);
bool openEntry(PGLOBAL g);
void close(void);
void closeEntry(void);
bool WildMatch(PSZ pat, PSZ str);
bool WildMatch(PCSZ pat, PCSZ str);
int findEntry(PGLOBAL g, bool next);
int nextEntry(PGLOBAL g);
bool IsInsertOk(PGLOBAL g, PCSZ fn);
// Members
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
PFBLOCK fp;
char *memory;
......@@ -119,8 +113,7 @@ class DllExport UNZFAM : public MAPFAM {
protected:
// Members
UNZIPUTL *zutp;
PSZ target;
bool mul;
PDOSDEF tdfp;
}; // end of UNZFAM
/***********************************************************************/
......@@ -147,8 +140,7 @@ class DllExport UZXFAM : public MPXFAM {
protected:
// Members
UNZIPUTL *zutp;
PSZ target;
bool mul;
PDOSDEF tdfp;
}; // end of UZXFAM
/***********************************************************************/
......@@ -175,8 +167,9 @@ class DllExport ZIPFAM : public DOSFAM {
protected:
// Members
ZIPUTIL *zutp;
PSZ target;
PCSZ target;
bool append;
//bool replace;
}; // end of ZIPFAM
/***********************************************************************/
......@@ -200,7 +193,7 @@ class DllExport ZPXFAM : public FIXFAM {
protected:
// Members
ZIPUTIL *zutp;
PSZ target;
PCSZ target;
bool append;
}; // end of ZPXFAM
......
/***************** 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. */
/***********************************************************************/
......@@ -38,6 +38,13 @@
//#include "token.h"
//#include "select.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. */
......@@ -87,8 +94,8 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
case OP_EXIST: bt = 0x00; break;
default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
} // endswitch opc
throw TYPE_ARRAY;
} // endswitch opc
return bt;
} // end of OpBmp
......@@ -1405,10 +1412,98 @@ PFIL FILTER::Copy(PTABS t)
} // end of Copy
#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. */
/*********************************************************************/
void FILTER::Print(PGLOBAL g, FILE *f, uint n)
void FILTER::Printf(PGLOBAL g, FILE *f, uint n)
{
char m[64];
......@@ -1430,18 +1525,18 @@ void FILTER::Print(PGLOBAL g, FILE *f, uint n)
if (lin && fp->GetArgType(i) == TYPE_FILTER)
fprintf(f, "%s Filter at %p\n", m, fp->Arg(i));
else
fp->Arg(i)->Print(g, f, n + 2);
fp->Arg(i)->Printf(g, f, n + 2);
} // endfor i
} // endfor fp
} // end of Print
} // end of Printf
/***********************************************************************/
/* 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
......@@ -1469,7 +1564,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
bcp = bxp;
p = bcp->Cold;
n = FLEN;
fp->Arg(0)->Print(g, p, n);
fp->Arg(0)->Prints(g, p, n);
n = FLEN - strlen(p);
switch (fp->Opc) {
......@@ -1515,7 +1610,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
n = FLEN - strlen(p);
p += strlen(p);
fp->Arg(1)->Print(g, p, n);
fp->Arg(1)->Prints(g, p, n);
} else
if (!bcp) {
strncat(ps, "???", z);
......@@ -1578,7 +1673,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
bcp = bxp;
} while (bcp); // enddo
} // end of Print
} // end of Prints
/* -------------------- Derived Classes Functions -------------------- */
......@@ -1696,8 +1791,6 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
if (trace)
htrc("PrepareFilter: fp=%p having=%d\n", fp, having);
//if (fp)
// fp->Print(g, debug, 0);
while (fp) {
if (fp->Opc == OP_SEP)
......@@ -1711,7 +1804,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
break; // Remove eventual ending separator(s)
// if (fp->Convert(g, having))
// longjmp(g->jumper[g->jump_level], TYPE_FILTER);
// throw TYPE_ARRAY;
filp = fp;
fp = fp->Next;
......@@ -1744,7 +1837,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
// return TRUE;
if (filp->Eval(g))
longjmp(g->jumper[g->jump_level], TYPE_FILTER);
throw TYPE_FILTER;
if (trace > 1)
htrc("PlugFilter filp=%p result=%d\n",
......
......@@ -61,8 +61,11 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */
//virtual PXOB CheckSubQuery(PGLOBAL, PSQL);
//virtual bool CheckLocal(PTDB);
//virtual int CheckSpcCol(PTDB tdbp, int n);
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
#if defined(MONGO_SUPPORT)
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 Link(PGLOBAL g, PFIL fil2);
// PFIL RemoveLastSep(void);
......
/***********************************************************************/
/* 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 @@
#define NO_IVAL -95684275 /* Used by GetIntegerOption */
#define VMLANG 370 /* Size of olf VM lang blocks */
#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 STD_INPUT 0 /* Standard language input */
#define STD_OUTPUT 1 /* Standard language output */
......@@ -90,6 +90,7 @@
#define TYPE_BIGINT 5
#define TYPE_LIST 6
#define TYPE_INT 7
#define TYPE_DATE 8
#define TYPE_DECIM 9
#define TYPE_BIN 10
#define TYPE_PCHAR 11
......@@ -229,9 +230,10 @@ typedef struct _parm {
typedef struct _global { /* Global structure */
void *Sarea; /* Points to work area */
uint Sarea_Size; /* Work area size */
PACTIVITY Activityp, ActivityStart;
PACTIVITY Activityp;
char Message[MAX_STR];
int Createas; /* To pass info to created table */
ulong More; /* Used by jsonudf */
int Createas; /* To pass info to created table */
void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */
short Mrr; /* True when doing mrr */
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ class XCHK : public BLOCK {
oldopn= newopn= 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 newsep; // Sepindex after create/alter
......@@ -168,18 +168,18 @@ class ha_connect: public handler
static bool connect_init(void);
static bool connect_end(void);
TABTYPE GetRealType(PTOS pos= NULL);
char *GetRealString(const char *s);
char *GetStringOption(char *opname, char *sdef= NULL);
char *GetRealString(PCSZ s);
PCSZ GetStringOption(PCSZ opname, PCSZ sdef= NULL);
PTOS GetTableOptionStruct(TABLE_SHARE *s= NULL);
bool GetBooleanOption(char *opname, bool bdef);
bool SetBooleanOption(char *opname, bool b);
int GetIntegerOption(char *opname);
bool GetIndexOption(KEY *kp, char *opname);
bool CheckString(const char *str1, const char *str2);
bool SameString(TABLE *tab, char *opn);
bool SetIntegerOption(char *opname, int n);
bool SameInt(TABLE *tab, char *opn);
bool SameBool(TABLE *tab, char *opn);
bool GetBooleanOption(PCSZ opname, bool bdef);
bool SetBooleanOption(PCSZ opname, bool b);
int GetIntegerOption(PCSZ opname);
bool GetIndexOption(KEY *kp, PCSZ opname);
bool CheckString(PCSZ str1, PCSZ str2);
bool SameString(TABLE *tab, PCSZ opn);
bool SetIntegerOption(PCSZ opname, int n);
bool SameInt(TABLE *tab, PCSZ opn);
bool SameBool(TABLE *tab, PCSZ opn);
bool FileExists(const char *fn, bool bf);
bool NoFieldOptionChange(TABLE *tab);
PFOS GetFieldOptionStruct(Field *fp);
......@@ -187,8 +187,8 @@ class ha_connect: public handler
PXOS GetIndexOptionStruct(KEY *kp);
PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL);
bool CheckVirtualIndex(TABLE_SHARE *s);
const char *GetDBName(const char *name);
const char *GetTableName(void);
PCSZ GetDBName(PCSZ name);
PCSZ GetTableName(void);
char *GetPartName(void);
//int GetColNameLen(Field *fp);
//char *GetColName(Field *fp);
......@@ -197,9 +197,9 @@ class ha_connect: public handler
bool IsSameIndex(PIXDEF xp1, PIXDEF xp2);
bool IsPartitioned(void);
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);
int OpenTable(PGLOBAL g, bool del= false);
bool CheckColumnList(PGLOBAL g);
......@@ -513,7 +513,7 @@ int index_prev(uchar *buf);
ulong hnum; // The number of this handler
query_id_t valid_query_id; // The one when tdbp 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
PVAL sdvalin1; // Used to convert date values
PVAL sdvalin2; // Used to convert date values
......
......@@ -193,7 +193,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section )
}
for (key = section->key; key; key = key->next)
if (key->name[0]) {
if (key->name && key->name[0]) {
fprintf(file, "%s", SVP(key->name));
if (key->value)
......
......@@ -4,10 +4,10 @@
typedef struct jdbc_parms {
int CheckSize(int rows);
char *Driver; // JDBC driver
char *Url; // Driver URL
char *User; // User connect info
char *Pwd; // Password connect info
PCSZ Driver; // JDBC driver
PCSZ Url; // Driver URL
PCSZ User; // User connect info
PCSZ Pwd; // Password connect info
//char *Properties; // Connection property list
//int Cto; // Connect timeout
//int Qto; // Query timeout
......@@ -19,12 +19,12 @@ typedef struct jdbc_parms {
/* JDBC catalog function prototypes. */
/***********************************************************************/
#if defined(PROMPT_OK)
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop);
char *JDBCCheckConnection(PGLOBAL g, PCSZ dsn, int cop);
#endif // PROMPT_OK
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table,
char *colpat, int maxres, bool info, PJPARM sop);
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sop);
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat,
char *tabtyp, int maxres, bool info, PJPARM sop);
PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table,
PCSZ colpat, int maxres, bool info, PJPARM sop);
PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sop);
PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat,
PCSZ tabtyp, int maxres, bool info, PJPARM sop);
PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info);
......@@ -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. */
/***********************************************************************/
static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db,
char *tab, PQRYRES qrp)
static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
PCSZ tab, PQRYRES qrp)
{
JCATPARM *cap;
......@@ -213,7 +213,7 @@ static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db,
/* JDBCColumns: constructs the result blocks containing all columns */
/* 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 buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
......@@ -316,7 +316,7 @@ PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat,
/* JDBCSrcCols: constructs the result blocks containing the */
/* 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;
PQRYRES qrp;
......@@ -330,7 +330,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 2);
sprintf(sqry, src, "1=1"); // dummy where clause
} else
sqry = src;
sqry = (char*)src;
qrp = jcp->GetMetaData(g, sqry);
jcp->Close();
......@@ -341,7 +341,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
/* JDBCTables: constructs the result blocks containing all tables in */
/* 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 buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
......@@ -1059,7 +1059,7 @@ int JDBConn::Open(PJPARM sop)
/***********************************************************************/
/* Execute an SQL command. */
/***********************************************************************/
int JDBConn::ExecSQLcommand(char *sql)
int JDBConn::ExecSQLcommand(PCSZ sql)
{
int rc;
jint n;
......@@ -1142,7 +1142,7 @@ int JDBConn::Fetch(int pos)
/***********************************************************************/
/* Restart from beginning of result set */
/***********************************************************************/
int JDBConn::Rewind(char *sql)
int JDBConn::Rewind(PCSZ sql)
{
int rbuf = -1;
......@@ -1200,7 +1200,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (rank == 0)
if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name));
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
throw TYPE_AM_JDBC;
} // endif name
// Returns 666 is case of error
......@@ -1208,7 +1208,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (Check((ctyp == 666) ? -1 : 1)) {
sprintf(g->Message, "Getting ctyp: %s", Msg);
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
throw TYPE_AM_JDBC;
} // endif Check
if (val->GetNullable())
......@@ -1227,7 +1227,8 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
case 12: // VARCHAR
case -1: // LONGVARCHAR
case 1: // CHAR
if (jb)
case 3: // DECIMAL
if (jb && ctyp != 3)
cn = (jstring)jb;
else if (!gmID(g, chrfldid, "StringField", "(ILjava/lang/String;)Ljava/lang/String;"))
cn = (jstring)env->CallObjectMethod(job, chrfldid, (jint)rank, jn);
......@@ -1253,7 +1254,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
break;
case 8: // DOUBLE
case 2: // NUMERIC
case 3: // DECIMAL
//case 3: // DECIMAL
if (!gmID(g, dblfldid, "DoubleField", "(ILjava/lang/String;)D"))
val->SetValue((double)env->CallDoubleMethod(job, dblfldid, rank, jn));
else
......@@ -1314,7 +1315,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
env->DeleteLocalRef(jn);
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
throw TYPE_AM_JDBC;
} // endif Check
if (rank == 0)
......@@ -1325,7 +1326,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
/***********************************************************************/
/* Prepare an SQL statement for insert. */
/***********************************************************************/
bool JDBConn::PrepareSQL(char *sql)
bool JDBConn::PrepareSQL(PCSZ sql)
{
bool b = true;
PGLOBAL& g = m_G;
......@@ -1348,7 +1349,7 @@ bool JDBConn::PrepareSQL(char *sql)
/***********************************************************************/
/* Execute an SQL query that returns a result set. */
/***********************************************************************/
int JDBConn::ExecuteQuery(char *sql)
int JDBConn::ExecuteQuery(PCSZ sql)
{
int rc = RC_FX;
jint ncol;
......@@ -1376,7 +1377,7 @@ int JDBConn::ExecuteQuery(char *sql)
/***********************************************************************/
/* Execute an SQL query and get the affected rows. */
/***********************************************************************/
int JDBConn::ExecuteUpdate(char *sql)
int JDBConn::ExecuteUpdate(PCSZ sql)
{
int rc = RC_FX;
jint n;
......@@ -1404,7 +1405,7 @@ int JDBConn::ExecuteUpdate(char *sql)
/***********************************************************************/
/* 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;
......@@ -1642,7 +1643,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
/* GetMetaData: constructs the result blocks containing the */
/* 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,
TYPE_INT, TYPE_INT};
......@@ -1844,7 +1845,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
PGLOBAL& g = m_G;
// void *buffer;
int i, ncol;
PSZ fnc = "Unknown";
PCSZ fnc = "Unknown";
uint n;
short len, tp;
int crow = 0;
......@@ -1942,6 +1943,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
} // endif len
pval[n] = AllocateValue(g, crp->Type, len);
pval[n]->SetNullable(true);
if (crp->Type == TYPE_STRING) {
pbuf[n] = (char*)PlugSubAlloc(g, NULL, len);
......
......@@ -46,9 +46,9 @@ enum JCATINFO {
typedef struct tagJCATPARM {
JCATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer
char *DB; // Database (Schema)
char *Tab; // Table name or pattern
char *Pat; // Table type or column pattern
PCSZ DB; // Database (Schema)
PCSZ Tab; // Table name or pattern
PCSZ Pat; // Table type or column pattern
} JCATPARM;
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
......@@ -77,7 +77,7 @@ class JDBConn : public BLOCK {
JDBConn(PGLOBAL g, TDBJDBC *tdbp);
int Open(PJPARM sop);
int Rewind(char *sql);
int Rewind(PCSZ sql);
void Close(void);
PQRYRES AllocateResult(PGLOBAL g);
......@@ -96,19 +96,19 @@ class JDBConn : public BLOCK {
//void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
//void SetUserName(PSZ user) {m_User = user;}
//void SetUserPwd(PSZ pwd) {m_Pwd = pwd;}
int GetResultSize(char *sql, JDBCCOL *colp);
int ExecuteQuery(char *sql);
int ExecuteUpdate(char *sql);
int GetResultSize(PCSZ sql, JDBCCOL *colp);
int ExecuteQuery(PCSZ sql);
int ExecuteUpdate(PCSZ sql);
int Fetch(int pos = 0);
bool PrepareSQL(char *sql);
bool PrepareSQL(PCSZ sql);
int ExecuteSQL(void);
bool SetParam(JDBCCOL *colp);
int ExecSQLcommand(char *sql);
int ExecSQLcommand(PCSZ sql);
void SetColumnValue(int rank, PSZ name, PVAL val);
int GetCatInfo(JCATPARM *cap);
//bool GetDataSources(PQRYRES qrp);
bool GetDrivers(PQRYRES qrp);
PQRYRES GetMetaData(PGLOBAL g, char *src);
PQRYRES GetMetaData(PGLOBAL g, PCSZ src);
public:
// Set static variables
......@@ -174,16 +174,10 @@ class JDBConn : public BLOCK {
jmethodID timfldid; // The TimeField method ID
jmethodID tspfldid; // The TimestampField method ID
jmethodID bigfldid; // The BigintField method ID
//DWORD m_LoginTimeout;
//DWORD m_QueryTimeout;
//DWORD m_UpdateOptions;
char *Msg;
PCSZ Msg;
char *m_Wrap;
char m_IDQuoteChar[2];
//PSZ m_Driver;
//PSZ m_Url;
//PSZ m_User;
PSZ m_Pwd;
PCSZ m_Pwd;
int m_Ncol;
int m_Aff;
int m_Rows;
......
This diff is collapsed.
/**************** json H Declares Source Code File (.H) ****************/
/* 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. */
/***********************************************************************/
......@@ -13,11 +13,12 @@
#define X
#endif
enum JTYP {TYPE_STRG = 1,
TYPE_DBL = 2,
TYPE_BOOL = 4,
TYPE_BINT = 5,
TYPE_INTG = 7,
enum JTYP {TYPE_STRG = TYPE_STRING,
TYPE_DBL = TYPE_DOUBLE,
TYPE_BOOL = TYPE_TINY,
TYPE_BINT = TYPE_BIGINT,
TYPE_DTM = TYPE_DATE,
TYPE_INTG = TYPE_INT,
TYPE_JSON = 12,
TYPE_JAR,
TYPE_JOB,
......@@ -125,14 +126,14 @@ class JPAIR : public BLOCK {
friend PJOB ParseObject(PGLOBAL, int&, STRG&, bool*);
friend bool SerializeObject(JOUT *, PJOB);
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 PJPR GetNext(void) {return Next;}
protected:
PSZ Key; // This pair key name
PCSZ Key; // This pair key name
PJVAL Val; // To the value of the pair
PJPR Next; // To the next pair
}; // end of class JPAIR
......@@ -150,7 +151,7 @@ class JSON : public BLOCK {
virtual JTYP GetValType(void) {X return TYPE_JSON;}
virtual void InitArray(PGLOBAL g) {X}
//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 PJVAL GetValue(const char *key) {X return NULL;}
virtual PJOB GetObject(void) {return NULL;}
......@@ -166,13 +167,13 @@ class JSON : public BLOCK {
virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;}
virtual bool Merge(PGLOBAL g, PJSON jsp) { 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(PJSON jsp) {X}
virtual void SetString(PGLOBAL g, PSZ s, short c) {X}
virtual void SetInteger(PGLOBAL g, int n) {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 IsNull(void) {X return true;}
......@@ -195,14 +196,14 @@ class JOBJECT : public JSON {
virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JOB;}
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 PJVAL GetValue(const char* key);
virtual PJAR GetKeyList(PGLOBAL g);
virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual bool Merge(PGLOBAL g, PJSON jsp);
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key);
virtual void DeleteKey(char *k);
virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key);
virtual void DeleteKey(PCSZ k);
virtual bool IsNull(void);
protected:
......@@ -253,7 +254,7 @@ class JVALUE : public JSON {
JVALUE(PJSON jsp) : JSON()
{Jsp = jsp; Value = NULL; Next = NULL; Del = false;}
JVALUE(PGLOBAL g, PVAL valp);
JVALUE(PGLOBAL g, PSZ strp);
JVALUE(PGLOBAL g, PCSZ strp);
using JSON::GetValue;
using JSON::SetValue;
......
This diff is collapsed.
/******************** 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. */
/*********************************************************************************/
......@@ -37,9 +37,9 @@ extern "C" {
DllExport char *jsonvalue(UDF_EXEC_ARGS);
DllExport void jsonvalue_deinit(UDF_INIT*);
DllExport my_bool json_array_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_array(UDF_EXEC_ARGS);
DllExport void json_array_deinit(UDF_INIT*);
DllExport my_bool json_make_array_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_make_array(UDF_EXEC_ARGS);
DllExport void json_make_array_deinit(UDF_INIT*);
DllExport my_bool json_array_add_values_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_array_add_values(UDF_EXEC_ARGS);
......@@ -53,9 +53,9 @@ extern "C" {
DllExport char *json_array_delete(UDF_EXEC_ARGS);
DllExport void json_array_delete_deinit(UDF_INIT*);
DllExport my_bool json_object_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_object(UDF_EXEC_ARGS);
DllExport void json_object_deinit(UDF_INIT*);
DllExport my_bool json_make_object_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_make_object(UDF_EXEC_ARGS);
DllExport void json_make_object_deinit(UDF_INIT*);
DllExport my_bool json_object_nonull_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_object_nonull(UDF_EXEC_ARGS);
......@@ -232,7 +232,7 @@ extern "C" {
/*********************************************************************************/
typedef struct _jpn {
enum JTYP Type;
PSZ Key;
PCSZ Key;
int N;
} JPN, *PJPN;
......
This diff is collapsed.
......@@ -192,7 +192,7 @@ bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv)
case 23:
break;
default:
p = "";
p = PlugDup(g, "");
} // endswitch flag
} else switch (flag) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -98,10 +98,7 @@ class MYCAT : public CATALOG {
// Methods
void Reset(void);
//void SetDataPath(PGLOBAL g, const char *path)
// {SetPath(g, &DataPath, path);}
bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary
// PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
PRELDEF GetTableDesc(PGLOBAL g, PTABLE tablep,
LPCSTR type, PRELDEF *prp = NULL);
PTDB GetTable(PGLOBAL g, PTABLE tablep,
......@@ -109,9 +106,7 @@ class MYCAT : public CATALOG {
void ClearDB(PGLOBAL g);
protected:
// PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
PRELDEF MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am);
//void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
// Members
ha_connect *Hc; // The Connect handler
......
This diff is collapsed.
......@@ -9,10 +9,9 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
#jdbc : Variable settings depend on machine configuration
#jdbc_new : Variable settings depend on machine configuration
jdbc : Variable settings depend on machine configuration
jdbc_new : Variable settings depend on machine configuration
jdbc_oracle : Variable settings depend on machine configuration
jdbc_postgresql : Variable settings depend on machine configuration
json : TABLE_TYPE = JSON conflicts with the SQL syntax
json_udf : conflicts with the server JSON functions
json_udf_bin : conflicts with the server JSON functions
json_mgo : Need MongoDB running and its C Driver installed
mongo : Need MongoDB running and its C Driver installed
......@@ -57,7 +57,7 @@ t1 CREATE TABLE `t1` (
`name` char(10) NOT NULL,
`birth` date NOT NULL,
`id` char(5) NOT NULL `FIELD_FORMAT`='S',
`salary` double(9,2) NOT NULL DEFAULT 0.00 `FIELD_FORMAT`='F',
`salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F',
`dept` int(4) NOT NULL `FIELD_FORMAT`='S'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=NO
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
......@@ -76,7 +76,7 @@ t1 CREATE TABLE `t1` (
`name` char(10) NOT NULL,
`birth` date NOT NULL,
`id` char(5) NOT NULL `FIELD_FORMAT`='S',
`salary` double(9,2) NOT NULL DEFAULT 0.00 `FIELD_FORMAT`='F',
`salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F',
`dept` int(4) NOT NULL `FIELD_FORMAT`='S'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=YES
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
......
......@@ -25,7 +25,6 @@ SELECT fname, ftype, size FROM t1 ORDER BY fname, ftype, size;
fname ftype size
boys .txt 282
boyswin .txt 288
SET STATEMENT sql_mode = '' FOR
INSERT INTO t1 VALUES ('','','','');
ERROR HY000: Got error 174 'COLBLK SetBuffer: undefined Access Method' from CONNECT
DROP TABLE t1;
......
......@@ -14,9 +14,7 @@ NULL NULL
SET GLOBAL time_zone='+1:00';
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=unknown';
SELECT * FROM t1;
ERROR HY000: Got error 174 'Connecting: java.sql.SQLException: Access denied for user 'unknown'@'localhost' (using password: NO) rc=-2' from CONNECT
DROP TABLE t1;
ERROR HY000: Connecting: java.sql.SQLException: Access denied for user 'unknown'@'localhost' (using password: NO) rc=-2
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/unknown?user=root';
ERROR HY000: Connecting: java.sql.SQLSyntaxErrorException: Unknown database 'unknown' rc=-2
......
This diff is collapsed.
This diff is collapsed.
......@@ -26,7 +26,6 @@ SELECT fname, ftype, size FROM t1 ORDER BY fname, ftype, size;
# TODO: add a better error message
--error ER_GET_ERRMSG
SET STATEMENT sql_mode = '' FOR
INSERT INTO t1 VALUES ('','','','');
DROP TABLE t1;
......
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