diff options
Diffstat (limited to 'storage/connect')
88 files changed, 1520 insertions, 1226 deletions
diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index a2f537436c9..193514eeb99 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -1,7 +1,7 @@ /************* Array C++ Functions Source Code File (.CPP) *************/ /* Name: ARRAY.CPP Version 2.3 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* This file contains the XOBJECT derived class ARRAY functions. */ /* ARRAY is used for elaborate type of processing, such as sorting */ @@ -19,14 +19,14 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <stdint.h> // for uintprt_h -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include required application header files */ @@ -186,7 +186,7 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec) // The error message was built by PlgDBalloc Type = TYPE_ERROR; else if (type != TYPE_PCHAR) - Value = AllocateValue(g, type, Len, prec, NULL); + Value = AllocateValue(g, type, Len, prec); Constant = TRUE; } // end of ARRAY constructor @@ -610,7 +610,7 @@ int ARRAY::Convert(PGLOBAL g, int k, PVAL vp) // The error message was built by PlgDBalloc return TYPE_ERROR; else - Value = AllocateValue(g, Type, Len, prec, NULL); + Value = AllocateValue(g, Type, Len, prec); /*********************************************************************/ /* Converting STRING to DATE can be done according to date format. */ @@ -848,7 +848,7 @@ void *ARRAY::GetSortIndex(PGLOBAL g) /* the indication of whether the Find will be always true, always not */ /* true or other. */ /***********************************************************************/ -int ARRAY::BlockTest(PGLOBAL g, int opc, int opm, +int ARRAY::BlockTest(PGLOBAL, int opc, int opm, void *minp, void *maxp, bool s) { bool bin, bax, pin, pax, veq, all = (opm == 2); @@ -1038,7 +1038,7 @@ void ARRAY::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of ARRAY contents. */ /***********************************************************************/ -void ARRAY::Print(PGLOBAL g, char *ps, uint z) +void ARRAY::Print(PGLOBAL, char *ps, uint z) { if (z < 16) return; diff --git a/storage/connect/blkfil.cpp b/storage/connect/blkfil.cpp index 802231b24ec..1f5a1a27ae5 100644 --- a/storage/connect/blkfil.cpp +++ b/storage/connect/blkfil.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -20,13 +20,13 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include <string.h> #include <sys/types.h> #include <sys/stat.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -56,7 +56,7 @@ BLOCKFILTER::BLOCKFILTER(PTDBDOS tdbp, int op) /***********************************************************************/ /* Make file output of BLOCKFILTER contents. */ /***********************************************************************/ -void BLOCKFILTER::Print(PGLOBAL g, FILE *f, uint n) +void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n) { char m[64]; @@ -70,7 +70,7 @@ void BLOCKFILTER::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of BLOCKFILTER contents. */ /***********************************************************************/ -void BLOCKFILTER::Print(PGLOBAL g, char *ps, uint z) +void BLOCKFILTER::Print(PGLOBAL, char *ps, uint z) { strncat(ps, "BlockFilter(s)", z); } // end of Print @@ -186,7 +186,7 @@ void BLKFILARI::Reset(PGLOBAL g) /***********************************************************************/ /* Evaluate block filter for arithmetic operators. */ /***********************************************************************/ -int BLKFILARI::BlockEval(PGLOBAL g) +int BLKFILARI::BlockEval(PGLOBAL) { int mincmp, maxcmp, n; @@ -306,7 +306,7 @@ void BLKFILAR2::MakeValueBitmap(void) /***********************************************************************/ /* Evaluate XDB2 block filter for arithmetic operators. */ /***********************************************************************/ -int BLKFILAR2::BlockEval(PGLOBAL g) +int BLKFILAR2::BlockEval(PGLOBAL) { #if defined(_DEBUG) assert (Colp->IsClustered()); @@ -428,7 +428,7 @@ void BLKFILMR2::MakeValueBitmap(void) /***********************************************************************/ /* Evaluate XDB2 block filter for arithmetic operators. */ /***********************************************************************/ -int BLKFILMR2::BlockEval(PGLOBAL g) +int BLKFILMR2::BlockEval(PGLOBAL) { #if defined(_DEBUG) assert (Colp->IsClustered()); @@ -514,7 +514,7 @@ void BLKSPCARI::Reset(PGLOBAL g) /***********************************************************************/ /* Evaluate block filter for arithmetic operators (ROWID) */ /***********************************************************************/ -int BLKSPCARI::BlockEval(PGLOBAL g) +int BLKSPCARI::BlockEval(PGLOBAL) { int mincmp, maxcmp, n, m; @@ -605,7 +605,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp) /***********************************************************************/ /* Reset: have the sorted array reset its Bot value to -1 (bottom). */ /***********************************************************************/ -void BLKFILIN::Reset(PGLOBAL g) +void BLKFILIN::Reset(PGLOBAL) { Arap->Reset(); // MakeValueBitmap(); // Does nothing for class BLKFILIN @@ -736,7 +736,7 @@ void BLKFILIN2::MakeValueBitmap(void) /* ended string in case of string argument. This is because the ARRAY */ /* can have a different width than the char column. */ /***********************************************************************/ -int BLKFILIN2::BlockEval(PGLOBAL g) +int BLKFILIN2::BlockEval(PGLOBAL) { if (N < 0) return Result; // Was set in MakeValueBitmap @@ -909,7 +909,7 @@ int BLKFILIN2::BlockEval(PGLOBAL g) /***********************************************************************/ /* BLKSPCIN constructor. */ /***********************************************************************/ -BLKSPCIN::BLKSPCIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, +BLKSPCIN::BLKSPCIN(PGLOBAL, PTDBDOS tdbp, int op, int opm, PXOB *xp, int bsize) : BLOCKFILTER(tdbp, op) { @@ -930,7 +930,7 @@ BLKSPCIN::BLKSPCIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, /***********************************************************************/ /* Reset: have the sorted array reset its Bot value to -1 (bottom). */ /***********************************************************************/ -void BLKSPCIN::Reset(PGLOBAL g) +void BLKSPCIN::Reset(PGLOBAL) { Arap->Reset(); } // end of Reset diff --git a/storage/connect/block.h b/storage/connect/block.h index d63a899d1f5..aa4edde5ec9 100644 --- a/storage/connect/block.h +++ b/storage/connect/block.h @@ -24,11 +24,11 @@ #if !defined(BLOCK_DEFINED) #define BLOCK_DEFINED -#if defined(WIN32) && !defined(NOEX) +#if defined(__WIN__) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !WIN32 +#else // !__WIN__ #define DllExport -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Definition of class BLOCK with its method function new. */ @@ -38,7 +38,7 @@ typedef class BLOCK *PBLOCK; class DllExport BLOCK { public: void * operator new(size_t size, PGLOBAL g, void *p = NULL) { -// if (trace > 2) +// if (trace > 3) // htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p); return (PlugSubAlloc(g, p, size)); @@ -50,7 +50,7 @@ class DllExport BLOCK { #if !defined(__BORLANDC__) // Avoid warning C4291 by defining a matching dummy delete operator void operator delete(void *, PGLOBAL, void *) {} - void operator delete(void *ptr,size_t size) {} + void operator delete(void *, size_t) {} #endif virtual ~BLOCK() {} diff --git a/storage/connect/catalog.h b/storage/connect/catalog.h index 5baab294737..6488b513ba9 100644 --- a/storage/connect/catalog.h +++ b/storage/connect/catalog.h @@ -1,7 +1,7 @@ /*************** Catalog H Declares Source Code File (.H) **************/ /* Name: CATALOG.H Version 3.3 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2000-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2000-2015 */ /* */ /* This file contains the CATALOG PlugDB classes definitions. */ /***********************************************************************/ @@ -73,33 +73,29 @@ class DllExport CATALOG { // Methods virtual void Reset(void) {} //virtual void SetDataPath(PGLOBAL g, const char *path) {} - virtual bool CheckName(PGLOBAL g, char *name) {return true;} - virtual bool ClearName(PGLOBAL g, PSZ name) {return true;} - virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} - virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;} - virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, - PRELDEF *prp = NULL) {return NULL;} - virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;} - virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;} - virtual bool TestCond(PGLOBAL g, const char *name, const char *type) - {return true;} - virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;} - virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, - MODE mode = MODE_READ, LPCSTR type = NULL) - {return NULL;} - virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {} - virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer, - int maxbuf, int info[]) {} - virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer, - int maxbuf, int info[]) {} - virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname, - char *buffer, int maxbuf, int info[]) {return NULL;} - virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;} - virtual void ClearDB(PGLOBAL g) {} + virtual bool CheckName(PGLOBAL, char*) {return true;} + virtual bool ClearName(PGLOBAL, PSZ) {return true;} + virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;} + virtual PRELDEF GetTableDescEx(PGLOBAL, PTABLE) {return NULL;} + virtual PRELDEF GetTableDesc(PGLOBAL, LPCSTR, LPCSTR, + PRELDEF* = NULL) {return NULL;} + virtual PRELDEF GetFirstTable(PGLOBAL) {return NULL;} + virtual PRELDEF GetNextTable(PGLOBAL) {return NULL;} + virtual bool TestCond(PGLOBAL, const char*, const char*) {return true;} + virtual bool DropTable(PGLOBAL, PSZ, bool) {return true;} + virtual PTDB GetTable(PGLOBAL, PTABLE, + MODE = MODE_READ, LPCSTR = NULL) {return NULL;} + virtual void TableNames(PGLOBAL, char*, int, int[]) {} + virtual void ColumnNames(PGLOBAL, char*, char*, int, int[]) {} + virtual void ColumnDefs(PGLOBAL, char*, char*, int, int[]) {} + virtual void *DecodeValues(PGLOBAL, char*, char*, char*, + int, int[]) {return NULL;} + virtual int ColumnType(PGLOBAL, char*, char*) {return 0;} + virtual void ClearDB(PGLOBAL) {} protected: - virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;} - virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} + virtual bool ClearSection(PGLOBAL, const char*, const char*) {return true;} + virtual PRELDEF MakeTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;} // Members char *Cbuf; /* Buffer used for col section */ diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index f5bd32db738..80b405be041 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -1,7 +1,7 @@ /************* Colblk C++ Functions Source Code File (.CPP) ************/ /* Name: COLBLK.CPP Version 2.1 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* */ /* This file contains the COLBLK class functions. */ /***********************************************************************/ @@ -111,7 +111,7 @@ bool COLBLK::Compare(PXOB xp) /***********************************************************************/ /* SetFormat: function used to set SELECT output format. */ /***********************************************************************/ -bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt) +bool COLBLK::SetFormat(PGLOBAL, FORMAT& fmt) { fmt = Format; @@ -175,7 +175,7 @@ bool COLBLK::InitValue(PGLOBAL g) /***********************************************************************/ /* SetBuffer: prepare a column block for write operation. */ /***********************************************************************/ -bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) +bool COLBLK::SetBuffer(PGLOBAL g, PVAL, bool, bool) { sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer"); return true; @@ -214,7 +214,7 @@ void COLBLK::WriteColumn(PGLOBAL g) /***********************************************************************/ /* Make file output of a column descriptor block. */ /***********************************************************************/ -void COLBLK::Print(PGLOBAL g, FILE *f, uint n) +void COLBLK::Print(PGLOBAL, FILE *f, uint n) { char m[64]; int i; @@ -237,7 +237,7 @@ void COLBLK::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of a column descriptor block. */ /***********************************************************************/ -void COLBLK::Print(PGLOBAL g, char *ps, uint z) +void COLBLK::Print(PGLOBAL, char *ps, uint) { sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name); } // end of Print @@ -297,9 +297,9 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op) Buf_Type = TYPE_STRING; *Format.Type = 'C'; Format.Length = Long; -#if defined(WIN32) +#if defined(__WIN__) Format.Prec = 1; // Case insensitive -#endif // WIN32 +#endif // __WIN__ Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() && To_Tdb->GetAmType() != TYPE_AM_PLG && To_Tdb->GetAmType() != TYPE_AM_PLM); @@ -347,7 +347,7 @@ TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp) /***********************************************************************/ /* ReadColumn: what this routine does is to return the table ID. */ /***********************************************************************/ -void TIDBLK::ReadColumn(PGLOBAL g) +void TIDBLK::ReadColumn(PGLOBAL) { if (Tname == NULL) { Tname = (char*)To_Tdb->GetName(); @@ -406,7 +406,7 @@ SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp) /***********************************************************************/ /* ReadColumn: what this routine does is to return the server ID. */ /***********************************************************************/ -void SIDBLK::ReadColumn(PGLOBAL g) +void SIDBLK::ReadColumn(PGLOBAL) { //if (Sname == NULL) { Sname = (char*)To_Tdb->GetServer(); diff --git a/storage/connect/colblk.h b/storage/connect/colblk.h index 5e8dc77ff69..c64f9d95129 100644 --- a/storage/connect/colblk.h +++ b/storage/connect/colblk.h @@ -1,7 +1,7 @@ /*************** Colblk H Declares Source Code File (.H) ***************/ /* Name: COLBLK.H Version 1.7 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* This file contains the COLBLK and derived classes declares. */ /***********************************************************************/ @@ -23,7 +23,7 @@ class DllExport COLBLK : public XOBJECT { // Default constructors used by derived classes COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0); COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process - COLBLK(int n) {} // Used when changing a column class in TDBXML + COLBLK(int) {} // Used when changing a column class in TDBXML public: // Implementation @@ -69,7 +69,7 @@ class DllExport COLBLK : public XOBJECT { virtual bool IsSpecial(void) {return false;} virtual bool Eval(PGLOBAL g); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); - virtual void SetTo_Val(PVAL valp) {} + virtual void SetTo_Val(PVAL) {} virtual void ReadColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g); virtual void Print(PGLOBAL g, FILE *, uint); diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 7c32c65226d..4e554b16638 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2012 +/* Copyright (C) Olivier Bertrand 2004 - 2015 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /***********************************************************************/ -/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2012 */ +/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -237,7 +237,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) /* OPENTAB: Open a Table. */ /***********************************************************************/ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, - bool del, PHC h) + bool del, PHC) { char *p; int i, n, rc; @@ -709,6 +709,28 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted) return (tdbp->To_Kindex->IsMul()) ? 2 : 1; } // end of CntIndexInit +#if defined(WORDS_BIGENDIAN) +/***********************************************************************/ +/* Swap bytes of the key that are written in little endian order. */ +/***********************************************************************/ +static void SetSwapValue(PVAL valp, char *kp) +{ + if (valp->IsTypeNum() && valp->GetType() != TYPE_DECIM) { + uchar buf[8]; + int i, k= valp->GetClen(); + + for (i = 0; k > 0;) + buf[i++]= kp[--k]; + + + + valp->SetBinValue((void*)buf); + } else + valp->SetBinValue((void*)kp); + +} // end of SetSwapValue +#endif // WORDS_BIGENDIAN + /***********************************************************************/ /* IndexRead: fetch a record having the index value. */ /***********************************************************************/ @@ -779,7 +801,12 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op, if (!valp->IsTypeNum()) { if (colp->GetColUse(U_VAR)) { +#if defined(WORDS_BIGENDIAN) + ((char*)&lg)[0]= ((char*)kp)[1]; + ((char*)&lg)[1]= ((char*)kp)[0]; +#else // !WORDS_BIGENDIAN lg= *(short*)kp; +#endif //!WORDS_BIGENDIAN kp+= sizeof(short); rcb= valp->SetValue_char(kp, (int)lg); } else @@ -797,7 +824,11 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op, } // endif b } else +#if defined(WORDS_BIGENDIAN) + SetSwapValue(valp, kp); +#else // !WORDS_BIGENDIAN valp->SetBinValue((void*)kp); +#endif //!WORDS_BIGENDIAN kp+= valp->GetClen(); @@ -893,7 +924,12 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, if (!valp->IsTypeNum()) { if (colp->GetColUse(U_VAR)) { +#if defined(WORDS_BIGENDIAN) + ((char*)&lg)[0]= ((char*)p)[1]; + ((char*)&lg)[1]= ((char*)p)[0]; +#else // !WORDS_BIGENDIAN lg= *(short*)p; +#endif //!WORDS_BIGENDIAN p+= sizeof(short); rcb= valp->SetValue_char((char*)p, (int)lg); } else @@ -912,7 +948,11 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, } // endif b } else +#if defined(WORDS_BIGENDIAN) + SetSwapValue(valp, (char*)p); +#else // !WORDS_BIGENDIAN valp->SetBinValue((void*)p); +#endif // !WORDS_BIGENDIAN if (trace) { char bf[32]; diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp index 9e518775c0f..64a0a172956 100644 --- a/storage/connect/domdoc.cpp +++ b/storage/connect/domdoc.cpp @@ -4,7 +4,7 @@ /******************************************************************/ #include "my_global.h" #include <stdio.h> -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> #if defined(MSX2) #import "msxml2.dll" //Does not exist on Vista diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index 1e65fa2a413..5cf9a4d945c 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -17,12 +17,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -30,7 +30,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -191,11 +191,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) return true; } // endif Memory -#if defined(WIN32) +#if defined(__WIN__) if (mode != MODE_DELETE) { -#else // !WIN32 +#else // !__WIN__ if (mode == MODE_READ) { -#endif // !WIN32 +#endif // !__WIN__ CloseFileHandle(hFile); // Not used anymore hFile = INVALID_HANDLE_VALUE; // For Fblock } // endif Mode @@ -276,7 +276,7 @@ bool MAPFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ /* Record file position in case of UPDATE or DELETE. */ /***********************************************************************/ -bool MAPFAM::RecordPos(PGLOBAL g) +bool MAPFAM::RecordPos(PGLOBAL) { Fpos = Mempos; return false; @@ -285,7 +285,7 @@ bool MAPFAM::RecordPos(PGLOBAL g) /***********************************************************************/ /* Initialize Fpos and Mempos for indexed DELETE. */ /***********************************************************************/ -int MAPFAM::InitDelete(PGLOBAL g, int fpos, int spos) +int MAPFAM::InitDelete(PGLOBAL, int fpos, int spos) { Fpos = Memory + (ptrdiff_t)fpos; Mempos = Memory + (ptrdiff_t)spos; @@ -371,7 +371,7 @@ int MAPFAM::ReadBuffer(PGLOBAL g) /***********************************************************************/ /* WriteBuffer: File write routine for MAP access method. */ /***********************************************************************/ -int MAPFAM::WriteBuffer(PGLOBAL g) +int MAPFAM::WriteBuffer(PGLOBAL g __attribute__((unused))) { #if defined(_DEBUG) // Insert mode is no more handled using file mapping @@ -452,7 +452,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ n = Tpos - Memory; -#if defined(WIN32) +#if defined(__WIN__) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -482,7 +482,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) #endif // UNIX } // endif Abort -#if defined(WIN32) +#if defined(__WIN__) CloseHandle(fp->Handle); #else // UNIX close(fp->Handle); @@ -495,7 +495,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Table file close routine for MAP access method. */ /***********************************************************************/ -void MAPFAM::CloseTableFile(PGLOBAL g, bool abort) +void MAPFAM::CloseTableFile(PGLOBAL g, bool) { PlugCloseFile(g, To_Fb); To_Fb = NULL; // To get correct file size in Cardinality @@ -551,7 +551,7 @@ int MBKFAM::Cardinality(PGLOBAL g) /***********************************************************************/ /* Skip one record in file. */ /***********************************************************************/ -int MBKFAM::SkipRecord(PGLOBAL g, bool header) +int MBKFAM::SkipRecord(PGLOBAL, bool) { return RC_OK; } // end of SkipRecord @@ -685,7 +685,7 @@ bool MPXFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ /* Initialize CurBlk, CurNum, Mempos and Fpos for indexed DELETE. */ /***********************************************************************/ -int MPXFAM::InitDelete(PGLOBAL g, int fpos, int spos) +int MPXFAM::InitDelete(PGLOBAL, int fpos, int) { Fpos = Memory + Headlen + (ptrdiff_t)fpos * Lrecl; Mempos = Fpos + Lrecl; @@ -740,7 +740,7 @@ int MPXFAM::ReadBuffer(PGLOBAL g) /***********************************************************************/ /* WriteBuffer: File write routine for MAP access method. */ /***********************************************************************/ -int MPXFAM::WriteBuffer(PGLOBAL g) +int MPXFAM::WriteBuffer(PGLOBAL g __attribute__((unused))) { #if defined(_DEBUG) // Insert mode is no more handled using file mapping diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp index f1fc466a5fc..8afda723578 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -1,11 +1,11 @@ /*********** File AM Dbf C++ Program Source Code File (.CPP) ****************/ /* PROGRAM NAME: FILAMDBF */ /* ------------- */ -/* Version 1.7 */ +/* Version 1.8 */ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -22,12 +22,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> //#include <errno.h> //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -35,7 +35,7 @@ //#include <io.h> #endif // !UNIX //#include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ #include <ctype.h> #include <stdio.h> #include <string.h> @@ -74,28 +74,28 @@ typedef struct _dbfheader { //uchar Dbfox :4; /* FoxPro if equal to 3 */ uchar Version; /* Version information flags */ char Filedate[3]; /* date, YYMMDD, binary. YY=year-1900 */ -private: + private: /* The following four members are stored in little-endian format on disk */ char m_RecordsBuf[4]; /* records in the file */ char m_HeadlenBuf[2]; /* bytes in the header */ char m_ReclenBuf[2]; /* bytes in a record */ char m_FieldsBuf[2]; /* Reserved but used to store fields */ -public: + public: char Incompleteflag; /* 01 if incomplete, else 00 */ char Encryptflag; /* 01 if encrypted, else 00 */ char Reserved2[12]; /* for LAN use */ char Mdxflag; /* 01 if production .mdx, else 00 */ char Language; /* Codepage */ char Reserved3[2]; - - uint Records() const { return uint4korr(m_RecordsBuf); } - ushort Headlen() const { return uint2korr(m_HeadlenBuf); } - ushort Reclen() const { return uint2korr(m_ReclenBuf); } - ushort Fields() const { return uint2korr(m_FieldsBuf); } - - void SetHeadlen(ushort num) { int2store(m_HeadlenBuf, num); } - void SetReclen(ushort num) { int2store(m_ReclenBuf, num); } - void SetFields(ushort num) { int2store(m_FieldsBuf, num); } + + uint Records(void) const {return uint4korr(m_RecordsBuf);} + ushort Headlen(void) const {return uint2korr(m_HeadlenBuf);} + ushort Reclen(void) const {return uint2korr(m_ReclenBuf);} + ushort Fields(void) const {return uint2korr(m_FieldsBuf);} + + void SetHeadlen(ushort num) {int2store(m_HeadlenBuf, num);} + void SetReclen(ushort num) {int2store(m_ReclenBuf, num);} + void SetFields(ushort num) {int2store(m_FieldsBuf, num);} } DBFHEADER; /****************************************************************************/ @@ -410,13 +410,13 @@ int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath) } else if (rc == RC_FX) return -1; - if ((int) header.Reclen() != lrecl) { + if ((int)header.Reclen() != lrecl) { sprintf(g->Message, MSG(BAD_LRECL), lrecl, header.Reclen()); return -1; } // endif Lrecl - Records = (int) header.Records(); - return (int) header.Headlen(); + Records = (int)header.Records(); + return (int)header.Headlen(); } // end of ScanHeader /* ---------------------------- Class DBFFAM ------------------------------ */ @@ -528,7 +528,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen); if (mode == MODE_INSERT) { -#if defined(WIN32) +#if defined(__WIN__) /************************************************************************/ /* Now we can revert to binary mode in particular because the eventual */ /* writing of a new header must be done in binary mode to avoid */ @@ -538,7 +538,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno)); return true; } // endif setmode -#endif // WIN32 +#endif // __WIN__ /************************************************************************/ /* If this is a new file, the header must be generated. */ @@ -577,8 +577,8 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) header->Filedate[0] = datm->tm_year - 100; header->Filedate[1] = datm->tm_mon + 1; header->Filedate[2] = datm->tm_mday; - header->SetHeadlen((ushort) hlen); - header->SetReclen((ushort) reclen); + header->SetHeadlen((ushort)hlen); + header->SetReclen((ushort)reclen); descp = (DESCRIPTOR*)header; // Currently only standard Xbase types are supported @@ -639,13 +639,13 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) DBFHEADER header; if ((rc = dbfhead(g, Stream, Tdbp->GetFile(g), &header)) == RC_OK) { - if (Lrecl != (int) header.Reclen()) { + if (Lrecl != (int)header.Reclen()) { sprintf(g->Message, MSG(BAD_LRECL), Lrecl, header.Reclen()); return true; } // endif Lrecl - Records = (int) header.Records(); - Headlen = (int) header.Headlen(); + Records = (int)header.Records(); + Headlen = (int)header.Headlen(); } else if (rc == RC_NF) { Records = 0; Headlen = 0; @@ -881,9 +881,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort) if ((Stream= global_fopen(g, MSGID_OPEN_MODE_STRERROR, filename, "r+b"))) { char nRecords[4]; - int4store(&nRecords, n); + int4store(nRecords, n); + fseek(Stream, 4, SEEK_SET); // Get header.Records position - fwrite(&nRecords, sizeof(nRecords), 1, Stream); + fwrite(nRecords, sizeof(nRecords), 1, Stream); fclose(Stream); Stream= NULL; Records= n; // Update Records value @@ -958,13 +959,13 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g) /************************************************************************/ DBFHEADER *hp = (DBFHEADER*)Memory; - if (Lrecl != (int) hp->Reclen()) { + if (Lrecl != (int)hp->Reclen()) { sprintf(g->Message, MSG(BAD_LRECL), Lrecl, hp->Reclen()); return true; } // endif Lrecl - Records = (int) hp->Records(); - Headlen = (int) hp->Headlen(); + Records = (int)hp->Records(); + Headlen = (int)hp->Headlen(); } // endif Headlen /**************************************************************************/ diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp index 980d558eee5..cd25429318a 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -34,7 +34,7 @@ #endif // !UNIX #include <sys/stat.h> #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -46,6 +46,7 @@ #include "plgdbsem.h" #include "filamfix.h" #include "tabdos.h" +#include "tabfix.h" #include "osutil.h" #ifndef INVALID_SET_FILE_POINTER @@ -102,7 +103,7 @@ bool FIXFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ /* Initialize CurBlk and CurNum for indexed DELETE. */ /***********************************************************************/ -int FIXFAM::InitDelete(PGLOBAL g, int fpos, int spos) +int FIXFAM::InitDelete(PGLOBAL, int fpos, int) { CurBlk = fpos / Nrec; CurNum = fpos % Nrec; @@ -133,18 +134,35 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g) if (Tdbp->GetFtype() == RECFM_BIN) { // The buffer must be prepared depending on column types int n = 0; + bool b = false; PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); - PCOLDEF cdp; +// PCOLDEF cdp; + PBINCOL colp; // Prepare the first line of the buffer memset(To_Buf, 0, Buflen); +#if 0 for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) { - if (IsTypeNum(cdp->GetType())) - memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen()); + if (!IsTypeNum(cdp->GetType())) { + memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen()); + b = true; + } // endif not num - n = MY_MAX(n, cdp->GetPoff() + cdp->GetClen()); + n = MY_MAX(n, cdp->GetOffset() + cdp->GetClen()); } // endfor cdp +#endif // 0 + + for (colp = (PBINCOL)Tdbp->GetColumns(); colp; + colp = (PBINCOL)colp->GetNext()) + if (!colp->IsSpecial()) { + if (!IsTypeNum(colp->GetResultType())) { + memset(To_Buf + colp->GetDeplac(), ' ', colp->GetLength()); + b = true; + } // endif not num + + n = MY_MAX(n, colp->GetDeplac() + colp->GetFileSize()); + } // endif !special // We do this for binary table because the lrecl can have been // specified with additional space to include line ending. @@ -156,9 +174,10 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g) } // endif n - // Now repeat this for the whole buffer - for (int len = Lrecl; len <= Buflen - Lrecl; len += Lrecl) - memcpy(To_Buf + len, To_Buf, Lrecl); + if (b) + // Now repeat this for the whole buffer + for (int len = Lrecl; len <= Buflen - Lrecl; len += Lrecl) + memcpy(To_Buf + len, To_Buf, Lrecl); } else { memset(To_Buf, ' ', Buflen); @@ -319,10 +338,10 @@ int FIXFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(UNIX) - sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); -#else +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); +#else + sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); #endif if (trace) @@ -659,7 +678,7 @@ BGXFAM::BGXFAM(PBGXFAM txfp) : FIXFAM(txfp) /***********************************************************************/ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org) { -#if defined(WIN32) +#if defined(__WIN__) char buf[256]; DWORD drc; LARGE_INTEGER of; @@ -675,14 +694,14 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org) sprintf(g->Message, MSG(SFP_ERROR), buf); return true; } // endif -#else // !WIN32 +#else // !__WIN__ if (lseek64(h, pos, org) < 0) { // sprintf(g->Message, MSG(ERROR_IN_LSK), errno); sprintf(g->Message, "lseek64: %s", strerror(errno)); printf("%s\n", g->Message); return true; } // endif -#endif // !WIN32 +#endif // !__WIN__ return false; } // end of BigSeek @@ -690,11 +709,12 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org) /***********************************************************************/ /* Read from a big file. */ /***********************************************************************/ -int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) +int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)), + HANDLE h, void *inbuf, int req) { int rc; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbr, drc, len = (DWORD)req; bool brc = ReadFile(h, inbuf, len, &nbr, NULL); @@ -716,12 +736,12 @@ int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = -1; } else rc = (int)nbr; -#else // !WIN32 +#else // !__WIN__ size_t len = (size_t)req; ssize_t nbr = read(h, inbuf, len); rc = (int)nbr; -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of BigRead @@ -733,7 +753,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbw, drc, len = (DWORD)req; bool brc = WriteFile(h, inbuf, len, &nbw, NULL); @@ -760,7 +780,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif brc || nbw -#else // !WIN32 +#else // !__WIN__ size_t len = (size_t)req; ssize_t nbw = write(h, inbuf, len); @@ -775,7 +795,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of BigWrite @@ -810,7 +830,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g) if (trace) htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode); -#if defined(WIN32) +#if defined(__WIN__) DWORD rc, access, creation, share = 0; /*********************************************************************/ @@ -967,7 +987,7 @@ int BGXFAM::Cardinality(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); -#if defined(WIN32) // OB +#if defined(__WIN__) // OB LARGE_INTEGER len; DWORD rc = 0; @@ -1326,7 +1346,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ /* Remove extra records. */ /*****************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) if (BigSeek(g, Hfile, (BIGINT)Tpos * (BIGINT)Lrecl)) return RC_FX; @@ -1336,12 +1356,12 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) sprintf(g->Message, MSG(SETEOF_ERROR), drc); return RC_FX; } // endif error -#else // !WIN32 +#else // !__WIN__ if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); return RC_FX; } // endif -#endif // !WIN32 +#endif // !__WIN__ } // endif UseTemp @@ -1366,7 +1386,7 @@ bool BGXFAM::OpenTempFile(PGLOBAL g) strcat(PlugRemoveType(tempname, tempname), ".t"); remove(tempname); // Be sure it does not exist yet -#if defined(WIN32) +#if defined(__WIN__) Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); @@ -1506,7 +1526,7 @@ void BGXFAM::CloseTableFile(PGLOBAL g, bool abort) void BGXFAM::Rewind(void) { #if 0 // This is probably unuseful because file is accessed directly -#if defined(WIN32) //OB +#if defined(__WIN__) //OB SetFilePointer(Hfile, 0, NULL, FILE_BEGIN); #else // UNIX lseek64(Hfile, 0, SEEK_SET); diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp index eb4e026ee8a..e53cdcd9ba9 100644 --- a/storage/connect/filamtxt.cpp +++ b/storage/connect/filamtxt.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) || defined(UNIV_LINUX) #include <errno.h> #include <unistd.h> @@ -36,7 +36,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -436,7 +436,7 @@ err: /* The purpose of this function is to deal with access methods that */ /* are not coherent regarding the use of SetPos and GetPos. */ /***********************************************************************/ -int TXTFAM::InitDelete(PGLOBAL g, int fpos, int spos) +int TXTFAM::InitDelete(PGLOBAL g, int, int) { strcpy(g->Message, "InitDelete should not be used by this table type"); return RC_FX; @@ -519,7 +519,7 @@ int DOSFAM::Cardinality(PGLOBAL g) /* Use BlockTest to reduce the table estimated size. */ /* Note: This function is not really implemented yet. */ /***********************************************************************/ -int DOSFAM::MaxBlkSize(PGLOBAL g, int s) +int DOSFAM::MaxBlkSize(PGLOBAL, int s) { return s; } // end of MaxBlkSize @@ -716,10 +716,10 @@ int DOSFAM::SkipRecord(PGLOBAL g, bool header) if (feof(Stream)) return RC_EF; -#if defined(UNIX) || defined(UNIV_LINUX) - sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); -#else +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); +#else + sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); #endif return RC_FX; } // endif fgets @@ -799,12 +799,12 @@ int DOSFAM::ReadBuffer(PGLOBAL g) if (trace > 1) htrc(" Read: To_Buf=%p p=%c\n", To_Buf, To_Buf, p); -#if defined(UNIX) - if (true) { - // Data files can be imported from Windows (having CRLF) -#else +#if defined(__WIN__) if (Bin) { // Data file is read in binary so CRLF remains +#else + if (true) { + // Data files can be imported from Windows (having CRLF) #endif if (*p == '\n' || *p == '\r') { // is this enough for Unix ??? @@ -833,10 +833,10 @@ int DOSFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(UNIX) - sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); -#else +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); +#else + sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); #endif if (trace) @@ -1028,15 +1028,15 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ /* Remove extra records. */ /*****************************************************************/ -#if defined(UNIX) - if (ftruncate(h, (off_t)Tpos)) { - sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); +#if defined(__WIN__) + if (chsize(h, Tpos)) { + sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); close(h); return RC_FX; } // endif #else - if (chsize(h, Tpos)) { - sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); + if (ftruncate(h, (off_t)Tpos)) { + sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); close(h); return RC_FX; } // endif @@ -1272,7 +1272,7 @@ int BLKFAM::Cardinality(PGLOBAL g) /***********************************************************************/ /* Use BlockTest to reduce the table estimated size. */ /***********************************************************************/ -int BLKFAM::MaxBlkSize(PGLOBAL g, int s) +int BLKFAM::MaxBlkSize(PGLOBAL g, int) { int rc = RC_OK, savcur = CurBlk; int size; @@ -1343,7 +1343,7 @@ int BLKFAM::GetNextPos(void) /***********************************************************************/ /* SetPos: Replace the table at the specified position. */ /***********************************************************************/ -bool BLKFAM::SetPos(PGLOBAL g, int pos) +bool BLKFAM::SetPos(PGLOBAL g, int) { strcpy(g->Message, "Blocked variable tables cannot be used indexed"); return true; @@ -1353,7 +1353,7 @@ bool BLKFAM::SetPos(PGLOBAL g, int pos) /* Record file position in case of UPDATE or DELETE. */ /* Not used yet for blocked tables. */ /***********************************************************************/ -bool BLKFAM::RecordPos(PGLOBAL g) +bool BLKFAM::RecordPos(PGLOBAL) { Fpos = (CurNum + Nrec * CurBlk); // Computed file index return false; @@ -1362,7 +1362,7 @@ bool BLKFAM::RecordPos(PGLOBAL g) /***********************************************************************/ /* Skip one record in file. */ /***********************************************************************/ -int BLKFAM::SkipRecord(PGLOBAL g, bool header) +int BLKFAM::SkipRecord(PGLOBAL, bool header) { if (header) { // For Delete @@ -1466,10 +1466,10 @@ int BLKFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(UNIX) - sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); -#else +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); +#else + sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); #endif if (trace) @@ -1551,11 +1551,11 @@ int BLKFAM::WriteBuffer(PGLOBAL g) Spos = GetNextPos(); // New start position // Prepare the output buffer -#if defined(WIN32) +#if defined(__WIN__) crlf = "\r\n"; #else crlf = "\n"; -#endif // WIN32 +#endif // __WIN__ strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf); len = strlen(OutBuf); } else { diff --git a/storage/connect/filamtxt.h b/storage/connect/filamtxt.h index 1c8ea1e3a6c..ae8f74a9830 100644 --- a/storage/connect/filamtxt.h +++ b/storage/connect/filamtxt.h @@ -57,8 +57,8 @@ class DllExport TXTFAM : public BLOCK { virtual int GetFileLength(PGLOBAL g); virtual int Cardinality(PGLOBAL g); virtual int MaxBlkSize(PGLOBAL g, int s); - virtual bool AllocateBuffer(PGLOBAL g) {return false;} - virtual void ResetBuffer(PGLOBAL g) {} + virtual bool AllocateBuffer(PGLOBAL) {return false;} + virtual void ResetBuffer(PGLOBAL) {} virtual int GetNerr(void) {return 0;} virtual int GetRowID(void) = 0; virtual bool RecordPos(PGLOBAL g) = 0; diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index e1f11bbf4cf..fdc5433f4a4 100755 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -21,7 +21,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) @@ -29,7 +29,7 @@ #endif // __BORLAND__ //#include <windows.h> #include <sys/stat.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -40,7 +40,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -49,7 +49,7 @@ /* tabdos.h is header containing the TABDOS class declarations. */ /***********************************************************************/ #include "global.h" -#include "osutil.h" // Unuseful for WIN32 +#include "osutil.h" // Unuseful for WINDOWS #include "plgdbsem.h" #include "valblk.h" #include "filamfix.h" @@ -279,7 +279,7 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g) /***********************************************************************/ /* Use BlockTest to reduce the table estimated size. */ /***********************************************************************/ -int VCTFAM::MaxBlkSize(PGLOBAL g, int s) +int VCTFAM::MaxBlkSize(PGLOBAL g, int) { int rc = RC_OK, savcur = CurBlk; int size; @@ -376,11 +376,11 @@ bool VCTFAM::MakeEmptyFile(PGLOBAL g, char *fn) int h, n; PlugSetPath(filename, fn, Tdbp->GetPath()); -#if defined(WIN32) +#if defined(__WIN__) h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE); -#else // !WIN32 +#else // !__WIN__ h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE); -#endif // !WIN32 +#endif // !__WIN__ if (h == -1) return true; @@ -1669,7 +1669,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) // Remove extra blocks n = Block * Blksize; -#if defined(WIN32) +#if defined(__WIN__) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -1716,7 +1716,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Move intermediate deleted or updated lines. */ /***********************************************************************/ -bool VCMFAM::MoveIntermediateLines(PGLOBAL g, bool *b) +bool VCMFAM::MoveIntermediateLines(PGLOBAL, bool *) { int i, m, n; @@ -1765,7 +1765,7 @@ bool VCMFAM::MoveIntermediateLines(PGLOBAL g, bool *b) /***********************************************************************/ /* Data Base close routine for VMP access method. */ /***********************************************************************/ -void VCMFAM::CloseTableFile(PGLOBAL g, bool abort) +void VCMFAM::CloseTableFile(PGLOBAL g, bool) { int wrc = RC_OK; MODE mode = Tdbp->GetMode(); @@ -1800,7 +1800,7 @@ void VCMFAM::CloseTableFile(PGLOBAL g, bool abort) /***********************************************************************/ /* ReadBlock: Read column values from current block. */ /***********************************************************************/ -bool VCMFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) +bool VCMFAM::ReadBlock(PGLOBAL, PVCTCOL colp) { char *mempos; int i = colp->Index - 1; @@ -1830,7 +1830,7 @@ bool VCMFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) /* the mapped file, except when checking for Update but in this case */ /* we do not want to write back the modifications either. */ /***********************************************************************/ -bool VCMFAM::WriteBlock(PGLOBAL g, PVCTCOL colp) +bool VCMFAM::WriteBlock(PGLOBAL, PVCTCOL colp __attribute__((unused))) { #if defined(_DEBUG) char *mempos; @@ -2124,7 +2124,7 @@ bool VECFAM::AllocateBuffer(PGLOBAL g) /***********************************************************************/ /* Do initial action when inserting. */ /***********************************************************************/ -bool VECFAM::InitInsert(PGLOBAL g) +bool VECFAM::InitInsert(PGLOBAL) { // We come here in MODE_INSERT only CurBlk = 0; @@ -2365,7 +2365,7 @@ bool VECFAM::MoveLines(PGLOBAL g) /***********************************************************************/ /* Move intermediate deleted or updated lines. */ /***********************************************************************/ -bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *bn) +bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *) { int i, n; bool b = false; @@ -2574,11 +2574,11 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) char fn[_MAX_PATH]; sprintf(fn, Colfn, colp->Index); -#if defined(WIN32) +#if defined(__WIN__) if (feof(Streams[i])) -#else // !WIN32 +#else // !__WIN__ if (errno == NO_ERROR) -#endif // !WIN32 +#endif // !__WIN__ sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn); else sprintf(g->Message, MSG(READ_ERROR), @@ -2969,7 +2969,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ n = Tpos * Clens[i]; -#if defined(WIN32) +#if defined(__WIN__) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -3009,7 +3009,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for VMP access method. */ /***********************************************************************/ -void VMPFAM::CloseTableFile(PGLOBAL g, bool abort) +void VMPFAM::CloseTableFile(PGLOBAL g, bool) { if (Tdbp->GetMode() == MODE_DELETE) { // Set Block and Nrec values for TDBVCT::MakeBlockValues @@ -3049,7 +3049,7 @@ BGVFAM::BGVFAM(PBGVFAM txfp) : VCTFAM(txfp) /***********************************************************************/ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b) { -#if defined(WIN32) +#if defined(__WIN__) char buf[256]; DWORD drc, m = (b) ? FILE_END : FILE_BEGIN; LARGE_INTEGER of; @@ -3065,12 +3065,12 @@ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b) sprintf(g->Message, MSG(SFP_ERROR), buf); return true; } // endif -#else // !WIN32 +#else // !__WIN__ if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) { sprintf(g->Message, MSG(ERROR_IN_LSK), errno); return true; } // endif -#endif // !WIN32 +#endif // !__WIN__ return false; } // end of BigSeek @@ -3082,7 +3082,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbr, drc, len = (DWORD)req; bool brc = ReadFile(h, inbuf, len, &nbr, NULL); @@ -3108,7 +3108,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif brc || nbr -#else // !WIN32 +#else // !__WIN__ size_t len = (size_t)req; ssize_t nbr = read(h, inbuf, len); @@ -3123,7 +3123,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of BigRead @@ -3135,7 +3135,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbw, drc, len = (DWORD)req; bool brc = WriteFile(h, inbuf, len, &nbw, NULL); @@ -3162,7 +3162,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif brc || nbw -#else // !WIN32 +#else // !__WIN__ size_t len = (size_t)req; ssize_t nbw = write(h, inbuf, len); @@ -3177,7 +3177,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of BigWrite @@ -3203,7 +3203,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) if (Header == 2) strcat(PlugRemoveType(filename, filename), ".blk"); -#if defined(WIN32) +#if defined(__WIN__) LARGE_INTEGER len; h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, @@ -3215,11 +3215,11 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) } // endif h if (h == INVALID_HANDLE_VALUE || !len.QuadPart) { -#else // !WIN32 +#else // !__WIN__ h = open64(filename, O_RDONLY, 0); if (h == INVALID_HANDLE_VALUE || !_filelength(h)) { -#endif // !WIN32 +#endif // !__WIN__ // Consider this is a void table if (trace) htrc("Void table h=%d\n", h); @@ -3280,17 +3280,17 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g) strcat(PlugRemoveType(filename, filename), ".blk"); if (h == INVALID_HANDLE_VALUE) { -#if defined(WIN32) +#if defined(__WIN__) DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING; h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL); -#else // !WIN32 +#else // !__WIN__ int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC; h = open64(filename, oflag, 0); -#endif // !WIN32 +#endif // !__WIN__ if (h == INVALID_HANDLE_VALUE) { sprintf(g->Message, "Error opening header file %s", filename); @@ -3328,7 +3328,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) PlugSetPath(filename, fn, Tdbp->GetPath()); -#if defined(WIN32) +#if defined(__WIN__) char *p; DWORD rc; bool brc; @@ -3380,7 +3380,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) CloseHandle(h); return true; -#else // !WIN32 +#else // !__WIN__ int h; BIGINT pos; @@ -3409,7 +3409,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno)); close(h); return true; -#endif // !WIN32 +#endif // !__WIN__ } // end of MakeEmptyFile /***********************************************************************/ @@ -3440,7 +3440,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g) htrc("OpenTableFile: filename=%s mode=%d Last=%d\n", filename, mode, Last); -#if defined(WIN32) +#if defined(__WIN__) DWORD access, creation, share = 0, rc = 0; /*********************************************************************/ @@ -3766,7 +3766,7 @@ int BGVFAM::WriteBuffer(PGLOBAL g) if (!Closing && !MaxBlk) { // Close the VCT file and reopen it in mode Insert -//#if defined(WIN32) //OB +//#if defined(__WIN__) //OB // CloseHandle(Hfile); //#else // UNIX // close(Hfile); @@ -3893,7 +3893,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) /***************************************************************/ /* Remove extra records. */ /***************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) BIGINT pos = (BIGINT)Block * (BIGINT)Blksize; if (BigSeek(g, Hfile, pos)) @@ -3905,12 +3905,12 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) sprintf(g->Message, MSG(SETEOF_ERROR), drc); return RC_FX; } // endif error -#else // !WIN32 +#else // !__WIN__ if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); return RC_FX; } // endif -#endif // !WIN32 +#endif // !__WIN__ } else // MaxBlk // Clean the unused space in the file, this is required when // inserting again with a partial column list. @@ -3947,7 +3947,7 @@ bool BGVFAM::OpenTempFile(PGLOBAL g) else if (MakeEmptyFile(g, tempname)) return true; -#if defined(WIN32) +#if defined(__WIN__) DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW; Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL, @@ -4218,7 +4218,7 @@ void BGVFAM::Rewind(void) CurNum = Nrec - 1; #if 0 // This is probably unuseful as the file is directly accessed -#if defined(WIN32) //OB +#if defined(__WIN__) //OB SetFilePointer(Hfile, 0, NULL, FILE_BEGIN); #else // UNIX lseek64(Hfile, 0, SEEK_SET); diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp index 1288689325c..56faa555069 100644 --- a/storage/connect/filamzip.cpp +++ b/storage/connect/filamzip.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -17,21 +17,21 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #else // !UNIX #include <io.h> #endif #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -89,11 +89,11 @@ int ZIPFAM::Zerror(PGLOBAL g) strcpy(g->Message, gzerror(Zfile, &errnum)); if (errnum == Z_ERRNO) -#if defined(WIN32) +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL)); -#else // !WIN32 +#else // !__WIN__ sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); -#endif // !WIN32 +#endif // !__WIN__ return (errnum == Z_STREAM_END) ? RC_EF : RC_FX; } // end of Zerror @@ -247,7 +247,7 @@ int ZIPFAM::GetNextPos(void) /***********************************************************************/ /* SetPos: Replace the table at the specified position. */ /***********************************************************************/ -bool ZIPFAM::SetPos(PGLOBAL g, int pos) +bool ZIPFAM::SetPos(PGLOBAL g, int pos __attribute__((unused))) { sprintf(g->Message, MSG(NO_SETPOS_YET), "ZIP"); return true; @@ -267,7 +267,7 @@ bool ZIPFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ /* Record file position in case of UPDATE or DELETE. */ /***********************************************************************/ -bool ZIPFAM::RecordPos(PGLOBAL g) +bool ZIPFAM::RecordPos(PGLOBAL) { Zpos = gztell(Zfile); return false; @@ -376,7 +376,7 @@ int ZIPFAM::WriteBuffer(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for ZDOS access method. (NIY) */ /***********************************************************************/ -int ZIPFAM::DeleteRecords(PGLOBAL g, int irc) +int ZIPFAM::DeleteRecords(PGLOBAL g, int) { strcpy(g->Message, MSG(NO_ZIP_DELETE)); return RC_FX; @@ -385,7 +385,7 @@ int ZIPFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for DOS access method. */ /***********************************************************************/ -void ZIPFAM::CloseTableFile(PGLOBAL g, bool abort) +void ZIPFAM::CloseTableFile(PGLOBAL, bool) { int rc = gzclose(Zfile); @@ -431,7 +431,7 @@ ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp) /***********************************************************************/ /* Use BlockTest to reduce the table estimated size. */ /***********************************************************************/ -int ZBKFAM::MaxBlkSize(PGLOBAL g, int s) +int ZBKFAM::MaxBlkSize(PGLOBAL g, int) { int rc = RC_OK, savcur = CurBlk; int size; @@ -503,7 +503,7 @@ int ZBKFAM::GetPos(void) /* Record file position in case of UPDATE or DELETE. */ /* Not used yet for fixed tables. */ /***********************************************************************/ -bool ZBKFAM::RecordPos(PGLOBAL g) +bool ZBKFAM::RecordPos(PGLOBAL /*g*/) { //strcpy(g->Message, "RecordPos not implemented for zip blocked tables"); //return true; @@ -513,7 +513,7 @@ bool ZBKFAM::RecordPos(PGLOBAL g) /***********************************************************************/ /* Skip one record in file. */ /***********************************************************************/ -int ZBKFAM::SkipRecord(PGLOBAL g, bool header) +int ZBKFAM::SkipRecord(PGLOBAL /*g*/, bool) { //strcpy(g->Message, "SkipRecord not implemented for zip blocked tables"); //return RC_FX; @@ -668,7 +668,7 @@ int ZBKFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for ZBK access method. */ /***********************************************************************/ -void ZBKFAM::CloseTableFile(PGLOBAL g, bool abort) +void ZBKFAM::CloseTableFile(PGLOBAL g, bool) { int rc = RC_OK; @@ -764,9 +764,9 @@ bool ZIXFAM::AllocateBuffer(PGLOBAL g) if (Tdbp->GetFtype() < 2) // if not binary, the file is physically a text file for (int len = Lrecl; len <= Buflen; len += Lrecl) { -#if defined(WIN32) +#if defined(__WIN__) To_Buf[len - 2] = '\r'; -#endif // WIN32 +#endif // __WIN__ To_Buf[len - 1] = '\n'; } // endfor len @@ -1060,7 +1060,7 @@ int ZLBFAM::GetNextPos(void) /***********************************************************************/ /* SetPos: Replace the table at the specified position. */ /***********************************************************************/ -bool ZLBFAM::SetPos(PGLOBAL g, int pos) +bool ZLBFAM::SetPos(PGLOBAL g, int pos __attribute__((unused))) { sprintf(g->Message, MSG(NO_SETPOS_YET), "ZIP"); return true; @@ -1350,7 +1350,7 @@ bool ZLBFAM::WriteCompressedBuffer(PGLOBAL g) /***********************************************************************/ /* Table file close routine for DOS access method. */ /***********************************************************************/ -void ZLBFAM::CloseTableFile(PGLOBAL g, bool abort) +void ZLBFAM::CloseTableFile(PGLOBAL g, bool) { int rc = RC_OK; diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index 949d49c2943..262d6b58a70 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -13,13 +13,13 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include <string.h> #include <sys/types.h> #include <sys/stat.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ diff --git a/storage/connect/filter.h b/storage/connect/filter.h index 78e066d9ab7..15730e2cc44 100644 --- a/storage/connect/filter.h +++ b/storage/connect/filter.h @@ -1,7 +1,7 @@ /*************** Filter H Declares Source Code File (.H) ***************/ /* Name: FILTER.H Version 1.2 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2010-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 2010-2015 */ /* */ /* This file contains the FILTER and derived classes declares. */ /***********************************************************************/ @@ -105,8 +105,8 @@ class FILTERX : public FILTER { virtual bool Eval(PGLOBAL) = 0; // just to prevent direct FILTERX use // Fake operator new used to change a filter into a derived filter - void * operator new(size_t size, PFIL filp) {return filp;} -#if defined(WIN32) + void * operator new(size_t, PFIL filp) {return filp;} +#if defined(__WIN__) // Avoid warning C4291 by defining a matching dummy delete operator void operator delete(void *, PFIL) {} #else diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index a72a2b9b31e..22c3a1e79ad 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -20,11 +20,12 @@ */ #define FLEX_SCANNER -#if WIN32 +#ifdef __WIN__ #define __STDC__ 1 +#define isatty _isatty #endif #include <stdio.h> -#ifndef WIN32 +#ifndef __WIN__ #include <unistd.h> #endif diff --git a/storage/connect/global.h b/storage/connect/global.h index 10564d09815..4d01a3ff05b 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -13,11 +13,11 @@ #include <time.h> /* time_t type declaration */ #include <setjmp.h> /* Long jump declarations */ -#if defined(WIN32) && !defined(NOEX) +#if defined(__WIN__) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !WIN32 +#else // !__WIN__ #define DllExport -#endif // !WIN32 +#endif // !__WIN__ #if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT) #define XML_SUPPORT 1 @@ -42,11 +42,11 @@ #define STEP(I) MSG_##I #endif // !XMSG and !NEWMSG -#if defined(WIN32) +#if defined(__WIN__) #define CRLF 2 -#else // !WIN32 +#else // !__WIN__ #define CRLF 1 -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Define access to the thread based trace value. */ @@ -104,7 +104,7 @@ #define SYS_STAMP "DOSR" #elif defined(WIN) #define SYS_STAMP "WIN1" -#elif defined(WIN32) +#elif defined(__WIN__) #define SYS_STAMP "WIN2" #else #define SYS_STAMP "XXXX" @@ -248,9 +248,9 @@ DllExport char *PlugReadMessage(PGLOBAL, int, char *); #elif defined(NEWMSG) DllExport char *PlugGetMessage(PGLOBAL, int); #endif // XMSG || NEWMSG -#if defined(WIN32) +#if defined(__WIN__) DllExport short GetLineLength(PGLOBAL); // Console line length -#endif // WIN32 +#endif // __WIN__ DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization DllExport int PlugExit(PGLOBAL); // Plug global termination DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 765c04bd2be..c2fb6481cb0 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -138,10 +138,10 @@ #include "reldef.h" #include "tabcol.h" #include "xindex.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include "tabwmi.h" -#endif // WIN32 +#endif // __WIN__ #include "connect.h" #include "user_connect.h" #include "ha_connect.h" @@ -153,6 +153,7 @@ #endif // LIBXML2_SUPPORT #include "taboccur.h" #include "tabpivot.h" +#include "tabfix.h" #define my_strupr(p) my_caseup_str(default_charset_info, (p)); #define my_strlwr(p) my_casedn_str(default_charset_info, (p)); @@ -168,13 +169,13 @@ #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.03.0007 April 30, 2015"; -#if defined(WIN32) + char version[]= "Version 1.03.0007 June 03, 2015"; +#if defined(__WIN__) char compver[]= "Version 1.03.0007 " __DATE__ " " __TIME__; char slash= '\\'; -#else // !WIN32 +#else // !__WIN__ char slash= '/'; -#endif // !WIN32 +#endif // !__WIN__ } // extern "C" #if defined(XMAP) @@ -193,10 +194,9 @@ extern "C" { /* Utility functions. */ /***********************************************************************/ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); -PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info); -PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, - int pretty, int lvl, int mxr, bool info); -PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info); +PQRYRES VirColumns(PGLOBAL g, bool info); +PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info); +PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info); void PushWarning(PGLOBAL g, THD *thd, int level); bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host, const char *db, char *tab, const char *src, int port); @@ -349,7 +349,7 @@ int GetConvSize(void) {return THDVAR(current_thd, conv_size);} TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);} uint GetJsonGrpSize(void) {return THDVAR(current_thd, json_grp_size);} uint GetWorkSize(void) {return THDVAR(current_thd, work_size);} -void SetWorkSize(uint n) +void SetWorkSize(uint) { // Changing the session variable value seems to be impossible here // and should be done in a check function @@ -629,11 +629,11 @@ static int connect_init_func(void *p) } #endif // 0 (LINUX) -#if defined(WIN32) +#if defined(__WIN__) sql_print_information("CONNECT: %s", compver); -#else // !WIN32 +#else // !__WIN__ sql_print_information("CONNECT: %s", version); -#endif // !WIN32 +#endif // !__WIN__ #ifdef LIBXML2_SUPPORT XmlInitParserLib(); @@ -656,6 +656,7 @@ static int connect_init_func(void *p) sql_print_information("connect_init: hton=%p", p); DTVAL::SetTimeShift(); // Initialize time zone shift once for all + BINCOL::SetEndian(); // Initialize host endian setting DBUG_RETURN(0); } // end of connect_init_func @@ -664,7 +665,7 @@ static int connect_init_func(void *p) @brief Plugin clean up */ -static int connect_done_func(void *p) +static int connect_done_func(void *) { int error= 0; PCONNECT pc, pn; @@ -674,9 +675,9 @@ static int connect_done_func(void *p) XmlCleanupParserLib(); #endif // LIBXML2_SUPPORT -#if !defined(WIN32) +#if !defined(__WIN__) //PROFILE_End(); Causes signal 11 -#endif // !WIN32 +#endif // !__WIN__ for (pc= user_connect::to_users; pc; pc= pn) { if (pc->g) @@ -743,11 +744,11 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) xp= (table) ? GetUser(ha_thd(), NULL) : NULL; if (xp) xp->SetHandler(this); -#if defined(WIN32) +#if defined(__WIN__) datapath= ".\\"; -#else // !WIN32 +#else // !__WIN__ datapath= "./"; -#endif // !WIN32 +#endif // !__WIN__ tdbp= NULL; sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL; sdvalout= NULL; @@ -822,8 +823,6 @@ ha_connect::~ha_connect(void) /****************************************************************************/ static PCONNECT GetUser(THD *thd, PCONNECT xp) { - const char *dbn= NULL; - if (!thd) return NULL; @@ -835,7 +834,7 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp) break; if (!xp) { - xp= new user_connect(thd, dbn); + xp= new user_connect(thd); if (xp->user_init()) { delete xp; @@ -908,7 +907,8 @@ const char *ha_connect::index_type(uint inx) If all_parts is set, MySQL wants to know the flags for the combined index, up to and including 'part'. */ -ulong ha_connect::index_flags(uint inx, uint part, bool all_parts) const +//ong ha_connect::index_flags(uint inx, uint part, bool all_parts) const +ulong ha_connect::index_flags(uint, uint, bool) const { ulong flags= HA_READ_NEXT | HA_READ_RANGE | HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR; @@ -1017,6 +1017,117 @@ char *GetListOption(PGLOBAL g, const char *opname, } // end of GetListOption /****************************************************************************/ +/* Return the value of a string option or NULL if not specified. */ +/****************************************************************************/ +char *GetStringTableOption(PGLOBAL g, PTOS options, char *opname, char *sdef) +{ + const char *opval= NULL; + + if (!options) + return sdef; + else if (!stricmp(opname, "Type")) + opval= options->type; + else if (!stricmp(opname, "Filename")) + opval= options->filename; + else if (!stricmp(opname, "Optname")) + opval= options->optname; + else if (!stricmp(opname, "Tabname")) + opval= options->tabname; + else if (!stricmp(opname, "Tablist")) + opval= options->tablist; + else if (!stricmp(opname, "Database") || + !stricmp(opname, "DBname")) + opval= options->dbname; + else if (!stricmp(opname, "Separator")) + opval= options->separator; + else if (!stricmp(opname, "Qchar")) + opval= options->qchar; + else if (!stricmp(opname, "Module")) + opval= options->module; + else if (!stricmp(opname, "Subtype")) + opval= options->subtype; + else if (!stricmp(opname, "Catfunc")) + opval= options->catfunc; + else if (!stricmp(opname, "Srcdef")) + opval= options->srcdef; + else if (!stricmp(opname, "Colist")) + opval= options->colist; + else if (!stricmp(opname, "Data_charset")) + opval= options->data_charset; + + if (!opval && options && options->oplist) + opval= GetListOption(g, opname, options->oplist); + + return opval ? (char*)opval : sdef; +} // end of GetStringTableOption + +/****************************************************************************/ +/* Return the value of a Boolean option or bdef if not specified. */ +/****************************************************************************/ +bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef) +{ + bool opval= bdef; + char *pv; + + if (!options) + return bdef; + else if (!stricmp(opname, "Mapped")) + opval= options->mapped; + else if (!stricmp(opname, "Huge")) + opval= options->huge; + else if (!stricmp(opname, "Split")) + opval= options->split; + else if (!stricmp(opname, "Readonly")) + opval= options->readonly; + else if (!stricmp(opname, "SepIndex")) + opval= options->sepindex; + else if (!stricmp(opname, "Header")) + opval= (options->header != 0); // Is Boolean for some table types + else if (options->oplist) + if ((pv= GetListOption(g, opname, options->oplist))) + opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0); + + return opval; +} // end of GetBooleanTableOption + +/****************************************************************************/ +/* Return the value of an integer option or NO_IVAL if not specified. */ +/****************************************************************************/ +int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef) +{ + ulonglong opval= NO_IVAL; + + if (!options) + return idef; + else if (!stricmp(opname, "Lrecl")) + opval= options->lrecl; + else if (!stricmp(opname, "Elements")) + opval= options->elements; + else if (!stricmp(opname, "Multiple")) + opval= options->multiple; + else if (!stricmp(opname, "Header")) + opval= options->header; + else if (!stricmp(opname, "Quoted")) + opval= options->quoted; + else if (!stricmp(opname, "Ending")) + opval= options->ending; + else if (!stricmp(opname, "Compressed")) + opval= (options->compressed); + + if (opval == NO_IVAL) { + char *pv; + + if ((pv= GetListOption(g, opname, options->oplist))) + opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true); + else + return idef; + + } // endif opval + + return (int)opval; +} // end of GetIntegerTableOption + +/****************************************************************************/ /* Return the table option structure. */ /****************************************************************************/ PTOS ha_connect::GetTableOptionStruct(TABLE_SHARE *s) @@ -1034,9 +1145,6 @@ char *ha_connect::GetRealString(const char *s) char *sv; if (IsPartitioned() && s) { -// sv= (char*)PlugSubAlloc(xp->g, NULL, strlen(s) + strlen(partname)); - // With wrong string pattern, the size of the constructed string - // can be more than strlen(s) + strlen(partname) sv= (char*)PlugSubAlloc(xp->g, NULL, 0); sprintf(sv, s, partname); PlugSubAlloc(xp->g, NULL, strlen(sv) + 1); @@ -1047,7 +1155,7 @@ char *ha_connect::GetRealString(const char *s) } // end of GetRealString /****************************************************************************/ -/* Return the value of a string option or NULL if not specified. */ +/* Return the value of a string option or sdef if not specified. */ /****************************************************************************/ char *ha_connect::GetStringOption(char *opname, char *sdef) { @@ -1065,37 +1173,6 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) opval= thd_query_string(table->in_use)->str; else if (!stricmp(opname, "Partname")) opval= partname; - else if (!options) - ; - else if (!stricmp(opname, "Type")) - opval= (char*)options->type; - else if (!stricmp(opname, "Filename")) - opval= GetRealString(options->filename); - else if (!stricmp(opname, "Optname")) - opval= (char*)options->optname; - else if (!stricmp(opname, "Tabname")) - opval= GetRealString(options->tabname); - else if (!stricmp(opname, "Tablist")) - opval= (char*)options->tablist; - else if (!stricmp(opname, "Database") || - !stricmp(opname, "DBname")) - opval= (char*)options->dbname; - else if (!stricmp(opname, "Separator")) - opval= (char*)options->separator; - else if (!stricmp(opname, "Qchar")) - opval= (char*)options->qchar; - else if (!stricmp(opname, "Module")) - opval= (char*)options->module; - else if (!stricmp(opname, "Subtype")) - opval= (char*)options->subtype; - else if (!stricmp(opname, "Catfunc")) - opval= (char*)options->catfunc; - else if (!stricmp(opname, "Srcdef")) - opval= (char*)options->srcdef; - else if (!stricmp(opname, "Colist")) - opval= (char*)options->colist; - else if (!stricmp(opname, "Data_charset")) - opval= (char*)options->data_charset; else if (!stricmp(opname, "Table_charset")) { const CHARSET_INFO *chif= (tshp) ? tshp->table_charset : table->s->table_charset; @@ -1103,17 +1180,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) if (chif) opval= (char*)chif->csname; - } // endif Table_charset - - if (!opval && options && options->oplist) { - opval= GetListOption(xp->g, opname, options->oplist); - - if (opval && (!stricmp(opname, "connect") - || !stricmp(opname, "tabname") - || !stricmp(opname, "filename"))) - opval = GetRealString(opval); + } else + opval= GetStringTableOption(xp->g, options, opname, NULL); - } // endif opval + if (opval && (!stricmp(opname, "connect") + || !stricmp(opname, "tabname") + || !stricmp(opname, "filename"))) + opval = GetRealString(opval); if (!opval) { if (sdef && !strcmp(sdef, "*")) { @@ -1144,31 +1217,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) /****************************************************************************/ bool ha_connect::GetBooleanOption(char *opname, bool bdef) { - bool opval= bdef; - char *pv; + bool opval; PTOS options= GetTableOptionStruct(); if (!stricmp(opname, "View")) opval= (tshp) ? tshp->is_view : table_share->is_view; - else if (!options) - ; - else if (!stricmp(opname, "Mapped")) - opval= options->mapped; - else if (!stricmp(opname, "Huge")) - opval= options->huge; -//else if (!stricmp(opname, "Compressed")) -// opval= options->compressed; - else if (!stricmp(opname, "Split")) - opval= options->split; - else if (!stricmp(opname, "Readonly")) - opval= options->readonly; - else if (!stricmp(opname, "SepIndex")) - opval= options->sepindex; - else if (!stricmp(opname, "Header")) - opval= (options->header != 0); // Is Boolean for some table types - else if (options->oplist) - if ((pv= GetListOption(xp->g, opname, options->oplist))) - opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0); + else + opval= GetBooleanTableOption(xp->g, options, opname, bdef); return opval; } // end of GetBooleanOption @@ -1197,37 +1252,18 @@ bool ha_connect::SetBooleanOption(char *opname, bool b) /****************************************************************************/ int ha_connect::GetIntegerOption(char *opname) { - ulonglong opval= NO_IVAL; - char *pv; + int opval; PTOS options= GetTableOptionStruct(); TABLE_SHARE *tsp= (tshp) ? tshp : table_share; if (!stricmp(opname, "Avglen")) - opval= (ulonglong)tsp->avg_row_length; + opval= (int)tsp->avg_row_length; else if (!stricmp(opname, "Estimate")) - opval= (ulonglong)tsp->max_rows; - else if (!options) - ; - else if (!stricmp(opname, "Lrecl")) - opval= options->lrecl; - else if (!stricmp(opname, "Elements")) - opval= options->elements; - else if (!stricmp(opname, "Multiple")) - opval= options->multiple; - else if (!stricmp(opname, "Header")) - opval= options->header; - else if (!stricmp(opname, "Quoted")) - opval= options->quoted; - else if (!stricmp(opname, "Ending")) - opval= options->ending; - else if (!stricmp(opname, "Compressed")) - opval= (options->compressed); - - if (opval == (ulonglong)NO_IVAL && options && options->oplist) - if ((pv= GetListOption(xp->g, opname, options->oplist))) - opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true); + opval= (int)tsp->max_rows; + else + opval= GetIntegerTableOption(xp->g, options, opname, NO_IVAL); - return (int)opval; + return opval; } // end of GetIntegerOption /****************************************************************************/ @@ -2008,7 +2044,7 @@ int ha_connect::MakeRecord(char *buf) /***********************************************************************/ /* Set row values from a MySQL pseudo record. Specific to MySQL. */ /***********************************************************************/ -int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) +int ha_connect::ScanRecord(PGLOBAL g, uchar *) { char attr_buffer[1024]; char data_buffer[1024]; @@ -2150,7 +2186,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) /* Check change in index column. Specific to MySQL. */ /* Should be elaborated to check for real changes. */ /***********************************************************************/ -int ha_connect::CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf) +int ha_connect::CheckRecord(PGLOBAL g, const uchar *, uchar *newbuf) { return ScanRecord(g, newbuf); } // end of dummy CheckRecord @@ -2923,7 +2959,7 @@ bool ha_connect::get_error_message(int error, String* buf) &dummy_errors); if (trace) - htrc("GEM(%u): %s\n", len, g->Message); + htrc("GEM(%d): len=%u %s\n", error, len, g->Message); msg[len]= '\0'; buf->copy(msg, (uint)strlen(msg), system_charset_info); @@ -3019,7 +3055,7 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked) @brief Make the indexes for this table */ -int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt) +int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) { int rc= 0; PGLOBAL& g= xp->g; @@ -3223,7 +3259,7 @@ int ha_connect::update_row(const uchar *old_data, uchar *new_data) @see sql_acl.cc, sql_udf.cc, sql_delete.cc, sql_insert.cc and sql_select.cc */ -int ha_connect::delete_row(const uchar *buf) +int ha_connect::delete_row(const uchar *) { int rc= 0; DBUG_ENTER("ha_connect::delete_row"); @@ -3503,7 +3539,8 @@ int ha_connect::index_last(uchar *buf) /****************************************************************************/ /* This is called to get more rows having the same index value. */ /****************************************************************************/ -int ha_connect::index_next_same(uchar *buf, const uchar *key, uint keylen) +//t ha_connect::index_next_same(uchar *buf, const uchar *key, uint keylen) +int ha_connect::index_next_same(uchar *buf, const uchar *, uint) { int rc; DBUG_ENTER("ha_connect::index_next_same"); @@ -3693,7 +3730,7 @@ int ha_connect::rnd_next(uchar *buf) @see filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc */ -void ha_connect::position(const uchar *record) +void ha_connect::position(const uchar *) { DBUG_ENTER("ha_connect::position"); //if (((PTDBASE)tdbp)->GetDef()->Indexable()) @@ -3876,7 +3913,7 @@ int ha_connect::info(uint flag) @see ha_innodb.cc */ -int ha_connect::extra(enum ha_extra_function operation) +int ha_connect::extra(enum ha_extra_function /*operation*/) { DBUG_ENTER("ha_connect::extra"); DBUG_RETURN(0); @@ -3955,11 +3992,11 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn) case TAB_JSON: if (options->filename && *options->filename) { char *s, path[FN_REFLEN], dbpath[FN_REFLEN]; -#if defined(WIN32) +#if defined(__WIN__) s= "\\"; -#else // !WIN32 +#else // !__WIN__ s= "/"; -#endif // !WIN32 +#endif // !__WIN__ strcpy(dbpath, mysql_real_data_home); if (db) @@ -4484,7 +4521,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) @see get_lock_data() in lock.cc */ -THR_LOCK_DATA **ha_connect::store_lock(THD *thd, +THR_LOCK_DATA **ha_connect::store_lock(THD *, THR_LOCK_DATA **to, enum thr_lock_type lock_type) { @@ -4718,6 +4755,9 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, else rows= HA_POS_ERROR; + if (trace) + htrc("records_in_range: rows=%llu\n", rows); + DBUG_RETURN(rows); } // end of records_in_range @@ -4901,7 +4941,7 @@ static int init_table_share(THD* thd, oom|= sql->append(' '); oom|= sql->append(opt->name); oom|= sql->append('='); - oom|= sql->append(vull ? "ON" : "OFF"); + oom|= sql->append(vull ? "YES" : "NO"); } // endif vull break; @@ -4955,7 +4995,7 @@ static int init_table_share(THD* thd, @note this function is no more called in case of CREATE .. SELECT */ -static int connect_assisted_discovery(handlerton *hton, THD* thd, +static int connect_assisted_discovery(handlerton *, THD* thd, TABLE_SHARE *table_s, HA_CREATE_INFO *create_info) { @@ -4963,12 +5003,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, const char *fncn= "?"; const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src; const char *col, *ocl, *rnk, *pic, *fcl, *skc; - char *tab, *dsn, *shm, *dpath, *objn; -#if defined(WIN32) + char *tab, *dsn, *shm, *dpath; +#if defined(__WIN__) char *nsp= NULL, *cls= NULL; -#endif // WIN32 - int port= 0, hdr= 0, mxr __attribute__((unused))= 0, mxe= 0, rc= 0; - int cop __attribute__((unused))= 0, pty= 2, lrecl= 0, lvl= 0; +#endif // __WIN__ + int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0; + int cop __attribute__((unused))= 0, lrecl= 0; #if defined(ODBC_SUPPORT) POPARM sop = NULL; char *ucnc = NULL; @@ -4998,7 +5038,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, if (!g) return HA_ERR_INTERNAL_ERROR; - user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= objn= NULL; + user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= NULL; // Get the useful create options ttp= GetTypeID(topt->type); @@ -5029,11 +5069,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, skc= GetListOption(g, "skipcol", topt->oplist, NULL); rnk= GetListOption(g, "rankcol", topt->oplist, NULL); pwd= GetListOption(g, "password", topt->oplist); - objn= GetListOption(g, "Object", topt->oplist, NULL); -#if defined(WIN32) +#if defined(__WIN__) nsp= GetListOption(g, "namespace", topt->oplist); cls= GetListOption(g, "class", topt->oplist); -#endif // WIN32 +#endif // __WIN__ port= atoi(GetListOption(g, "port", topt->oplist, "0")); #if defined(ODBC_SUPPORT) mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0")); @@ -5047,8 +5086,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, #if defined(PROMPT_OK) cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0")); #endif // PROMPT_OK - pty= atoi(GetListOption(g,"Pretty", topt->oplist, "2")); - lvl= atoi(GetListOption(g,"Level", topt->oplist, "0")); } else { host= "localhost"; user= (ttp == TAB_ODBC ? NULL : "root"); @@ -5192,11 +5229,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= false; break; -#if defined(WIN32) +#if defined(__WIN__) case TAB_WMI: ok= true; break; -#endif // WIN32 +#endif // __WIN__ #if defined(PIVOT_SUPPORT) case TAB_PIVOT: supfnc= FNC_NO; @@ -5309,11 +5346,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, case TAB_CSV: qrp= CSVColumns(g, dpath, fn, spc, qch, hdr, mxe, fnc == FNC_COL); break; -#if defined(WIN32) +#if defined(__WIN__) case TAB_WMI: qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL); break; -#endif // WIN32 +#endif // __WIN__ case TAB_PRX: case TAB_TBL: case TAB_XCL: @@ -5337,10 +5374,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, break; #endif // PIVOT_SUPPORT case TAB_VIR: - qrp= VirColumns(g, tab, (char*)db, fnc == FNC_COL); + qrp= VirColumns(g, fnc == FNC_COL); break; case TAB_JSON: - qrp= JSONColumns(g, (char*)db, fn, objn, pty, lrecl, lvl, fnc == FNC_COL); + qrp= JSONColumns(g, (char*)db, topt, fnc == FNC_COL); break; #if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT) case TAB_XML: @@ -5489,10 +5526,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, #if defined(ODBC_SUPPORT) if (ttp == TAB_ODBC) { - int plgtyp; + int plgtyp; + bool w= false; // Wide character type // typ must be PLG type, not SQL type - if (!(plgtyp= TranslateSQLType(typ, dec, prec, v))) { + if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) { if (GetTypeConv() == TPC_SKIP) { // Skip this column sprintf(g->Message, "Column %s skipped (unsupported type %d)", @@ -5509,6 +5547,13 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, typ= plgtyp; switch (typ) { + case TYPE_STRING: + if (w) { + sprintf(g->Message, "Column %s is wide characters", cnm); + push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message); + } // endif w + + break; case TYPE_DOUBLE: // Some data sources do not count dec in length (prec) prec += (dec + 2); // To be safe @@ -5767,11 +5812,11 @@ int ha_connect::create(const char *name, TABLE *table_arg, // on Windows and libxml2 otherwise switch (*xsup) { case '*': -#if defined(WIN32) +#if defined(__WIN__) dom= true; -#else // !WIN32 +#else // !__WIN__ dom= false; -#endif // !WIN32 +#endif // !__WIN__ break; case 'M': case 'D': @@ -6118,11 +6163,11 @@ bool ha_connect::FileExists(const char *fn, bool bf) NULL, NULL, 0, 0)) return true; -#if defined(WIN32) +#if defined(__WIN__) s= "\\"; -#else // !WIN32 +#else // !__WIN__ s= "/"; -#endif // !WIN32 +#endif // !__WIN__ if (IsPartitioned()) { sprintf(tfn, fn, GetPartName()); @@ -6464,8 +6509,7 @@ fin: @note: This function is no more called by check_if_supported_inplace_alter */ -bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info, - uint table_changes) +bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *, uint) { DBUG_ENTER("ha_connect::check_if_incompatible_data"); // TO DO: really implement and check it. @@ -6607,7 +6651,7 @@ maria_declare_plugin(connect) 0x0103, /* version number (1.03) */ NULL, /* status variables */ connect_system_variables, /* system variables */ - "1.03.0006", /* string version */ + "1.03.0007", /* string version */ MariaDB_PLUGIN_MATURITY_BETA /* maturity */ } maria_declare_plugin_end; diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index 1e597f751ca..3d03bea5d00 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -23,7 +23,7 @@ #define ARGS MY_MIN(24,len-i),s+MY_MAX(i-3,0) -#if defined(WIN32) +#if defined(__WIN__) #define EL "\r\n" #else #define EL "\n" diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 1afd79bec05..ff4025ee0fb 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -296,7 +296,7 @@ my_bool Json_Value_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Value_init char *Json_Value(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; PJVAL jvp; @@ -329,7 +329,7 @@ my_bool Json_Array_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Array_init char *Json_Array(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; uint i; @@ -376,7 +376,7 @@ my_bool Json_Array_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Array_Add_init char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; PJVAL jvp; @@ -410,7 +410,7 @@ void Json_Array_Add_deinit(UDF_INIT* initid) } // end of Json_Array_Add_deinit /***********************************************************************/ -/* Add values to a Json array. */ +/* Delete a value from a Json array. */ /***********************************************************************/ my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { @@ -429,7 +429,7 @@ my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Array_Delete_init char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; int n; @@ -451,7 +451,7 @@ char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, } else { n = *(int*)args->args[1]; arp = jvp->GetArray(); - arp->DeleteValue(n - 1); + arp->DeleteValue(n); arp->InitArray(g); if (!(str = Serialize(g, arp, NULL, 0))) { @@ -482,7 +482,7 @@ my_bool Json_Object_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Object_init char *Json_Object(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; uint i; @@ -520,7 +520,7 @@ my_bool Json_Object_Nonull_init(UDF_INIT *initid, UDF_ARGS *args, } // end of Json_Object_Nonull_init char *Json_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; uint i; @@ -574,8 +574,7 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) return false; } // end of Json_Array_Grp_init -void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, - char *is_null, char *error) +void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; PJAR arp = (PJAR)g->Activityp; @@ -585,8 +584,8 @@ void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, } // end of Json_Array_Grp_add -char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) +char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *, char *result, + unsigned long *res_length, char *, char *) { char *str; PGLOBAL g = (PGLOBAL)initid->ptr; @@ -605,7 +604,7 @@ char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result, return str; } // end of Json_Array_Grp -void Json_Array_Grp_clear(UDF_INIT *initid, char *is_null, char *error) +void Json_Array_Grp_clear(UDF_INIT *initid, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; @@ -646,8 +645,7 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) return false; } // end of Json_Object_Grp_init -void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, - char *is_null, char *error) +void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; PJOB objp = (PJOB)g->Activityp; @@ -657,8 +655,8 @@ void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, } // end of Json_Object_Grp_add -char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) +char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *, char *result, + unsigned long *res_length, char *, char *) { char *str; PGLOBAL g = (PGLOBAL)initid->ptr; @@ -675,7 +673,7 @@ char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result, return str; } // end of Json_Object_Grp -void Json_Object_Grp_clear(UDF_INIT *initid, char *is_null, char *error) +void Json_Object_Grp_clear(UDF_INIT *initid, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 7d1d014c48b..c2882fc0d7c 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -533,8 +533,8 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn) // This function does not crash ( if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) { xmlErrorPtr err = xmlGetLastError(); - strcpy(g->Message, (err) ? err->message : "Error saving XML doc"); + xmlResetError(Xerr); rc = -1; } // endif Save // rc = xmlDocDump(of, Docp); @@ -569,6 +569,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp) htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0); //if (xp && xp->Count == 1) { + if (xp) { if (Nlist) { xmlXPathFreeNodeSet(Nlist); @@ -605,7 +606,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp) Ctxp = NULL; } // endif Ctxp -// } // endif Count + } // endif xp CloseXML2File(g, xp, false); } // end of Close diff --git a/storage/connect/macutil.cpp b/storage/connect/macutil.cpp index 4d3022b91b6..f5d3bb11fe9 100644 --- a/storage/connect/macutil.cpp +++ b/storage/connect/macutil.cpp @@ -2,11 +2,11 @@ /* MACUTIL: Author Olivier Bertrand -- 2008-2012 */ /* From the article and sample code by Khalid Shaikh. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) #include "my_global.h" -#else // !WIN32 -#error This is WIN32 only DLL -#endif // !WIN32 +#else // !__WIN__ +#error This is WINDOWS only DLL +#endif // !__WIN__ #include "global.h" #include "plgdbsem.h" #include "macutil.h" diff --git a/storage/connect/macutil.h b/storage/connect/macutil.h index 8a3e97e12e1..c80bd58e20a 100644 --- a/storage/connect/macutil.h +++ b/storage/connect/macutil.h @@ -1,10 +1,10 @@ // MACUTIL.H Olivier Bertrand 2008-2012 // Get Mac Addresses via GetAdaptersInfo -#if defined(WIN32) +#if defined(__WIN__) #include <iphlpapi.h> -#else // !WIN32 -#error This is WIN32 only -#endif // !WIN32 +#else // !__WIN__ +#error This is WINDOWS only +#endif // !__WIN__ #include "block.h" typedef class MACINFO *MACIP; diff --git a/storage/connect/maputil.cpp b/storage/connect/maputil.cpp index 97c638b4254..c4e016f1511 100644 --- a/storage/connect/maputil.cpp +++ b/storage/connect/maputil.cpp @@ -14,7 +14,7 @@ #include "plgdbsem.h" #include "maputil.h" -#ifdef WIN32 +#ifdef __WIN__ /***********************************************************************/ /* In Insert mode, just open the file for append. Otherwise */ /* create the mapping file object. The map handle can be released */ diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index b15c8fa2322..9c72e9cd665 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2014 +/* Copyright (C) Olivier Bertrand 2004 - 2015 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ /* ------------- */ /* Version 1.4 */ /* */ -/* Author: Olivier Bertrand 2012 - 2014 */ +/* Author: Olivier Bertrand 2012 - 2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -30,7 +30,7 @@ /***********************************************************************/ #include <my_config.h> -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> //#include <sqlext.h> #elif defined(UNIX) @@ -66,10 +66,10 @@ #include "tabfmt.h" #include "tabvct.h" #include "tabsys.h" -#if defined(WIN32) +#if defined(__WIN__) #include "tabmac.h" #include "tabwmi.h" -#endif // WIN32 +#endif // __WIN__ //#include "tabtbl.h" #include "tabxcl.h" #include "tabtbl.h" @@ -93,13 +93,33 @@ /***********************************************************************/ /* Extern static variables. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) extern "C" HINSTANCE s_hModule; // Saved module handle -#endif // !WIN32 +#endif // !__WIN__ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); /***********************************************************************/ +/* Get the plugin directory. */ +/***********************************************************************/ +char *GetPluginDir(void) +{ + char *plugin_dir; + +#if defined(_WIN64) + plugin_dir = (char *)GetProcAddress(GetModuleHandle(NULL), + "?opt_plugin_dir@@3PADEA"); +#elif defined(_WIN32) + plugin_dir = (char*)GetProcAddress(GetModuleHandle(NULL), + "?opt_plugin_dir@@3PADA"); +#else + plugin_dir = opt_plugin_dir; +#endif + + return plugin_dir; +} // end of GetPluginDir + +/***********************************************************************/ /* Get a unique enum table type ID. */ /***********************************************************************/ TABTYPE GetTypeID(const char *type) @@ -122,7 +142,7 @@ TABTYPE GetTypeID(const char *type) : (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL : (!stricmp(type, "DIR")) ? TAB_DIR -#ifdef WIN32 +#ifdef __WIN__ : (!stricmp(type, "MAC")) ? TAB_MAC : (!stricmp(type, "WMI")) ? TAB_WMI #endif @@ -328,12 +348,12 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) { typedef PQRYRES (__stdcall *XCOLDEF) (PGLOBAL, void*, char*, char*, bool); const char *module, *subtype; - char c, getname[40] = "Col"; -#if defined(WIN32) + char c, soname[_MAX_PATH], getname[40] = "Col"; +#if defined(__WIN__) HANDLE hdll; /* Handle to the external DLL */ -#else // !WIN32 +#else // !__WIN__ void *hdll; /* Handle for the loaded shared library */ -#endif // !WIN32 +#endif // !__WIN__ XCOLDEF coldef = NULL; PQRYRES qrp = NULL; @@ -343,6 +363,17 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) if (!module || !subtype) return NULL; + /*********************************************************************/ + /* Ensure that the .dll doesn't have a path. */ + /* This is done to ensure that only approved dll from the system */ + /* directories are used (to make this even remotely secure). */ + /*********************************************************************/ + if (check_valid_path(module, strlen(module))) { + strcpy(g->Message, "Module cannot contain a path"); + return NULL; + } else + PlugSetPath(soname, module, GetPluginDir()); + // The exported name is always in uppercase for (int i = 0; ; i++) { c = subtype[i]; @@ -350,13 +381,13 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) if (!c) break; } // endfor i -#if defined(WIN32) +#if defined(__WIN__) // Load the Dll implementing the table - if (!(hdll = LoadLibrary(module))) { + if (!(hdll = LoadLibrary(soname))) { char buf[256]; DWORD rc = GetLastError(); - sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, module); + sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, (LPTSTR)buf, sizeof(buf), NULL); @@ -370,13 +401,13 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) FreeLibrary((HMODULE)hdll); return NULL; } // endif coldef -#else // !WIN32 +#else // !__WIN__ const char *error = NULL; // Load the desired shared library - if (!(hdll = dlopen(module, RTLD_LAZY))) { + if (!(hdll = dlopen(soname, RTLD_LAZY))) { error = dlerror(); - sprintf(g->Message, MSG(SHARED_LIB_ERR), module, SVP(error)); + sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); return NULL; } // endif Hdll @@ -387,7 +418,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) dlclose(hdll); return NULL; } // endif coldef -#endif // !WIN32 +#endif // !__WIN__ // Just in case the external Get function does not set error messages sprintf(g->Message, "Error getting column info from %s", subtype); @@ -395,11 +426,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) // Get the table column definition qrp = coldef(g, topt, tab, db, info); -#if defined(WIN32) +#if defined(__WIN__) FreeLibrary((HMODULE)hdll); -#else // !WIN32 +#else // !__WIN__ dlclose(hdll); -#endif // !WIN32 +#endif // !__WIN__ return qrp; } // end of OEMColumns @@ -411,11 +442,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) /***********************************************************************/ CATALOG::CATALOG(void) { -#if defined(WIN32) +#if defined(__WIN__) //DataPath= ".\\"; -#else // !WIN32 +#else // !__WIN__ //DataPath= "./"; -#endif // !WIN32 +#endif // !__WIN__ memset(&Ctb, 0, sizeof(CURTAB)); Cbuf= NULL; Cblen= 0; @@ -458,11 +489,11 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path) } if (*path != '.') { -#if defined(WIN32) +#if defined(__WIN__) char *s= "\\"; -#else // !WIN32 +#else // !__WIN__ char *s= "/"; -#endif // !WIN32 +#endif // !__WIN__ strcat(strcat(strcat(strcpy(buf, "."), s), path), s); } else strcpy(buf, path); @@ -478,7 +509,7 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path) /* Look for a table descriptor matching the name and type. */ /***********************************************************************/ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, - LPCSTR type, PRELDEF *prp) + LPCSTR type, PRELDEF *) { if (trace) printf("GetTableDesc: name=%s am=%s\n", name, SVP(type)); @@ -523,10 +554,10 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) #if defined(ODBC_SUPPORT) case TAB_ODBC: tdp= new(g) ODBCDEF; break; #endif // ODBC_SUPPORT -#if defined(WIN32) +#if defined(__WIN__) case TAB_MAC: tdp= new(g) MACDEF; break; case TAB_WMI: tdp= new(g) WMIDEF; break; -#endif // WIN32 +#endif // __WIN__ case TAB_OEM: tdp= new(g) OEMDEF; break; case TAB_TBL: tdp= new(g) TBLDEF; break; case TAB_XCL: tdp= new(g) XCLDEF; break; @@ -589,7 +620,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) /***********************************************************************/ /* ClearDB: Terminates Database usage. */ /***********************************************************************/ -void MYCAT::ClearDB(PGLOBAL g) +void MYCAT::ClearDB(PGLOBAL) { } // end of ClearDB diff --git a/storage/connect/mycat.h b/storage/connect/mycat.h index cdbe4e5bca9..d4024e6b6c3 100644 --- a/storage/connect/mycat.h +++ b/storage/connect/mycat.h @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2013 +/* Copyright (C) Olivier Bertrand 2004 - 2015 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ #include "block.h" #include "catalog.h" -typedef struct ha_table_option_struct TOS, *PTOS; +//typedef struct ha_table_option_struct TOS, *PTOS; /** structure for CREATE TABLE options (table options) @@ -98,7 +98,7 @@ class MYCAT : public CATALOG { void Reset(void); //void SetDataPath(PGLOBAL g, const char *path) // {SetPath(g, &DataPath, path);} - bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary + bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, PRELDEF *prp = NULL); PTDB GetTable(PGLOBAL g, PTABLE tablep, diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 47d781d9ff6..ada0109a820 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2007-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2007-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -35,11 +35,11 @@ #include "my_sys.h" #include "mysqld_error.h" #endif // !MYSQL_PREPARED_STATEMENTS -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include "osutil.h" -#endif // !WIN32 +#endif // !__WIN__ #include "global.h" #include "plgdbsem.h" @@ -451,15 +451,15 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt); //mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...); -#if defined(WIN32) +#if defined(__WIN__) if (!strcmp(host, ".")) { mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL); pipe = mysqld_unix_port; } // endif host -#else // !WIN32 +#else // !__WIN__ if (!strcmp(host, "localhost")) pipe = mysqld_unix_port; -#endif // !WIN32 +#endif // !__WIN__ #if 0 if (pwd && !strcmp(pwd, "*")) { @@ -720,7 +720,7 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w) /***********************************************************************/ /* Get table size by executing "select count(*) from table_name". */ /***********************************************************************/ -int MYSQLC::GetTableSize(PGLOBAL g, PSZ query) +int MYSQLC::GetTableSize(PGLOBAL g __attribute__((unused)), PSZ query) { if (mysql_real_query(m_DB, query, strlen(query))) { #if defined(_DEBUG) diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h index 79b8a43fe5a..fa34edd804c 100644 --- a/storage/connect/myconn.h +++ b/storage/connect/myconn.h @@ -7,24 +7,24 @@ /* DO NOT define DLL_EXPORT in your application so these items are */ /* declared are imported from the Myconn DLL. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) #include <winsock.h> -#else // !WIN32 +#else // !__WIN__ #include <sys/socket.h> -#endif // !WIN32 +#endif // !__WIN__ #include <mysql.h> #include <errmsg.h> #include "myutil.h" -#if defined(WIN32) && defined(MYCONN_EXPORTS) +#if defined(__WIN__) && defined(MYCONN_EXPORTS) #if defined(DLL_EXPORT) #define DllItem _declspec(dllexport) #else // !DLL_EXPORT #define DllItem _declspec(dllimport) #endif // !DLL_EXPORT -#else // !WIN32 || !MYCONN_EXPORTS +#else // !__WIN__ || !MYCONN_EXPORTS #define DllItem -#endif // !WIN32 +#endif // !__WIN__ #define MYSQL_ENABLED 0x00000001 #define MYSQL_LOGON 0x00000002 diff --git a/storage/connect/mysql-test/connect/r/bin.result b/storage/connect/mysql-test/connect/r/bin.result index bbf5614b555..4ba353ac705 100644 --- a/storage/connect/mysql-test/connect/r/bin.result +++ b/storage/connect/mysql-test/connect/r/bin.result @@ -14,12 +14,12 @@ SET time_zone='+00:00'; CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', -name CHAR(10) not null, +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', dept INT(4) NOT NULL FIELD_FORMAT='S' -) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; +) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; SELECT * FROM t1; fig name birth id salary dept 5500 ARCHIBALD 1980-01-25 3789 4380.50 318 @@ -41,12 +41,12 @@ DROP TABLE t1; CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', -name CHAR(10) not null, +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', dept INT(4) NOT NULL FIELD_FORMAT='S' -) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat'; +) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); ERROR HY000: Table 't1' is read only ALTER TABLE t1 READONLY=NO; @@ -59,7 +59,7 @@ t1 CREATE TABLE `t1` ( `id` char(5) NOT NULL `FIELD_FORMAT`='S', `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' `READONLY`=NO +) 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); SELECT * FROM t1; fig name birth id salary dept @@ -78,7 +78,7 @@ t1 CREATE TABLE `t1` ( `id` char(5) NOT NULL `FIELD_FORMAT`='S', `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' `READONLY`=YES +) 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); ERROR HY000: Table 't1' is read only DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/r/json.result b/storage/connect/mysql-test/connect/r/json.result index 80b0a2cbc18..acb74c38e26 100644 --- a/storage/connect/mysql-test/connect/r/json.result +++ b/storage/connect/mysql-test/connect/r/json.result @@ -97,7 +97,7 @@ ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher L CREATE TABLE t2 ( FIRSTNAME CHAR(32), LASTNAME CHAR(32)) -ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[2]:AUTHOR'; +ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[1]:AUTHOR'; SELECT * FROM t2; FIRSTNAME LASTNAME William J. Pardi @@ -252,9 +252,9 @@ DROP TABLE t1; # CREATE TABLE t2 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[0]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t2; WHO WEEK WHAT AMOUNT @@ -268,9 +268,9 @@ Janet 3 Food 18.00 Janet 3 Beer 18.00 CREATE TABLE t3 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t3; WHO WEEK WHAT AMOUNT @@ -284,9 +284,9 @@ Beth 4 Beer 15.00 Janet 4 Car 17.00 CREATE TABLE t4 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[3]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t4; WHO WEEK WHAT AMOUNT diff --git a/storage/connect/mysql-test/connect/t/bin.test b/storage/connect/mysql-test/connect/t/bin.test index 06d73529c00..1e45bcaf93a 100644 --- a/storage/connect/mysql-test/connect/t/bin.test +++ b/storage/connect/mysql-test/connect/t/bin.test @@ -19,12 +19,12 @@ SET time_zone='+00:00'; CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', - name CHAR(10) not null, + 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', dept INT(4) NOT NULL FIELD_FORMAT='S' -) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; +) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; SELECT * FROM t1; --error ER_GET_ERRMSG @@ -40,12 +40,12 @@ DROP TABLE t1; CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', - name CHAR(10) not null, + 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', dept INT(4) NOT NULL FIELD_FORMAT='S' -) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat'; +) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; --error ER_OPEN_AS_READONLY INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); ALTER TABLE t1 READONLY=NO; diff --git a/storage/connect/mysql-test/connect/t/json.test b/storage/connect/mysql-test/connect/t/json.test index f89f58534e7..1cc2c054db4 100644 --- a/storage/connect/mysql-test/connect/t/json.test +++ b/storage/connect/mysql-test/connect/t/json.test @@ -97,7 +97,7 @@ SELECT * FROM t1 WHERE ISBN = '9782212090819'; CREATE TABLE t2 ( FIRSTNAME CHAR(32), LASTNAME CHAR(32)) -ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[2]:AUTHOR'; +ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[1]:AUTHOR'; SELECT * FROM t2; INSERT INTO t2 VALUES('Charles','Dickens'); SELECT * FROM t1; @@ -162,25 +162,25 @@ DROP TABLE t1; --echo # CREATE TABLE t2 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[0]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t2; CREATE TABLE t3 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t3; CREATE TABLE t4 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[3]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t4; diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp index fe504bbe422..d4416e188c8 100644 --- a/storage/connect/myutil.cpp +++ b/storage/connect/myutil.cpp @@ -13,11 +13,11 @@ /************************************************************************/ #include "my_global.h" #include <mysql.h> -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include "osutil.h" -#endif // !WIN32 +#endif // !__WIN__ #include "global.h" #include "plgdbsem.h" diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 2f2f5f38c29..6aaa048de81 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -11,7 +11,7 @@ /***********************************************************************/ #include <my_global.h> #include <m_string.h> -#if defined(WIN32) +#if defined(__WIN__) //nclude <io.h> //nclude <fcntl.h> #include <direct.h> // for getcwd @@ -45,13 +45,13 @@ #include "osutil.h" -#if defined(WIN32) +#if defined(__WIN__) /***********************************************************************/ /* For dynamic load of ODBC32.DLL */ /***********************************************************************/ #pragma comment(lib, "odbc32.lib") extern "C" HINSTANCE s_hModule; // Saved module handle -#endif // WIN32 +#endif // __WIN__ int GetConvSize(); @@ -116,16 +116,24 @@ static int GetSQLCType(int type) /***********************************************************************/ /* TranslateSQLType: translate a SQL Type to a PLG type. */ /***********************************************************************/ -int TranslateSQLType(int stp, int prec, int& len, char& v) +int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w) { int type; switch (stp) { + case SQL_WVARCHAR: // (-9) + w = true; case SQL_VARCHAR: // 12 v = 'V'; + type = TYPE_STRING; + break; + case SQL_WCHAR: // (-8) + w = true; case SQL_CHAR: // 1 type = TYPE_STRING; break; + case SQL_WLONGVARCHAR: // (-10) + w = true; case SQL_LONGVARCHAR: // (-1) v = 'V'; type = TYPE_STRING; @@ -180,7 +188,6 @@ int TranslateSQLType(int stp, int prec, int& len, char& v) case SQL_BINARY: // (-2) case SQL_VARBINARY: // (-3) case SQL_LONGVARBINARY: // (-4) -// case SQL_BIT: // (-7) case SQL_GUID: // (-11) default: type = TYPE_ERROR; @@ -410,6 +417,7 @@ PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop) PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) { // int i, type, len, prec; + bool w = false; // PCOLRES crp, crpt, crpl, crpp; PQRYRES qrp; ODBConn *ocp; @@ -455,7 +463,7 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) type = crpt->Kdata->GetIntValue(i); len = crpl->Kdata->GetIntValue(i); prec = crpp->Kdata->GetIntValue(i); - type = TranslateSQLType(type, prec, len); + type = TranslateSQLType(type, prec, len, w); crpt->Kdata->SetValue(type, i); // Some data sources do not count prec in length @@ -1201,15 +1209,15 @@ bool ODBConn::DriverConnect(DWORD Options) SWORD nResult; PUCHAR ConnOut = (PUCHAR)PlugSubAlloc(m_G, NULL, MAX_CONNECT_LEN); UWORD wConnectOption = SQL_DRIVER_COMPLETE; -#if defined(WIN32) +#if defined(__WIN__) HWND hWndTop = GetForegroundWindow(); HWND hWnd = GetParent(hWndTop); if (hWnd == NULL) hWnd = GetDesktopWindow(); -#else // !WIN32 +#else // !__WIN__ HWND hWnd = (HWND)1; -#endif // !WIN32 +#endif // !__WIN__ PGLOBAL& g = m_G; PDBUSER dup = PlgGetUser(g); @@ -1222,10 +1230,10 @@ bool ODBConn::DriverConnect(DWORD Options) SQL_NTS, ConnOut, MAX_CONNECT_LEN, &nResult, wConnectOption); -#if defined(WIN32) +#if defined(__WIN__) if (hWndTop) EnableWindow(hWndTop, true); -#endif // WIN32 +#endif // __WIN__ // If user hit 'Cancel' if (rc == SQL_NO_DATA_FOUND) { diff --git a/storage/connect/odbconn.h b/storage/connect/odbconn.h index 41cc2439354..6a24334f08c 100644 --- a/storage/connect/odbconn.h +++ b/storage/connect/odbconn.h @@ -29,9 +29,9 @@ //efine MAX_CURSOR_NAME 18 // Max size of a cursor name #define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type -#if !defined(WIN32) +#if !defined(__WIN__) typedef unsigned char *PUCHAR; -#endif // !WIN32 +#endif // !__WIN__ // Field Flags, used to indicate status of fields //efine SQL_FIELD_FLAG_DIRTY 0x1 diff --git a/storage/connect/os.h b/storage/connect/os.h index 8f77a0ad39f..2dc603fdcda 100644 --- a/storage/connect/os.h +++ b/storage/connect/os.h @@ -15,16 +15,16 @@ typedef off_t off64_t; #endif #endif -#if defined(WIN32) +#if defined(__WIN__) typedef __int64 BIGINT; -#else // !WIN32 +#else // !__WIN__ typedef longlong BIGINT; #define FILE_BEGIN SEEK_SET #define FILE_CURRENT SEEK_CUR #define FILE_END SEEK_END -#endif // !WIN32 +#endif // !__WIN__ -#if !defined(WIN32) +#if !defined(__WIN__) typedef const void *LPCVOID; typedef const char *LPCTSTR; typedef const char *LPCSTR; @@ -61,6 +61,6 @@ typedef int HANDLE; #define _MAX_EXT FN_EXTLEN #define INVALID_HANDLE_VALUE (-1) #define __stdcall -#endif /* !WIN32 */ +#endif /* !__WIN__ */ #endif /* _OS_H_INCLUDED */ diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c index 66985847ce7..2e9e120b0c8 100644 --- a/storage/connect/osutil.c +++ b/storage/connect/osutil.c @@ -4,7 +4,7 @@ #include <stdio.h> #include "osutil.h" -#ifdef WIN32 +#ifdef __WIN__ my_bool CloseFileHandle(HANDLE h) { return !CloseHandle(h); diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 4dc8f293070..b57d9e20ceb 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -389,6 +389,7 @@ typedef struct _qryres *PQRYRES; typedef struct _colres *PCOLRES; typedef struct _datpar *PDTP; typedef struct indx_used *PXUSED; +typedef struct ha_table_option_struct TOS, *PTOS; /***********************************************************************/ /* Utility blocks for file and storage. */ @@ -543,11 +544,11 @@ typedef struct _colres { char Var; /* Type added information */ } COLRES; -#if defined(WIN32) && !defined(NOEX) +#if defined(__WIN__) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !WIN32 +#else // !__WIN__ #define DllExport -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Utility routines. */ @@ -593,6 +594,9 @@ DllExport void NewPointer(PTABS, void *, void *); DllExport void SetTrc(void); DllExport char *GetListOption(PGLOBAL, const char *, const char *, const char *def=NULL); +DllExport char *GetStringTableOption(PGLOBAL, PTOS, char *, char *); +DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, char *, bool); +DllExport int GetIntegerTableOption(PGLOBAL, PTOS, char *, int); #define MSGID_NONE 0 #define MSGID_CANNOT_OPEN 1 diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 32f6d6f8366..9e236da2d93 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -38,12 +38,12 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> #define BIGMEM 1048576 // 1 Megabyte -#else // !WIN32 +#else // !__WIN__ #include <unistd.h> #include <fcntl.h> #if defined(THREAD) @@ -51,7 +51,7 @@ #endif // THREAD #include <stdarg.h> #define BIGMEM 2147483647 // Max int value -#endif // !WIN32 +#endif // !__WIN__ #include <locale.h> /***********************************************************************/ @@ -73,11 +73,11 @@ /* Macro or external routine definition */ /***********************************************************************/ #if defined(THREAD) -#if defined(WIN32) +#if defined(__WIN__) extern CRITICAL_SECTION parsec; // Used calling the Flex parser -#else // !WIN32 +#else // !__WIN__ extern pthread_mutex_t parmut; -#endif // !WIN32 +#endif // !__WIN__ #endif // THREAD /***********************************************************************/ @@ -403,11 +403,11 @@ char *SetPath(PGLOBAL g, const char *path) } // endif path if (*path != '.') { -#if defined(WIN32) +#if defined(__WIN__) char *s= "\\"; -#else // !WIN32 +#else // !__WIN__ char *s= "/"; -#endif // !WIN32 +#endif // !__WIN__ strcat(strcat(strcat(strcpy(buf, "."), s), path), s); } else strcpy(buf, path); @@ -426,7 +426,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op) char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL; switch (op) { // Determine which part to extract -#if !defined(UNIX) +#if defined(__WIN__) case OP_FDISK: drive = pBuff; break; #endif // !UNIX case OP_FPATH: direc = pBuff; break; @@ -702,19 +702,19 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag) /* instruction is included in an Enter/LeaveCriticalSection bracket. */ /*********************************************************************/ #if defined(THREAD) -#if defined(WIN32) +#if defined(__WIN__) EnterCriticalSection((LPCRITICAL_SECTION)&parsec); -#else // !WIN32 +#else // !__WIN__ pthread_mutex_lock(&parmut); -#endif // !WIN32 +#endif // !__WIN__ #endif // THREAD /*int rc =*/ fmdflex(pdp); #if defined(THREAD) -#if defined(WIN32) +#if defined(__WIN__) LeaveCriticalSection((LPCRITICAL_SECTION)&parsec); -#else // !WIN32 +#else // !__WIN__ pthread_mutex_unlock(&parmut); -#endif // !WIN32 +#endif // !__WIN__ #endif // THREAD if (trace) @@ -888,7 +888,7 @@ FILE *PlugReopenFile(PGLOBAL g, PFBLOCK fp, LPCSTR md) /* Close file routine: the purpose of this routine is to avoid */ /* double closing that freeze the system on some Unix platforms. */ /***********************************************************************/ -int PlugCloseFile(PGLOBAL g, PFBLOCK fp, bool all) +int PlugCloseFile(PGLOBAL g __attribute__((unused)), PFBLOCK fp, bool all) { int rc = 0; @@ -1109,7 +1109,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp) return amn; } // end of GetAmName -#if defined(WIN32) && !defined(NOCATCH) +#if defined(__WIN__) && !defined(NOCATCH) /***********************************************************************/ /* GetExceptionDesc: return the description of an exception code. */ /***********************************************************************/ @@ -1197,7 +1197,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e) return p; } // end of GetExceptionDesc -#endif // WIN32 && !NOCATCH +#endif // __WIN__ && !NOCATCH /***********************************************************************/ /* PlgDBalloc: allocates or suballocates memory conditionally. */ @@ -1239,7 +1239,7 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp) if (!mp.Sub) { // For allocations greater than one fourth of remaining storage // in the area, do allocate from virtual storage. -#if defined(WIN32) +#if defined(__WIN__) if (mp.Size >= BIGMEM) mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT, PAGE_READWRITE); else @@ -1336,7 +1336,7 @@ void PlgDBfree(MBLOCK& mp) htrc("PlgDBfree: %p sub=%d size=%d\n", mp.Memp, mp.Sub, mp.Size); if (!mp.Sub && mp.Memp) -#if defined(WIN32) +#if defined(__WIN__) if (mp.Size >= BIGMEM) VirtualFree(mp.Memp, 0, MEM_RELEASE); else @@ -1532,11 +1532,11 @@ int FileComp(PGLOBAL g, char *file1, char *file2) bp[0] = buff1; bp[1] = buff2; for (i = 0; i < 2; i++) { -#if defined(WIN32) +#if defined(__WIN__) h[i]= global_open(g, MSGID_NONE, fn[i], _O_RDONLY | _O_BINARY); -#else // !WIN32 +#else // !__WIN__ h[i]= global_open(g, MSGOD_NONE, fn[i], O_RDONLY); -#endif // !WIN32 +#endif // !__WIN__ if (h[i] == -1) { // if (errno != ENOENT) { diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 36d115e0096..c0e249adf12 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -44,7 +44,7 @@ /* */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> #else #if defined(UNIX) || defined(UNIV_LINUX) @@ -80,9 +80,9 @@ #include "rcmsg.h" #endif // NEWMSG -#if defined(WIN32) +#if defined(__WIN__) extern HINSTANCE s_hModule; /* Saved module handle */ -#endif // WIN32 +#endif // __WIN__ #if defined(XMSG) extern char *msg_path; @@ -192,7 +192,7 @@ int PlugExit(PGLOBAL g) /***********************************************************************/ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) { -#if !defined(UNIX) && !defined(UNIV_LINUX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -220,7 +220,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) BOOL PlugIsAbsolutePath(LPCSTR path) { -#if defined(WIN32) +#if defined(__WIN__) return ((path[0] >= 'a' && path[0] <= 'z') || (path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':'; #else @@ -238,7 +238,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) char direc[_MAX_DIR], defdir[_MAX_DIR], tmpdir[_MAX_DIR]; char fname[_MAX_FNAME]; char ftype[_MAX_EXT]; -#if !defined(UNIX) && !defined(UNIV_LINUX) +#if defined(__WIN__) char drive[_MAX_DRIVE], defdrv[_MAX_DRIVE]; #else char *drive = NULL, *defdrv = NULL; @@ -255,7 +255,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) return pBuff; } // endif -#if !defined(WIN32) +#if !defined(__WIN__) if (*FileName == '~') { if (_fullpath(pBuff, FileName, _MAX_PATH)) { if (trace > 1) @@ -266,7 +266,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) return FileName; // Error, return unchanged name } // endif FileName -#endif // !WIN32 +#endif // !__WIN__ if (prefix && strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath)) { @@ -295,11 +295,11 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) if (trace > 1) { htrc("after _splitpath: FileName=%s\n", FileName); -#if defined(UNIX) || defined(UNIV_LINUX) - htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype); -#else +#if defined(__WIN__) htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype); htrc("defdrv=%s defdir=%s\n", defdrv, defdir); +#else + htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype); #endif } // endif trace @@ -427,7 +427,7 @@ char *PlugGetMessage(PGLOBAL g, int mid) } // end of PlugGetMessage #endif // NEWMSG -#if defined(WIN32) +#if defined(__WIN__) /***********************************************************************/ /* Return the line length of the console screen buffer. */ /***********************************************************************/ @@ -439,7 +439,7 @@ short GetLineLength(PGLOBAL g) return (b) ? coninfo.dwSize.X : 0; } // end of GetLineLength -#endif // WIN32 +#endif // __WIN__ /***********************************************************************/ /* Program for memory allocation of work and language areas. */ @@ -502,7 +502,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */ pph = (PPOOLHEADER)memp; - if (trace > 2) + if (trace > 3) htrc("SubAlloc in %p size=%d used=%d free=%d\n", memp, size, pph->To_Free, pph->FreeBlk); @@ -526,7 +526,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) pph->To_Free += size; /* New offset of pool free block */ pph->FreeBlk -= size; /* New size of pool free block */ - if (trace > 2) + if (trace > 3) htrc("Done memp=%p used=%d free=%d\n", memp, pph->To_Free, pph->FreeBlk); diff --git a/storage/connect/rcmsg.c b/storage/connect/rcmsg.c index eafcbdcd81b..75759e03314 100644 --- a/storage/connect/rcmsg.c +++ b/storage/connect/rcmsg.c @@ -21,9 +21,9 @@ #include "msgid.h" #endif // NEWMSG -#if !defined(WIN32) +#if !defined(__WIN__) #define stricmp strcasecmp -#endif // !WIN32 +#endif // !__WIN__ char *msglang(void); diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 47f825e965d..60d515a61ca 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -17,7 +17,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <sqlext.h> #else #include <dlfcn.h> // dlopen(), dlclose(), dlsym() ... @@ -48,14 +48,15 @@ #include "tabmul.h" #include "ha_connect.h" -#if !defined(WIN32) +#if !defined(__WIN__) extern handlerton *connect_hton; -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* External function. */ /***********************************************************************/ USETEMP UseTemp(void); +char *GetPluginDir(void); /* --------------------------- Class RELDEF -------------------------- */ @@ -246,7 +247,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) /***********************************************************************/ PSZ TABDEF::GetPath(void) { - return (Database) ? (PSZ)Database : Hc->GetDataPath(); + return (Database) ? (PSZ)Database : (Hc) ? Hc->GetDataPath() : NULL; } // end of GetPath /***********************************************************************/ @@ -255,7 +256,8 @@ PSZ TABDEF::GetPath(void) int TABDEF::GetColCatInfo(PGLOBAL g) { char *type= GetStringCatInfo(g, "Type", "*"); - int i, loff, poff, nof, nlg; + char c, fty, eds; + int i, n, loff, poff, nof, nlg; void *field= NULL; TABTYPE tc; PCOLDEF cdp, lcdp= NULL, tocols= NULL; @@ -322,7 +324,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g) if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0) return -1; // Error, probably unhandled type - else if (nof) + else loff= cdp->GetOffset(); switch (tc) { @@ -330,20 +332,52 @@ int TABDEF::GetColCatInfo(PGLOBAL g) cdp->SetOffset(0); // Not to have shift case TAB_BIN: // BIN/VEC are packed by default - if (nof) + if (nof) { // Field width is the internal representation width // that can also depend on the column format - switch (cdp->Fmt ? *cdp->Fmt : 'X') { - case 'C': break; + fty = cdp->Decode ? 'C' : 'X'; + eds = 0; + n = 0; + + if (cdp->Fmt && !cdp->Decode) { + for (i = 0; cdp->Fmt[i]; i++) { + c = toupper(cdp->Fmt[i]); + + if (isdigit(c)) + n = (n * 10 + (c - '0')); + else if (c == 'L' || c == 'B' || c == 'H') + eds = c; + else + fty = c; + + } // endfor i + + } // endif Fmt + + if (n) + nof = n; + else switch (fty) { + case 'X': + if (eds && IsTypeChar(cdp->Buf_Type)) + nof = sizeof(longlong); + else + nof= cdp->Clen; + + break; + case 'C': break; case 'R': - case 'F': - case 'L': - case 'I': nof= 4; break; - case 'D': nof= 8; break; - case 'S': nof= 2; break; - case 'T': nof= 1; break; - default: nof= cdp->Clen; - } // endswitch Fmt + case 'F': nof = sizeof(float); break; + case 'I': nof = sizeof(int); break; + case 'D': nof = sizeof(double); break; + case 'S': nof = sizeof(short); break; + case 'T': nof = sizeof(char); break; + case 'G': nof = sizeof(longlong); break; + default: /* Wrong format */ + sprintf(g->Message, "Invalid format %c", fty); + return -1; + } // endswitch fty + + } // endif nof default: break; @@ -369,20 +403,16 @@ int TABDEF::GetColCatInfo(PGLOBAL g) // not specified (for instance if quoted is specified) // if ((ending= Hc->GetIntegerOption("Ending")) < 0) { if ((ending= Hc->GetIntegerOption("Ending")) <= 0) { -#if defined(WIN32) - ending= 2; -#else - ending= 1; -#endif + ending= (tc == TAB_BIN || tc == TAB_VEC) ? 0 : CRLF; Hc->SetIntegerOption("Ending", ending); } // endif ending // Calculate the default record size switch (tc) { case TAB_FIX: + case TAB_BIN: recln= nlg + ending; // + length of line ending break; - case TAB_BIN: case TAB_VEC: recln= nlg; @@ -433,20 +463,31 @@ void TABDEF::SetIndexInfo(void) PTABDEF OEMDEF::GetXdef(PGLOBAL g) { typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *); - char c, getname[40] = "Get"; + char c, soname[_MAX_PATH], getname[40] = "Get"; PTABDEF xdefp; XGETDEF getdef = NULL; PCATLG cat = Cat; -#if defined(WIN32) + /*********************************************************************/ + /* Ensure that the .dll doesn't have a path. */ + /* This is done to ensure that only approved dll from the system */ + /* directories are used (to make this even remotely secure). */ + /*********************************************************************/ + if (check_valid_path(Module, strlen(Module))) { + strcpy(g->Message, "Module cannot contain a path"); + return NULL; + } else + PlugSetPath(soname, Module, GetPluginDir()); + +#if defined(__WIN__) // Is the DLL already loaded? - if (!Hdll && !(Hdll = GetModuleHandle(Module))) + if (!Hdll && !(Hdll = GetModuleHandle(soname))) // No, load the Dll implementing the function - if (!(Hdll = LoadLibrary(Module))) { + if (!(Hdll = LoadLibrary(soname))) { char buf[256]; DWORD rc = GetLastError(); - sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module); + sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, (LPTSTR)buf, sizeof(buf), NULL); @@ -467,10 +508,11 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) FreeLibrary((HMODULE)Hdll); return NULL; } // endif getdef -#else // !WIN32 +#else // !__WIN__ const char *error = NULL; Dl_info dl_info; - + +#if 0 // Don't know what all this stuff does // The OEM lib must retrieve exported CONNECT variables if (dladdr(&connect_hton, &dl_info)) { if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) { @@ -484,15 +526,16 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) sprintf(g->Message, "dladdr failed: %s, OEM not supported", SVP(error)); return NULL; } // endif dladdr +#endif // 0 // Is the library already loaded? -// if (!Hdll && !(Hdll = ???)) - // Load the desired shared library - if (!(Hdll = dlopen(Module, RTLD_LAZY))) { - error = dlerror(); - sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error)); - return NULL; - } // endif Hdll + if (!Hdll && !(Hdll = dlopen(soname, RTLD_NOLOAD))) + // Load the desired shared library + if (!(Hdll = dlopen(soname, RTLD_LAZY))) { + error = dlerror(); + sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); + return NULL; + } // endif Hdll // The exported name is always in uppercase for (int i = 0; ; i++) { @@ -508,7 +551,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) dlclose(Hdll); return NULL; } // endif getdef -#endif // !WIN32 +#endif // !__WIN__ // Just in case the external Get function does not set error messages sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); @@ -548,7 +591,7 @@ bool OEMDEF::DeleteTableFile(PGLOBAL g) /***********************************************************************/ /* Define: initialize the table definition block from XDB file. */ /***********************************************************************/ -bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR, int) { Module = GetStringCatInfo(g, "Module", ""); Subtype = GetStringCatInfo(g, "Subtype", Module); @@ -715,7 +758,7 @@ COLDEF::COLDEF(void) : COLCRT() /***********************************************************************/ /* Define: initialize a column definition from a COLINFO structure. */ /***********************************************************************/ -int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) +int COLDEF::Define(PGLOBAL g, void *, PCOLINFO cfp, int poff) { Name = (PSZ)PlugDup(g, cfp->Name); @@ -745,7 +788,8 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) if (cfp->Datefmt) Decode = (PSZ)PlugDup(g, cfp->Datefmt); - } // endif special + } else + Offset = poff; if (cfp->Fieldfmt) Fmt = (PSZ)PlugDup(g, cfp->Fieldfmt); diff --git a/storage/connect/reldef.h b/storage/connect/reldef.h index 13bd392b706..4aa29037dfc 100644 --- a/storage/connect/reldef.h +++ b/storage/connect/reldef.h @@ -1,7 +1,7 @@ /*************** RelDef H Declares Source Code File (.H) ***************/ /* Name: RELDEF.H Version 1.5 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */ /* */ /* This file contains the DEF classes definitions. */ /***********************************************************************/ @@ -89,7 +89,7 @@ class DllExport TABDEF : public RELDEF { /* Logical table descriptor */ bool IsReadOnly(void) {return Read_Only;} virtual AMT GetDefType(void) {return TYPE_AM_TAB;} virtual PIXDEF GetIndx(void) {return NULL;} - virtual void SetIndx(PIXDEF xp) {} + virtual void SetIndx(PIXDEF) {} virtual bool IsHuge(void) {return false;} const CHARSET_INFO *data_charset() {return m_data_charset;} @@ -139,11 +139,11 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */ PTABDEF GetXdef(PGLOBAL g); // Members -#if defined(WIN32) +#if defined(__WIN__) HANDLE Hdll; /* Handle to the external DLL */ -#else // !WIN32 +#else // !__WIN__ void *Hdll; /* Handle for the loaded shared library */ -#endif // !WIN32 +#endif // !__WIN__ PTABDEF Pxdef; /* Pointer to the external TABDEF class */ char *Module; /* Path/Name of the DLL implenting it */ char *Subtype; /* The name of the OEM table sub type */ diff --git a/storage/connect/tabcol.cpp b/storage/connect/tabcol.cpp index 8f350c6f074..662c0b514cf 100644 --- a/storage/connect/tabcol.cpp +++ b/storage/connect/tabcol.cpp @@ -1,7 +1,7 @@ /************* TabCol C++ Functions Source Code File (.CPP) ************/ /* Name: TABCOL.CPP Version 2.7 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* */ /* This file contains the PlugDB++ XTAB, COLUMN and XORDER methods. */ /***********************************************************************/ @@ -91,7 +91,7 @@ void XTAB::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of XTAB contents. */ /***********************************************************************/ -void XTAB::Print(PGLOBAL g, char *ps, uint z) +void XTAB::Print(PGLOBAL, char *ps, uint z) { char buf[128]; int i, n = (int)z - 1; @@ -125,7 +125,7 @@ COLUMN::COLUMN(LPCSTR name) : Name(name) /***********************************************************************/ /* COLUMN SetFormat: should never be called. */ /***********************************************************************/ -bool COLUMN::SetFormat(PGLOBAL g, FORMAT& fmt) +bool COLUMN::SetFormat(PGLOBAL g, FORMAT&) { strcpy(g->Message, MSG(NO_FORMAT_COL)); return true; @@ -154,7 +154,7 @@ void COLUMN::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of COLUMN contents. */ /***********************************************************************/ -void COLUMN::Print(PGLOBAL g, char *ps, uint z) +void COLUMN::Print(PGLOBAL, char *ps, uint z) { char buf[80]; diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index ba22da52998..a1e58ab3344 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <sys\timeb.h> // For testing only #include <fcntl.h> @@ -26,7 +26,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -34,7 +34,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -112,12 +112,13 @@ DOSDEF::DOSDEF(void) Maxerr = 0; ReadMode = 0; Ending = 0; + Teds = 0; } // end of DOSDEF constructor /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ -bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int) { char buf[8]; bool map = (am && (*am == 'M' || *am == 'm')); @@ -146,6 +147,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Padded = GetBoolCatInfo("Padded", false); Blksize = GetIntCatInfo("Blksize", 0); Eof = (GetIntCatInfo("EOF", 0) != 0); + Teds = toupper(*GetStringCatInfo(g, "Endian", "")); } else if (Recfm == RECFM_DBF) { Maxerr = GetIntCatInfo("Maxerr", 0); Accept = GetBoolCatInfo("Accept", false); @@ -206,11 +208,11 @@ void DOSDEF::RemoveOptValues(PGLOBAL g) // Delete any eventually ill formed non matching optimization file if (!GetOptFileName(g, filename)) -#if defined(WIN32) +#if defined(__WIN__) DeleteFile(filename); #else // UNIX remove(filename); -#endif // WIN32 +#endif // __WIN__ Optimized = 0; } // end of RemoveOptValues @@ -251,7 +253,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) /*********************************************************************/ if (sep) { // Indexes are save in separate files -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -268,7 +270,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) strcat(strcat(fname, "_"), pxdf->GetName()); _makepath(filename, drive, direc, fname, ftype); PlugSetPath(filename, filename, GetPath()); -#if defined(WIN32) +#if defined(__WIN__) if (!DeleteFile(filename)) rc |= (GetLastError() != ERROR_FILE_NOT_FOUND); #else // UNIX @@ -285,7 +287,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) // Drop all indexes, delete the common file PlugSetPath(filename, Ofn, GetPath()); strcat(PlugRemoveType(filename, filename), ftype); -#if defined(WIN32) +#if defined(__WIN__) if (!DeleteFile(filename)) rc = (GetLastError() != ERROR_FILE_NOT_FOUND); #else // UNIX @@ -303,7 +305,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) /***********************************************************************/ /* InvalidateIndex: mark all indexes as invalid. */ /***********************************************************************/ -bool DOSDEF::InvalidateIndex(PGLOBAL g) +bool DOSDEF::InvalidateIndex(PGLOBAL) { if (To_Indx) for (PIXDEF xp = To_Indx; xp; xp = xp->Next) @@ -954,7 +956,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g) #if 0 if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS) return false; -#endif // WIN32 +#endif // __WIN__ if (defp->Optimized) return false; // Already done or to be redone @@ -1736,15 +1738,16 @@ err: /***********************************************************************/ /* Make a dynamic index. */ /***********************************************************************/ -bool TDBDOS::InitialyzeIndex(PGLOBAL g, PIXDEF xdp, bool sorted) +bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted) { int k, rc; - bool brc, dynamic; + volatile bool dynamic; + bool brc; PCOL colp; PCOLDEF cdp; PVAL valp; PXLOAD pxp; - PKXBASE kxp; + volatile PKXBASE kxp; PKPDEF kdp; if (!xdp && !(xdp = To_Xdp)) { @@ -1864,7 +1867,7 @@ int TDBDOS::GetProgCur(void) /***********************************************************************/ /* RowNumber: return the ordinal number of the current row. */ /***********************************************************************/ -int TDBDOS::RowNumber(PGLOBAL g, bool b) +int TDBDOS::RowNumber(PGLOBAL g, bool) { if (To_Kindex) { /*******************************************************************/ @@ -1944,7 +1947,7 @@ int TDBDOS::Cardinality(PGLOBAL g) rec = ((PDOSDEF)To_Def)->Ending; if (AvgLen <= 0) // No given average estimate - rec += EstimatedLength(g); + rec += EstimatedLength(); else // An estimate was given for the average record length rec += AvgLen; @@ -1988,7 +1991,7 @@ int TDBDOS::GetMaxSize(PGLOBAL g) /* Estimate the number of lines in the table (if not known) by */ /* dividing the file length by minimum record length. */ /*****************************************************************/ - rec = EstimatedLength(g) + ((PDOSDEF)To_Def)->Ending; + rec = EstimatedLength() + ((PDOSDEF)To_Def)->Ending; MaxSize = (len + rec - 1) / rec; if (trace) @@ -2005,7 +2008,7 @@ int TDBDOS::GetMaxSize(PGLOBAL g) /***********************************************************************/ /* DOS EstimatedLength. Returns an estimated minimum line length. */ /***********************************************************************/ -int TDBDOS::EstimatedLength(PGLOBAL g) +int TDBDOS::EstimatedLength(void) { int dep = 0; PCOLDEF cdp = To_Def->GetCols(); @@ -2023,7 +2026,7 @@ int TDBDOS::EstimatedLength(PGLOBAL g) /***********************************************************************/ /* DOS tables favor the use temporary files for Update. */ /***********************************************************************/ -bool TDBDOS::IsUsingTemp(PGLOBAL g) +bool TDBDOS::IsUsingTemp(PGLOBAL) { USETEMP utp = UseTemp(); @@ -2183,7 +2186,7 @@ int TDBDOS::ReadDB(PGLOBAL g) /***********************************************************************/ /* PrepareWriting: Prepare the line to write. */ /***********************************************************************/ -bool TDBDOS::PrepareWriting(PGLOBAL g) +bool TDBDOS::PrepareWriting(PGLOBAL) { if (!Ftype && (Mode == MODE_INSERT || Txfp->GetUseTemp())) { char *p; diff --git a/storage/connect/tabdos.h b/storage/connect/tabdos.h index b7150294e9b..c098886f14b 100644 --- a/storage/connect/tabdos.h +++ b/storage/connect/tabdos.h @@ -1,7 +1,7 @@ /*************** TabDos H Declares Source Code File (.H) ***************/ /* Name: TABDOS.H Version 3.3 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */ /* */ /* This file contains the DOS classes declares. */ /***********************************************************************/ @@ -91,6 +91,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */ int Maxerr; /* Maximum number of bad records (DBF) */ int ReadMode; /* Specific to DBF */ int Ending; /* Length of end of lines */ + int Teds; /* Binary table default endian setting */ }; // end of DOSDEF /***********************************************************************/ @@ -123,11 +124,11 @@ class DllExport TDBDOS : public TDBASE { // Implementation virtual AMT GetAmType(void) {return Txfp->GetAmType();} - virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;} - virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;} + virtual PSZ GetFile(PGLOBAL) {return Txfp->To_File;} + virtual void SetFile(PGLOBAL, PSZ fn) {Txfp->To_File = fn;} virtual void SetAbort(bool b) {Abort = b;} virtual RECFM GetFtype(void) {return Ftype;} - virtual bool SkipHeader(PGLOBAL g) {return false;} + virtual bool SkipHeader(PGLOBAL) {return false;} virtual void RestoreNrec(void) {Txfp->SetNrec(1);} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBDOS(g, this);} @@ -149,7 +150,7 @@ class DllExport TDBDOS : public TDBASE { // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;} + virtual char *GetOpenMode(PGLOBAL, char*) {return NULL;} virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);} virtual int GetProgMax(PGLOBAL g); virtual int GetProgCur(void); @@ -168,7 +169,7 @@ class DllExport TDBDOS : public TDBASE { virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);} // Specific routine - virtual int EstimatedLength(PGLOBAL g); + virtual int EstimatedLength(void); // Optimization routines virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add); diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp index 77e47e6f8dd..acd548c86ab 100644 --- a/storage/connect/tabfix.cpp +++ b/storage/connect/tabfix.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -17,7 +17,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -35,7 +35,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -54,6 +54,7 @@ extern int num_read, num_there, num_eq[2]; // Statistics static const longlong M2G = 0x80000000; static const longlong M4G = (longlong)2 * M2G; +char BINCOL::Endian = 'H'; /***********************************************************************/ /* External function. */ @@ -67,10 +68,12 @@ USETEMP UseTemp(void); /***********************************************************************/ TDBFIX::TDBFIX(PDOSDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) { + Teds = tdp->Teds; // For BIN tables } // end of TDBFIX standard constructor TDBFIX::TDBFIX(PGLOBAL g, PTDBFIX tdbp) : TDBDOS(g, tdbp) { + Teds = tdbp->Teds; } // end of TDBFIX copy constructor // Method @@ -271,7 +274,7 @@ int TDBFIX::RowNumber(PGLOBAL g, bool b) /***********************************************************************/ /* FIX tables don't use temporary files except if specified as do it. */ /***********************************************************************/ -bool TDBFIX::IsUsingTemp(PGLOBAL g) +bool TDBFIX::IsUsingTemp(PGLOBAL) { // Not ready yet to handle using a temporary file with mapping // or while deleting from DBF files. @@ -373,19 +376,94 @@ int TDBFIX::WriteDB(PGLOBAL g) BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am) : DOSCOL(g, cdp, tp, cp, i, am) { - Fmt = (cdp->GetFmt()) ? toupper(*cdp->GetFmt()) : 'X'; + char c, *fmt = cdp->GetFmt(); + + Fmt = GetDomain() ? 'C' : 'X'; + Buff = NULL; + Eds = ((PTDBFIX)tp)->Teds; + N = 0; + M = GetTypeSize(Buf_Type, sizeof(longlong)); + Lim = 0; + + if (fmt) { + for (N = 0, i = 0; fmt[i]; i++) { + c = toupper(fmt[i]); + + if (isdigit(c)) + N = (N * 10 + (c - '0')); + else if (c == 'L' || c == 'B' || c == 'H') + Eds = c; + else + Fmt = c; + + } // endfor i + + // M is the size of the source value + switch (Fmt) { + case 'C': Eds = 0; break; + case 'X': break; + case 'S': M = sizeof(short); break; + case 'T': M = sizeof(char); break; + case 'I': M = sizeof(int); break; + case 'G': M = sizeof(longlong); break; + case 'R': // Real + case 'F': M = sizeof(float); break; + case 'D': M = sizeof(double); break; + default: + sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); + longjmp(g->jumper[g->jump_level], 11); + } // endswitch Fmt + + } else if (IsTypeChar(Buf_Type)) + Eds = 0; + + if (Eds) { + // This is a byte order specification + if (!N) + N = M; + + if (Eds != 'L' && Eds != 'B') + Eds = Endian; + + if (N != M || Eds != Endian || IsTypeChar(Buf_Type)) { + Buff = (char*)PlugSubAlloc(g, NULL, M); + memset(Buff, 0, M); + Lim = MY_MIN(N, M); + } else + Eds = 0; // New format is a no op + + } // endif Eds + } // end of BINCOL constructor /***********************************************************************/ -/* FIXCOL constructor used for copying columns. */ +/* BINCOL constructor used for copying columns. */ /* tdbp is the pointer to the new table descriptor. */ /***********************************************************************/ BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp) { + Eds = col1->Eds; Fmt = col1->Fmt; + N = col1->N; + M = col1->M; + Lim = col1->Lim; } // end of BINCOL copy constructor /***********************************************************************/ +/* Set Endian according to the host setting. */ +/***********************************************************************/ +void BINCOL::SetEndian(void) + { + union { + short S; + char C[sizeof(short)]; + }; + + S = 1; + Endian = (C[0] == 1) ? 'L' : 'B'; + } // end of SetEndian + +/***********************************************************************/ /* ReadColumn: what this routine does is to access the last line */ /* read from the corresponding table and extract from it the field */ /* corresponding to this column. */ @@ -416,22 +494,40 @@ void BINCOL::ReadColumn(PGLOBAL g) /*********************************************************************/ /* Set Value from the line field. */ /*********************************************************************/ + if (Eds) { + for (int i = 0; i < Lim; i++) + if (Eds == 'B' && Endian == 'L') + Buff[i] = p[N - i - 1]; + else if (Eds == 'L' && Endian == 'B') + Buff[M - i - 1] = p[i]; + else if (Endian == 'B') + Buff[M - i - 1] = p[N - i - 1]; + else + Buff[i] = p[i]; + + p = Buff; + } // endif Eds + switch (Fmt) { case 'X': // Standard not converted values - Value->SetBinValue(p); + if (Eds && IsTypeChar(Buf_Type)) + Value->SetValue(*(longlong*)p); + else + Value->SetBinValue(p); + break; case 'S': // Short integer - Value->SetValue((int)*(short*)p); + Value->SetValue(*(short*)p); break; case 'T': // Tiny integer - Value->SetValue((int)*p); + Value->SetValue(*p); break; - case 'L': // Long Integer - strcpy(g->Message, "Format L is deprecated, use I"); - longjmp(g->jumper[g->jump_level], 11); case 'I': // Integer Value->SetValue(*(int*)p); break; + case 'G': // Large (great) integer + Value->SetValue(*(longlong*)p); + break; case 'F': // Float case 'R': // Real Value->SetValue((double)*(float*)p); @@ -483,7 +579,7 @@ void BINCOL::WriteColumn(PGLOBAL g) if (Value != To_Val) Value->SetValue_pval(To_Val, false); // Convert the updated value - p = tdbp->To_Line + Deplac; + p = (Eds) ? Buff : tdbp->To_Line + Deplac; /*********************************************************************/ /* Check whether updating is Ok, meaning col value is not too long. */ @@ -493,11 +589,13 @@ void BINCOL::WriteColumn(PGLOBAL g) switch (Fmt) { case 'X': // Standard not converted values - if (Value->GetBinValue(p, Long, Status)) { + if (Eds && IsTypeChar(Buf_Type)) + *(longlong *)p = Value->GetBigintValue(); + else if (Value->GetBinValue(p, Long, Status)) { sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, Value->GetSize(), Long); longjmp(g->jumper[g->jump_level], 31); - } // endif Fmt + } // endif p break; case 'S': // Short integer @@ -520,9 +618,6 @@ void BINCOL::WriteColumn(PGLOBAL g) *p = (char)n; break; - case 'L': // Long Integer - strcpy(g->Message, "Format L is deprecated, use I"); - longjmp(g->jumper[g->jump_level], 11); case 'I': // Integer n = Value->GetBigintValue(); @@ -533,9 +628,9 @@ void BINCOL::WriteColumn(PGLOBAL g) *(int *)p = Value->GetIntValue(); break; - case 'B': // Large (big) integer + case 'G': // Large (great) integer if (Status) - *(longlong *)p = (longlong)Value->GetBigintValue(); + *(longlong *)p = Value->GetBigintValue(); break; case 'F': // Float @@ -567,6 +662,21 @@ void BINCOL::WriteColumn(PGLOBAL g) longjmp(g->jumper[g->jump_level], 11); } // endswitch Fmt + if (Eds && Status) { + p = tdbp->To_Line + Deplac; + + for (int i = 0; i < Lim; i++) + if (Eds == 'B' && Endian == 'L') + p[N - i - 1] = Buff[i]; + else if (Eds == 'L' && Endian == 'B') + p[i] = Buff[M - i - 1]; + else if (Endian == 'B') + p[N - i - 1] = Buff[M - i - 1]; + else + p[i] = Buff[i]; + + } // endif Eds + } // end of WriteColumn /* ------------------------ End of TabFix ---------------------------- */ diff --git a/storage/connect/tabfix.h b/storage/connect/tabfix.h index 7d5b964da2a..49956ba0711 100644 --- a/storage/connect/tabfix.h +++ b/storage/connect/tabfix.h @@ -1,7 +1,7 @@ /*************** TabDos H Declares Source Code File (.H) ***************/ -/* Name: TABFIX.H Version 2.3 */ +/* Name: TABFIX.H Version 2.4 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */ /* */ /* This file contains the TDBFIX and (FIX/BIN)COL classes declares. */ /***********************************************************************/ @@ -12,7 +12,7 @@ typedef class FIXCOL *PFIXCOL; typedef class BINCOL *PBINCOL; -typedef class TXTFAM *PTXF; +typedef class TXTFAM *PTXF; /***********************************************************************/ /* This is the DOS/UNIX Access Method class declaration for files */ @@ -53,7 +53,8 @@ class DllExport TDBFIX : public TDBDOS { protected: virtual bool PrepareWriting(PGLOBAL g) {return false;} - // Members are inherited from TDBDOS + // Members + char Teds; /* Binary table default endian setting */ }; // end of class TDBFIX /***********************************************************************/ @@ -68,17 +69,29 @@ class DllExport BINCOL : public DOSCOL { BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process // Implementation - virtual int GetAmType(void) {return TYPE_AM_BIN;} + virtual int GetAmType(void) {return TYPE_AM_BIN;} + int GetDeplac(void) {return Deplac;} + int GetFileSize(void) + {return N ? N : GetTypeSize(Buf_Type, Long);} // Methods - virtual void ReadColumn(PGLOBAL g); - virtual void WriteColumn(PGLOBAL g); + virtual void ReadColumn(PGLOBAL g); + virtual void WriteColumn(PGLOBAL g); + + // Static + static void SetEndian(void); protected: BINCOL(void) {} // Default constructor not to be used // Members - char Fmt; // The column numeric format + static char Endian; // The host endian setting (L or B) + char *Buff; // Utility buffer + char Eds; // The file endian setting + char Fmt; // The converted value format + int N; // The number of bytes in the file + int M; // The buffer type size + int Lim; // Min(N,M) }; // end of class BINCOL /***********************************************************************/ diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index d5f8dc50a89..015f8d93b15 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2001 - 2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2001 - 2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -20,7 +20,7 @@ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -102,14 +102,14 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep, } // endif info // num_max = atoi(p+1); // Max num of record to test -#if defined(WIN32) +#if defined(__WIN__) if (sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6)) dechar = '.'; else dechar = ','; -#else // !WIN32 +#else // !__WIN__ dechar = '.'; -#endif // !WIN32 +#endif // !__WIN__ if (trace) htrc("File %s sep=%c q=%c hdr=%d mxr=%d\n", @@ -147,7 +147,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep, if (fgets(buf, sizeof(buf), infile)) { n = strlen(buf) + 1; buf[n - 2] = '\0'; -#if defined(UNIX) +#if !defined(__WIN__) // The file can be imported from Windows if (buf[n - 3] == '\r') buf[n - 3] = 0; @@ -204,7 +204,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep, if (fgets(buf, sizeof(buf), infile)) { n = strlen(buf); buf[n - 1] = '\0'; -#if defined(UNIX) +#if !defined(__WIN__) // The file can be imported from Windows if (buf[n - 2] == '\r') buf[n - 2] = 0; @@ -625,7 +625,7 @@ bool TDBCSV::CheckErr(void) /***********************************************************************/ /* CSV EstimatedLength. Returns an estimated minimum line length. */ /***********************************************************************/ -int TDBCSV::EstimatedLength(PGLOBAL g) +int TDBCSV::EstimatedLength(void) { int n = 0; PCOLDEF cdp; @@ -1118,7 +1118,7 @@ PCOL TDBFMT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /* FMT EstimatedLength. Returns an estimated minimum line length. */ /* The big problem here is how can we astimated that minimum ? */ /***********************************************************************/ -int TDBFMT::EstimatedLength(PGLOBAL g) +int TDBFMT::EstimatedLength(void) { // This is rather stupid !!! return ((PDOSDEF)To_Def)->GetEnding() + (int)((Lrecl / 10) + 1); diff --git a/storage/connect/tabfmt.h b/storage/connect/tabfmt.h index 8a1e1f17561..ce80a276cdc 100644 --- a/storage/connect/tabfmt.h +++ b/storage/connect/tabfmt.h @@ -75,7 +75,7 @@ class TDBCSV : public TDBDOS { virtual int ReadBuffer(PGLOBAL g); // Physical file read // Specific routines - virtual int EstimatedLength(PGLOBAL g); + virtual int EstimatedLength(void); virtual bool SkipHeader(PGLOBAL g); virtual bool CheckErr(void); @@ -157,7 +157,7 @@ class TDBFMT : public TDBCSV { virtual int ReadBuffer(PGLOBAL g); // Physical file read // Specific routines - virtual int EstimatedLength(PGLOBAL g); + virtual int EstimatedLength(void); protected: virtual bool PrepareWriting(PGLOBAL g) diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 0231b369fc1..fafba6228b9 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -59,16 +59,15 @@ typedef struct _jncol { /* JSONColumns: construct the result blocks containing the description */ /* of all the columns of a table contained inside a JSON file. */ /***********************************************************************/ -PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, - int pretty, int lrecl, int lvl, bool info) +PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) { static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT}; static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0}; - char filename[_MAX_PATH], colname[65], fmt[129]; - int i, j, n = 0; + char *fn, colname[65], fmt[129]; + int i, j, lvl, n = 0; int ncol = sizeof(buftyp) / sizeof(int); PVAL valp; JCOL jcol; @@ -78,37 +77,42 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, PJVAL jvp; PJOB row; PJDEF tdp; - TDBJSN *tjnp; - PJTDB tjsp; + TDBJSN *tjnp = NULL; + PJTDB tjsp = NULL; PQRYRES qrp; PCOLRES crp; + jcol.Name = jcol.Fmt = NULL; + if (info) { length[0] = 128; length[7] = 256; goto skipit; } // endif info - if (trace) - htrc("File %s pretty=%d lvl=%d lrecl=%d\n", - SVP(fn), pretty, lvl, lrecl); - /*********************************************************************/ /* Open the input file. */ /*********************************************************************/ - if (!fn) { + if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) { strcpy(g->Message, MSG(MISSING_FNAME)); return NULL; - } else - PlugSetPath(filename, fn, dp); + } else { + lvl = GetIntegerTableOption(g, topt, "Level", 0); + lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl; + } // endif fn tdp = new(g) JSONDEF; - tdp->Database = dp; - tdp->Fn = filename; - tdp->Objname = objn; - tdp->Pretty = pretty; + tdp->Fn = fn; + tdp->Database = SetPath(g, db); + tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); + tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; + tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); + + if (trace) + htrc("File %s objname=%s pretty=%d lvl=%d\n", + tdp->Fn, tdp->Objname, tdp->Pretty, lvl); - if (pretty == 2) { + if (tdp->Pretty == 2) { tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp)); if (tjsp->MakeDocument(g)) @@ -116,13 +120,12 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; } else { - if (!lrecl) { - sprintf(g->Message, "LRECL must be specified for pretty=%d", pretty); + if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) { + sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); return NULL; } // endif lrecl - tdp->Lrecl = lrecl; - tdp->Ending = CRLF; + tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF); tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp)); tjnp->SetMode(MODE_READ); @@ -263,7 +266,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, jcp->Found = false; } // endfor jcp - if (pretty != 2) { + if (tdp->Pretty != 2) { // Read next record switch (tjnp->ReadDB(g)) { case RC_EF: @@ -283,7 +286,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, } // endor i - if (pretty != 2) + if (tdp->Pretty != 2) tjnp->CloseDB(g); skipit: @@ -339,7 +342,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, return qrp; err: - if (pretty != 2) + if (tdp->Pretty != 2) tjnp->CloseDB(g); return NULL; @@ -354,22 +357,21 @@ JSONDEF::JSONDEF(void) Xcol = NULL; Pretty = 2; Limit = 1; - Level = 0; - ReadMode = 0; + Base = 0; Strict = false; } // end of JSONDEF constructor /***********************************************************************/ /* DefineAM: define specific AM block values. */ /***********************************************************************/ -bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) { Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT); Objname = GetStringCatInfo(g, "Object", NULL); Xcol = GetStringCatInfo(g, "Expand", NULL); Pretty = GetIntCatInfo("Pretty", 2); - Level = GetIntCatInfo("Level", 0); Limit = GetIntCatInfo("Limit", 10); + Base = GetIntCatInfo("Base", 0) ? 1 : 0; return DOSDEF::DefineAM(g, "DOS", poff); } // end of DefineAM @@ -438,6 +440,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) Xcol = tdp->Xcol; Limit = tdp->Limit; Pretty = tdp->Pretty; + B = tdp->Base ? 1 : 0; Strict = tdp->Strict; } else { Jmode = MODE_OBJECT; @@ -445,11 +448,12 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) Xcol = NULL; Limit = 1; Pretty = 0; + B = 0; Strict = false; } // endif tdp Fpos = -1; - N = 0; + N = M = 0; NextSame = 0; SameRow = 0; Xval = -1; @@ -467,10 +471,12 @@ TDBJSN::TDBJSN(TDBJSN *tdbp) : TDBDOS(NULL, tdbp) Xcol = tdbp->Xcol; Fpos = tdbp->Fpos; N = tdbp->N; + M = tdbp->M; Limit = tdbp->Limit; NextSame = tdbp->NextSame; SameRow = tdbp->SameRow; Xval = tdbp->Xval; + B = tdbp->B; Pretty = tdbp->Pretty; Strict = tdbp->Strict; Comma = tdbp->Comma; @@ -506,7 +512,7 @@ PCOL TDBJSN::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/ -PCOL TDBJSN::InsertSpecialColumn(PGLOBAL g, PCOL colp) +PCOL TDBJSN::InsertSpecialColumn(PCOL colp) { if (!colp->IsSpecial()) return NULL; @@ -561,7 +567,7 @@ PJSON TDBJSN::FindRow(PGLOBAL g) jsp->GetObject()->GetValue(objpath) : NULL; } else if (objpath[strlen(objpath)-1] == ']') { val = (jsp->GetType() == TYPE_JAR) ? - jsp->GetArray()->GetValue(atoi(objpath+1) - 1) : NULL; + jsp->GetArray()->GetValue(atoi(objpath+1) - B) : NULL; } else val = NULL; @@ -617,11 +623,11 @@ bool TDBJSN::SkipHeader(PGLOBAL g) return true; #endif // _DEBUG -#if defined(WIN32) +#if defined(__WIN__) #define Ending 2 -#else // !WIN32 +#else // !__WIN__ #define Ending 1 -#endif // !WIN32 +#endif // !__WIN__ if (Pretty == 1) { if (Mode == MODE_INSERT || Mode == MODE_DELETE) { @@ -647,6 +653,7 @@ int TDBJSN::ReadDB(PGLOBAL g) if (NextSame) { SameRow = NextSame; NextSame = 0; + M++; return RC_OK; } else if ((rc = TDBDOS::ReadDB(g)) == RC_OK) if (!IsRead() && ((rc = ReadBuffer(g)) != RC_OK)) { @@ -658,6 +665,7 @@ int TDBJSN::ReadDB(PGLOBAL g) Row = FindRow(g); SameRow = 0; Fpos++; + M = 1; rc = RC_OK; } // endif's @@ -706,7 +714,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp) val->SetValue(arp); val = new(g) JVALUE; - i = atoi(objpath+1) - 1; + i = atoi(objpath+1) - B; arp->SetValue(g, val, i); arp->InitArray(g); } else { @@ -854,8 +862,8 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm) return true; else if (jnp->Op != OP_EXP) { if (b) { - // Return 1st value - jnp->Rank = 1; + // Return 1st value (B is the index base) + jnp->Rank = Tjp->B; jnp->Op = OP_EQ; } else if (!Value->IsTypeNum()) { jnp->CncVal = AllocateValue(g, (void*)", ", TYPE_STRING); @@ -866,13 +874,9 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm) } // endif OP } else if (dg) { - if (atoi(p) > 0) { - // Return nth value - jnp->Rank = atoi(p); - jnp->Op = OP_EQ; - } else // Ignore array - jnp->Op = OP_NULL; - + // Return nth value + jnp->Rank = atoi(p) - Tjp->B; + jnp->Op = OP_EQ; } else if (n == 1) { // Set the Op value; switch (*p) { @@ -1116,16 +1120,12 @@ PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i) arp = (PJAR)row; if (!Nodes[i].Key) { - if (Nodes[i].Op != OP_NULL) { - if (Nodes[i].Rank) { - val = arp->GetValue(Nodes[i].Rank - 1); - } else if (Nodes[i].Op == OP_EXP) { - return ExpandArray(g, arp, i); - } else - return CalculateArray(g, arp, i); - - } else - val = NULL; + if (Nodes[i].Op == OP_EQ) + val = arp->GetValue(Nodes[i].Rank); + else if (Nodes[i].Op == OP_EXP) + return ExpandArray(g, arp, i); + else + return CalculateArray(g, arp, i); } else if (i < Nod-1) { strcpy(g->Message, "Unexpected array"); @@ -1287,16 +1287,12 @@ PJSON JSONCOL::GetRow(PGLOBAL g) break; case TYPE_JAR: if (!Nodes[i].Key) { - if (Nodes[i].Op != OP_NULL) { - arp = (PJAR)row; - - if (Nodes[i].Rank) - val = arp->GetValue(Nodes[i].Rank - 1); - else - val = arp->GetValue(Nodes[i].Rx); + arp = (PJAR)row; - } else - val = NULL; + if (Nodes[i].Op == OP_EQ) + val = arp->GetValue(Nodes[i].Rank); + else + val = arp->GetValue(Nodes[i].Rx); } else { strcpy(g->Message, "Unexpected array"); @@ -1388,8 +1384,8 @@ void JSONCOL::WriteColumn(PGLOBAL g) } // endif jsp if (arp) { - if (Nod > 1 && Nodes[Nod-2].Rank) - arp->SetValue(g, new(g) JVALUE(jsp), Nodes[Nod-2].Rank-1); + if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ) + arp->SetValue(g, new(g) JVALUE(jsp), Nodes[Nod-2].Rank); else arp->AddValue(g, new(g) JVALUE(jsp)); @@ -1409,8 +1405,8 @@ void JSONCOL::WriteColumn(PGLOBAL g) case TYPE_INT: case TYPE_DOUBLE: if (arp) { - if (Nodes[Nod-1].Rank) - arp->SetValue(g, new(g) JVALUE(g, Value), Nodes[Nod-1].Rank-1); + if (Nodes[Nod-1].Op == OP_EQ) + arp->SetValue(g, new(g) JVALUE(g, Value), Nodes[Nod-1].Rank); else arp->AddValue(g, new(g) JVALUE(g, Value)); @@ -1486,7 +1482,7 @@ int TDBJSON::MakeNewDoc(PGLOBAL g) /***********************************************************************/ int TDBJSON::MakeDocument(PGLOBAL g) { - char *p, *memory, *objpath, *key; + char *p, *memory, *objpath, *key = NULL; int len, i = 0; MODE mode = Mode; PJSON jsp; @@ -1560,7 +1556,7 @@ int TDBJSON::MakeDocument(PGLOBAL g) arp = jsp->GetArray(); objp = NULL; - i = atoi(objpath+1) - 1; + i = atoi(objpath+1) - B; val = arp->GetValue(i); if (!val) { @@ -1646,7 +1642,7 @@ void TDBJSON::ResetSize(void) /***********************************************************************/ /* TDBJSON is not indexable. */ /***********************************************************************/ -int TDBJSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) +int TDBJSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool) { if (pxdf) { strcpy(g->Message, "JSON not indexable when pretty = 2"); @@ -1677,7 +1673,7 @@ int TDBJSON::GetRecpos(void) /***********************************************************************/ /* Set the position in the table. */ /***********************************************************************/ -bool TDBJSON::SetRecpos(PGLOBAL g, int recpos) +bool TDBJSON::SetRecpos(PGLOBAL, int recpos) { #if 0 union { @@ -1739,7 +1735,7 @@ bool TDBJSON::OpenDB(PGLOBAL g) /***********************************************************************/ /* ReadDB: Data Base read routine for JSON access method. */ /***********************************************************************/ -int TDBJSON::ReadDB(PGLOBAL g) +int TDBJSON::ReadDB(PGLOBAL) { int rc; @@ -1748,6 +1744,7 @@ int TDBJSON::ReadDB(PGLOBAL g) if (NextSame) { SameRow = NextSame; NextSame = false; + M++; rc = RC_OK; } else if (++Fpos < (signed)Doc->size()) { Row = Doc->GetValue(Fpos); @@ -1756,6 +1753,7 @@ int TDBJSON::ReadDB(PGLOBAL g) Row = ((PJVAL)Row)->GetJson(); SameRow = 0; + M = 1; rc = RC_OK; } else rc = RC_EF; @@ -1857,11 +1855,8 @@ void TDBJSON::CloseDB(PGLOBAL g) /***********************************************************************/ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) { - Fn = tdp->GetFn(); - Objn = tdp->Objname; - Pretty = tdp->Pretty; - Lrecl = tdp->Lrecl; - lvl = tdp->Level; + Topt = tdp->GetTopt(); + Db = (char*)tdp->GetDB(); } // end of TDBJCL constructor /***********************************************************************/ @@ -1869,8 +1864,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBJCL::GetResult(PGLOBAL g) { - return JSONColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, Objn, - Pretty, Lrecl, lvl, false); + return JSONColumns(g, Db, Topt, false); } // end of GetResult /* --------------------------- End of json --------------------------- */ diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h index 10b9a9a9cc3..4505d30a21c 100644 --- a/storage/connect/tabjson.h +++ b/storage/connect/tabjson.h @@ -36,8 +36,7 @@ class JSONDEF : public DOSDEF { /* Table description */ friend class TDBJSON; friend class TDBJSN; friend class TDBJCL; - friend PQRYRES JSONColumns(PGLOBAL, char *, const char *, char *, - int, int, int, bool); + friend PQRYRES JSONColumns(PGLOBAL, char*, PTOS, bool); public: // Constructor JSONDEF(void); @@ -57,6 +56,7 @@ class JSONDEF : public DOSDEF { /* Table description */ int Limit; /* Limit of multiple values */ int Pretty; /* Depends on file structure */ int Level; /* Used for catalog table */ + int Base; /* Tne array index base */ bool Strict; /* Strict syntax checking */ }; // end of JSONDEF @@ -82,9 +82,9 @@ class TDBJSN : public TDBDOS { // Methods virtual PTDB CopyOne(PTABS t); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); + virtual PCOL InsertSpecialColumn(PCOL colp); virtual int RowNumber(PGLOBAL g, bool b = FALSE) - {return (b) ? N : Fpos + 1;} + {return (b) ? M : N;} // Database routines virtual int Cardinality(PGLOBAL g); @@ -106,13 +106,14 @@ class TDBJSN : public TDBDOS { char *Objname; // The table object name char *Xcol; // Name of expandable column int Fpos; // The current row index -//int Spos; // DELETE start index int N; // The current Rownum + int M; // Index of multiple value int Limit; // Limit of multiple values int Pretty; // Depends on file structure int NextSame; // Same next row int SameRow; // Same row nb int Xval; // Index of expandable array + int B; // Array index base bool Strict; // Strict syntax checking bool Comma; // Row has final comma }; // end of class TDBJSN @@ -224,11 +225,6 @@ class TDBJCL : public TDBCAT { virtual PQRYRES GetResult(PGLOBAL g); // Members -//char *Dp; - const char *Fn; - char *Objn; - int Pretty; - int Lrecl; - int lvl; + PTOS Topt; + char *Db; }; // end of class TDBJCL - diff --git a/storage/connect/table.cpp b/storage/connect/table.cpp index d163c443cd5..933e072c1bb 100644 --- a/storage/connect/table.cpp +++ b/storage/connect/table.cpp @@ -1,7 +1,7 @@ /************** Table C++ Functions Source Code File (.CPP) ************/ /* Name: TABLE.CPP Version 2.7 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */ /* */ /* This file contains the TBX, TDB and OPJOIN classes functions. */ /***********************************************************************/ @@ -74,7 +74,7 @@ TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum) /***********************************************************************/ /* RowNumber: returns the current row ordinal number. */ /***********************************************************************/ -int TDB::RowNumber(PGLOBAL g, bool b) +int TDB::RowNumber(PGLOBAL g, bool) { sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType())); return 0; @@ -122,7 +122,7 @@ void TDB::Print(PGLOBAL g, FILE *f, uint n) } // end of Print -void TDB::Print(PGLOBAL g, char *ps, uint z) +void TDB::Print(PGLOBAL, char *ps, uint) { sprintf(ps, "R%d.%s", Tdb_No, Name); } // end of Print @@ -263,7 +263,7 @@ PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num) /***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/ -PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp) +PCOL TDBASE::InsertSpecialColumn(PCOL colp) { if (!colp->IsSpecial()) return NULL; @@ -327,7 +327,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp) return NULL; } // endif's name - if (!(colp = InsertSpecialColumn(g, colp))) { + if (!(colp = InsertSpecialColumn(colp))) { sprintf(g->Message, MSG(BAD_SPECIAL_COL), name); return NULL; } // endif Insert @@ -338,7 +338,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp) /***********************************************************************/ /* ResetTableOpt: Wrong for this table type. */ /***********************************************************************/ -int TDBASE::ResetTableOpt(PGLOBAL g, bool dop, bool dox) +int TDBASE::ResetTableOpt(PGLOBAL g, bool, bool) { strcpy(g->Message, "This table is not indexable"); return RC_INFO; @@ -365,7 +365,7 @@ void TDBASE::ResetKindex(PGLOBAL g, PKXBASE kxp) /***********************************************************************/ /* SetRecpos: Replace the table at the specified position. */ /***********************************************************************/ -bool TDBASE::SetRecpos(PGLOBAL g, int recpos) +bool TDBASE::SetRecpos(PGLOBAL g, int) { strcpy(g->Message, MSG(SETRECPOS_NIY)); return true; @@ -386,7 +386,7 @@ void TDBASE::PrintAM(FILE *f, char *m) /* Two questions here: exact meaning of U_J_INT ? */ /* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */ /***********************************************************************/ -void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2) +void TDBASE::MarkDB(PGLOBAL, PTDB tdb2) { if (trace) htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2); @@ -453,7 +453,7 @@ bool TDBCAT::Initialize(PGLOBAL g) /***********************************************************************/ /* CAT: Get the number of properties. */ /***********************************************************************/ -int TDBCAT::GetMaxSize(PGLOBAL g) +int TDBCAT::GetMaxSize(PGLOBAL g __attribute__((unused))) { if (MaxSize < 0) { // if (Initialize(g)) @@ -528,7 +528,7 @@ bool TDBCAT::InitCol(PGLOBAL g) /***********************************************************************/ /* SetRecpos: Replace the table at the specified position. */ /***********************************************************************/ -bool TDBCAT::SetRecpos(PGLOBAL g, int recpos) +bool TDBCAT::SetRecpos(PGLOBAL, int recpos) { N = recpos - 1; return false; @@ -537,7 +537,7 @@ bool TDBCAT::SetRecpos(PGLOBAL g, int recpos) /***********************************************************************/ /* Data Base read routine for CAT access method. */ /***********************************************************************/ -int TDBCAT::ReadDB(PGLOBAL g) +int TDBCAT::ReadDB(PGLOBAL) { return (++N < Qrp->Nblin) ? RC_OK : RC_EF; } // end of ReadDB @@ -554,7 +554,7 @@ int TDBCAT::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for CAT access methods. */ /***********************************************************************/ -int TDBCAT::DeleteDB(PGLOBAL g, int irc) +int TDBCAT::DeleteDB(PGLOBAL g, int) { strcpy(g->Message, "Delete not enabled for CAT tables"); return RC_FX; @@ -563,7 +563,7 @@ int TDBCAT::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for WMI access method. */ /***********************************************************************/ -void TDBCAT::CloseDB(PGLOBAL g) +void TDBCAT::CloseDB(PGLOBAL) { // Nothing to do } // end of CloseDB @@ -584,7 +584,7 @@ CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n) /***********************************************************************/ /* Read the next Data Source elements. */ /***********************************************************************/ -void CATCOL::ReadColumn(PGLOBAL g) +void CATCOL::ReadColumn(PGLOBAL) { // Get the value of the Name or Description property if (Crp->Kdata) diff --git a/storage/connect/tabmac.cpp b/storage/connect/tabmac.cpp index f072465ced5..e6e2abb54e2 100644 --- a/storage/connect/tabmac.cpp +++ b/storage/connect/tabmac.cpp @@ -3,12 +3,12 @@ /* From the article and sample code by Khalid Shaikh. */ /* TABMAC: virtual table to get the list of MAC addresses. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) #include "my_global.h" //#include <iphlpapi.h> -#else // !WIN32 -#error This is a WIN32 only table type -#endif // !WIN32 +#else // !__WIN__ +#error This is a WINDOWS only table type +#endif // !__WIN__ #include "global.h" #include "plgdbsem.h" //#include "catalog.h" diff --git a/storage/connect/tabmac.h b/storage/connect/tabmac.h index 5e6c98d68fb..f9a66e82eaa 100644 --- a/storage/connect/tabmac.h +++ b/storage/connect/tabmac.h @@ -1,11 +1,11 @@ // TABMAC.H Olivier Bertrand 2011-2012 // MAC: virtual table to Get Mac Addresses via GetAdaptersInfo -#if defined(WIN32) +#if defined(__WIN__) #include <windows.h> #include <iphlpapi.h> -#else // !WIN32 -#error This is a WIN32 only table TYPE -#endif // !WIN32 +#else // !__WIN__ +#error This is a WINDOWS only table TYPE +#endif // !__WIN__ /***********************************************************************/ /* Definitions. */ diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 94950584c9b..3008ca1b8ca 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -37,7 +37,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -145,7 +145,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) /*******************************************************************/ /* To_File is a multiple name with special characters */ /*******************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) char drive[_MAX_DRIVE], direc[_MAX_DIR]; WIN32_FIND_DATA FileData; HANDLE hSearch; @@ -196,7 +196,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) return true; } // endif FindClose -#else // !WIN32 +#else // !__WIN__ struct stat fileinfo; char fn[FN_REFLEN], direc[FN_REFLEN], pattern[FN_HEADLEN], ftype[FN_EXTLEN]; DIR *dir; @@ -249,7 +249,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) // Close the dir handle. closedir(dir); -#endif // !WIN32 +#endif // !__WIN__ } else { /*******************************************************************/ @@ -269,7 +269,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) p = filename + strlen(filename) - 1; -#if defined(UNIX) +#if !defined(__WIN__) // Data files can be imported from Windows (having CRLF) if (*p == '\n' || *p == '\r') { // is this enough for Unix ??? @@ -297,7 +297,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) } // endif Mul -#if defined(WIN32) +#if defined(__WIN__) suite: #endif @@ -561,7 +561,7 @@ int TDBMUL::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for MUL access method. */ /***********************************************************************/ -int TDBMUL::DeleteDB(PGLOBAL g, int irc) +int TDBMUL::DeleteDB(PGLOBAL g, int) { // When implementing DELETE_MODE InitFileNames must be updated to // eliminate CRLF under Windows if the file is read in binary. @@ -586,7 +586,7 @@ void TDBMUL::CloseDB(PGLOBAL g) /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ -bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR, int) { Desc = Fn = GetStringCatInfo(g, "Filename", NULL); Incl = (GetIntCatInfo("Subdir", 0) != 0); @@ -597,7 +597,7 @@ bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new Table Description Block. */ /***********************************************************************/ -PTDB DIRDEF::GetTable(PGLOBAL g, MODE m) +PTDB DIRDEF::GetTable(PGLOBAL g, MODE) { #if 0 if (Huge) @@ -620,17 +620,17 @@ TDBDIR::TDBDIR(PDIRDEF tdp) : TDBASE(tdp) { To_File = tdp->Fn; iFile = 0; -#if defined(WIN32) +#if defined(__WIN__) memset(&FileData, 0, sizeof(_finddata_t)); Hsearch = -1; *Drive = '\0'; -#else // !WIN32 +#else // !__WIN__ memset(&Fileinfo, 0, sizeof(struct stat)); Entry = NULL; Dir = NULL; Done = false; *Pattern = '\0'; -#endif // !WIN32 +#endif // !__WIN__ *Fpath = '\0'; *Direc = '\0'; *Fname = '\0'; @@ -641,17 +641,17 @@ TDBDIR::TDBDIR(PTDBDIR tdbp) : TDBASE(tdbp) { To_File = tdbp->To_File; iFile = tdbp->iFile; -#if defined(WIN32) +#if defined(__WIN__) FileData = tdbp->FileData; Hsearch = tdbp->Hsearch; strcpy(Drive, tdbp->Drive); -#else // !WIN32 +#else // !__WIN__ Fileinfo = tdbp->Fileinfo; Entry = tdbp->Entry; Dir = tdbp->Dir; Done = tdbp->Done; strcpy(Pattern, tdbp->Pattern); -#endif // !WIN32 +#endif // !__WIN__ strcpy(Direc, tdbp->Direc); strcpy(Fname, tdbp->Fname); strcpy(Ftype, tdbp->Ftype); @@ -675,7 +675,7 @@ char* TDBDIR::Path(PGLOBAL g) { PCATLG cat = PlgGetCatalog(g); -#if defined(WIN32) +#if defined(__WIN__) if (!*Drive) { PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath()); _splitpath(Fpath, Drive, Direc, Fname, Ftype); @@ -683,7 +683,7 @@ char* TDBDIR::Path(PGLOBAL g) _makepath(Fpath, Drive, Direc, Fname, Ftype); // Usefull ??? return Fpath; -#else // !WIN32 +#else // !__WIN__ if (!Done) { PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath()); _splitpath(Fpath, NULL, Direc, Fname, Ftype); @@ -692,7 +692,7 @@ char* TDBDIR::Path(PGLOBAL g) } // endif Done return Pattern; -#endif // !WIN32 +#endif // !__WIN__ } // end of Path /***********************************************************************/ @@ -710,7 +710,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { int n = -1; -#if defined(WIN32) +#if defined(__WIN__) int h; // Start searching files in the target directory. @@ -726,7 +726,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) } else n = 0; -#else // !WIN32 +#else // !__WIN__ Path(g); // Start searching files in the target directory. @@ -750,7 +750,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) // Close the DIR handle. closedir(Dir); -#endif // !WIN32 +#endif // !__WIN__ MaxSize = n; } // endif MaxSize @@ -776,10 +776,10 @@ bool TDBDIR::OpenDB(PGLOBAL g) } // endif use Use = USE_OPEN; -#if !defined(WIN32) +#if !defined(__WIN__) Path(g); // Be sure it is done Dir = NULL; // For ReadDB -#endif // !WIN32 +#endif // !__WIN__ return false; } // end of OpenDB @@ -790,7 +790,7 @@ int TDBDIR::ReadDB(PGLOBAL g) { int rc = RC_OK; -#if defined(WIN32) +#if defined(__WIN__) if (Hsearch == -1) { /*******************************************************************/ /* Start searching files in the target directory. The use of the */ @@ -848,7 +848,7 @@ int TDBDIR::ReadDB(PGLOBAL g) rc = RC_EF; } // endif Entry -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of ReadDB @@ -865,7 +865,7 @@ int TDBDIR::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for DIR access method. */ /***********************************************************************/ -int TDBDIR::DeleteDB(PGLOBAL g, int irc) +int TDBDIR::DeleteDB(PGLOBAL g, int) { strcpy(g->Message, MSG(TABDIR_READONLY)); return RC_FX; // NIY @@ -874,19 +874,19 @@ int TDBDIR::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for MUL access method. */ /***********************************************************************/ -void TDBDIR::CloseDB(PGLOBAL g) +void TDBDIR::CloseDB(PGLOBAL) { -#if defined(WIN32) +#if defined(__WIN__) // Close the search handle. _findclose(Hsearch); Hsearch = -1; -#else // !WIN32 +#else // !__WIN__ // Close the DIR handle if (Dir) { closedir(Dir); Dir = NULL; } // endif dir -#endif // !WIN32 +#endif // !__WIN__ iFile = 0; } // end of CloseDB @@ -895,7 +895,7 @@ void TDBDIR::CloseDB(PGLOBAL g) /***********************************************************************/ /* DIRCOL public constructor. */ /***********************************************************************/ -DIRCOL::DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) +DIRCOL::DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) : COLBLK(cdp, tdbp, i) { if (cprec) { @@ -935,19 +935,19 @@ void DIRCOL::ReadColumn(PGLOBAL g) /* Retrieve the information corresponding to the column number. */ /*********************************************************************/ switch (N) { -#if defined(WIN32) +#if defined(__WIN__) case 0: Value->SetValue_psz(tdbp->Drive); break; -#endif // WIN32 +#endif // __WIN__ case 1: Value->SetValue_psz(tdbp->Direc); break; case 2: Value->SetValue_psz(tdbp->Fname); break; case 3: Value->SetValue_psz(tdbp->Ftype); break; -#if defined(WIN32) +#if defined(__WIN__) case 4: Value->SetValue((int)tdbp->FileData.attrib); break; case 5: Value->SetValue((int)tdbp->FileData.size); break; case 6: Value->SetValue((int)tdbp->FileData.time_write); break; case 7: Value->SetValue((int)tdbp->FileData.time_create); break; case 8: Value->SetValue((int)tdbp->FileData.time_access); break; -#else // !WIN32 +#else // !__WIN__ case 4: Value->SetValue((int)tdbp->Fileinfo.st_mode); break; case 5: Value->SetValue((int)tdbp->Fileinfo.st_size); break; case 6: Value->SetValue((int)tdbp->Fileinfo.st_mtime); break; @@ -955,7 +955,7 @@ void DIRCOL::ReadColumn(PGLOBAL g) case 8: Value->SetValue((int)tdbp->Fileinfo.st_atime); break; case 9: Value->SetValue((int)tdbp->Fileinfo.st_uid); break; case 10: Value->SetValue((int)tdbp->Fileinfo.st_gid); break; -#endif // !WIN32 +#endif // !__WIN__ default: sprintf(g->Message, MSG(INV_DIRCOL_OFST), N); longjmp(g->jumper[g->jump_level], GetAmType()); @@ -1006,7 +1006,7 @@ int TDBSDR::FindInDir(PGLOBAL g) size_t m = strlen(Direc); // Start searching files in the target directory. -#if defined(WIN32) +#if defined(__WIN__) int h = _findfirst(Path(g), &FileData); if (h != -1) { @@ -1039,7 +1039,7 @@ int TDBSDR::FindInDir(PGLOBAL g) // Close the search handle. _findclose(h); } // endif h -#else // !WIN32 +#else // !__WIN__ int k; DIR *dir = opendir(Direc); @@ -1073,7 +1073,7 @@ int TDBSDR::FindInDir(PGLOBAL g) // Close the DIR handle. closedir(dir); -#endif // !WIN32 +#endif // !__WIN__ return n; } // end of FindInDir @@ -1089,13 +1089,13 @@ bool TDBSDR::OpenDB(PGLOBAL g) Sub = (PSUBDIR)PlugSubAlloc(g, NULL, sizeof(SUBDIR)); Sub->Next = NULL; Sub->Prev = NULL; -#if defined(WIN32) +#if defined(__WIN__) Sub->H = -1; Sub->Len = strlen(Direc); -#else // !WIN32 +#else // !__WIN__ Sub->D = NULL; Sub->Len = 0; -#endif // !WIN32 +#endif // !__WIN__ } // endif To_Sub return TDBDIR::OpenDB(g); @@ -1108,7 +1108,7 @@ int TDBSDR::ReadDB(PGLOBAL g) { int rc; -#if defined(WIN32) +#if defined(__WIN__) again: rc = TDBDIR::ReadDB(g); @@ -1160,7 +1160,7 @@ int TDBSDR::ReadDB(PGLOBAL g) } // endif H } // endif rc -#else // !WIN32 +#else // !__WIN__ rc = RC_NF; again: @@ -1217,7 +1217,7 @@ int TDBSDR::ReadDB(PGLOBAL g) } // endif Entry -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of ReadDB diff --git a/storage/connect/tabmul.h b/storage/connect/tabmul.h index 379e8f88e93..433cc3a2ee3 100644 --- a/storage/connect/tabmul.h +++ b/storage/connect/tabmul.h @@ -6,14 +6,14 @@ /* */ /* This file contains the TDBMUL and TDBDIR classes declares. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> -#else // !WIN32 +#else // !__WIN__ #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <dirent.h> -#endif // !WIN32 +#endif // !__WIN__ //#include "osutil.h" #include "block.h" @@ -132,17 +132,17 @@ class TDBDIR : public TDBASE { // Members PSZ To_File; // Points to file search pathname int iFile; // Index of currently retrieved file -#if defined(WIN32) +#if defined(__WIN__) _finddata_t FileData; // Find data structure int Hsearch; // Search handle char Drive[_MAX_DRIVE]; // Drive name -#else // !WIN32 +#else // !__WIN__ struct stat Fileinfo; // File info structure struct dirent *Entry; // Point to directory entry structure DIR *Dir; // To searched directory structure bool Done; // true when _splipath is done char Pattern[_MAX_FNAME+_MAX_EXT]; -#endif // !WIN32 +#endif // !__WIN__ char Fpath[_MAX_PATH]; // Absolute file search pattern char Direc[_MAX_DIR]; // Search path char Fname[_MAX_FNAME]; // File name @@ -183,11 +183,11 @@ class TDBSDR : public TDBDIR { typedef struct _Sub_Dir { struct _Sub_Dir *Next; struct _Sub_Dir *Prev; -#if defined(WIN32) +#if defined(__WIN__) int H; // Search handle -#else // !WIN32 +#else // !__WIN__ DIR *D; -#endif // !WIN32 +#endif // !__WIN__ size_t Len; // Initial directory name length } SUBDIR, *PSUBDIR; diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index b18e4da2ec4..19a5dfd758f 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -5,7 +5,7 @@ /* */ /* AUTHOR: */ /* ------- */ -/* Olivier BERTRAND 2007-2014 */ +/* Olivier BERTRAND 2007-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -35,9 +35,9 @@ #include "my_global.h" #include "sql_class.h" #include "sql_servers.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ //#include <fnmatch.h> //#include <errno.h> #include <stdlib.h> @@ -46,7 +46,7 @@ #include "osutil.h" //#include <io.h> //#include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -307,7 +307,7 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b) /***********************************************************************/ /* DefineAM: define specific AM block values from XCV file. */ /***********************************************************************/ -bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int) { char *url; @@ -380,7 +380,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB MYSQLDEF::GetTable(PGLOBAL g, MODE m) +PTDB MYSQLDEF::GetTable(PGLOBAL g, MODE) { if (Xsrc) return new(g) TDBMYEXC(this); @@ -438,7 +438,7 @@ TDBMYSQL::TDBMYSQL(PMYDEF tdp) : TDBASE(tdp) Nparm = 0; } // end of TDBMYSQL constructor -TDBMYSQL::TDBMYSQL(PGLOBAL g, PTDBMY tdbp) : TDBASE(tdbp) +TDBMYSQL::TDBMYSQL(PTDBMY tdbp) : TDBASE(tdbp) { Host = tdbp->Host; Database = tdbp->Database; @@ -468,7 +468,7 @@ PTDB TDBMYSQL::CopyOne(PTABS t) PCOL cp1, cp2; PGLOBAL g = t->G; - tp = new(g) TDBMYSQL(g, this); + tp = new(g) TDBMYSQL(this); for (cp1 = Columns; cp1; cp1 = cp1->GetNext()) { cp2 = new(g) MYSQLCOL((PMYCOL)cp1, tp); @@ -816,7 +816,7 @@ int TDBMYSQL::GetMaxSize(PGLOBAL g) /***********************************************************************/ /* This a fake routine as ROWID does not exist in MySQL. */ /***********************************************************************/ -int TDBMYSQL::RowNumber(PGLOBAL g, bool b) +int TDBMYSQL::RowNumber(PGLOBAL, bool) { return N + 1; } // end of RowNumber @@ -832,7 +832,7 @@ int TDBMYSQL::GetProgMax(PGLOBAL g) /***********************************************************************/ /* MySQL Bind Parameter function. */ /***********************************************************************/ -int TDBMYSQL::BindColumns(PGLOBAL g) +int TDBMYSQL::BindColumns(PGLOBAL g __attribute__((unused))) { #if defined(MYSQL_PREPARED_STATEMENTS) if (Prep) { @@ -1425,7 +1425,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g) /***********************************************************************/ /* WriteColumn: make sure the bind buffer is updated. */ /***********************************************************************/ -void MYSQLCOL::WriteColumn(PGLOBAL g) +void MYSQLCOL::WriteColumn(PGLOBAL) { /*********************************************************************/ /* Do convert the column value if necessary. */ @@ -1463,7 +1463,7 @@ TDBMYEXC::TDBMYEXC(PMYDEF tdp) : TDBMYSQL(tdp) Nerr = 0; } // end of TDBMYEXC constructor -TDBMYEXC::TDBMYEXC(PGLOBAL g, PTDBMYX tdbp) : TDBMYSQL(g, tdbp) +TDBMYEXC::TDBMYEXC(PTDBMYX tdbp) : TDBMYSQL(tdbp) { Cmdlist = tdbp->Cmdlist; Cmdcol = tdbp->Cmdcol; @@ -1481,7 +1481,7 @@ PTDB TDBMYEXC::CopyOne(PTABS t) PCOL cp1, cp2; PGLOBAL g = t->G; - tp = new(g) TDBMYEXC(g, this); + tp = new(g) TDBMYEXC(this); for (cp1 = Columns; cp1; cp1 = cp1->GetNext()) { cp2 = new(g) MYXCOL((PMYXCOL)cp1, tp); @@ -1534,7 +1534,7 @@ PCMD TDBMYEXC::MakeCMD(PGLOBAL g) /***********************************************************************/ /* EXC GetMaxSize: returns the maximum number of rows in the table. */ /***********************************************************************/ -int TDBMYEXC::GetMaxSize(PGLOBAL g) +int TDBMYEXC::GetMaxSize(PGLOBAL) { if (MaxSize < 0) { MaxSize = 10; // a guess @@ -1711,7 +1711,7 @@ void MYXCOL::ReadColumn(PGLOBAL g) /***********************************************************************/ /* WriteColumn: should never be called. */ /***********************************************************************/ -void MYXCOL::WriteColumn(PGLOBAL g) +void MYXCOL::WriteColumn(PGLOBAL) { assert(false); } // end of WriteColumn diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h index 99930d43a57..17d7b190340 100644 --- a/storage/connect/tabmysql.h +++ b/storage/connect/tabmysql.h @@ -73,11 +73,11 @@ class TDBMYSQL : public TDBASE { public: // Constructor TDBMYSQL(PMYDEF tdp); - TDBMYSQL(PGLOBAL g, PTDBMY tdbp); + TDBMYSQL(PTDBMY tdbp); // Implementation virtual AMT GetAmType(void) {return TYPE_AM_MYSQL;} - virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(g, this);} + virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(this);} // Methods virtual PTDB CopyOne(PTABS t); @@ -180,11 +180,11 @@ class TDBMYEXC : public TDBMYSQL { public: // Constructors TDBMYEXC(PMYDEF tdp); - TDBMYEXC(PGLOBAL g, PTDBMYX tdbp); + TDBMYEXC(PTDBMYX tdbp); // Implementation virtual AMT GetAmType(void) {return TYPE_AM_MYX;} - virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYEXC(g, this);} + virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYEXC(this);} // Methods virtual PTDB CopyOne(PTABS t); diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 7f7b1c5d50c..07e260154e0 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -13,7 +13,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -266,7 +266,7 @@ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m) +PTDB OCCURDEF::GetTable(PGLOBAL g, MODE) { if (Catfunc != FNC_COL) return new(g) TDBOCCUR(this); @@ -432,7 +432,7 @@ int TDBOCCUR::GetMaxSize(PGLOBAL g) /* In this sample, ROWID will be the (virtual) row number, */ /* while ROWNUM will be the occurence rank in the multiple column. */ /***********************************************************************/ -int TDBOCCUR::RowNumber(PGLOBAL g, bool b) +int TDBOCCUR::RowNumber(PGLOBAL, bool b) { return (b) ? M : N; } // end of RowNumber @@ -567,7 +567,7 @@ void OCCURCOL::ReadColumn(PGLOBAL g) /* ReadColumn: what this routine does is to access the Mth columns of */ /* list, extract its name and set to it the rank column value. */ /***********************************************************************/ -void RANKCOL::ReadColumn(PGLOBAL g) +void RANKCOL::ReadColumn(PGLOBAL) { PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb; PCOL *col = tdbp->Col; diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index 3bf1238cebc..307509848f4 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -35,7 +35,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) @@ -1268,6 +1268,10 @@ void ODBCCOL::ReadColumn(PGLOBAL g) } // endif Buf_Type + // Handle null values + if (Value->IsZero()) + Value->SetNull(Nullable); + if (trace) { char buf[64]; @@ -1393,7 +1397,7 @@ void ODBCCOL::WriteColumn(PGLOBAL g) /* -------------------------- Class TDBXDBC -------------------------- */ /***********************************************************************/ -/* Implementation of the TDBODBC class. */ +/* Implementation of the TDBXDBC class. */ /***********************************************************************/ TDBXDBC::TDBXDBC(PODEF tdp) : TDBODBC(tdp) { diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 401ffa3780e..b628e26d3c7 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -17,7 +17,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(WIN32) +#if defined(__WIN__) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif @@ -376,7 +376,7 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB PIVOTDEF::GetTable(PGLOBAL g, MODE m) +PTDB PIVOTDEF::GetTable(PGLOBAL g, MODE) { return new(g) TDBPIVOT(this); } // end of GetTable @@ -634,7 +634,7 @@ bool TDBPIVOT::MakeViewColumns(PGLOBAL g) /***********************************************************************/ /* PIVOT GetMaxSize: returns the maximum number of rows in the table. */ /***********************************************************************/ -int TDBPIVOT::GetMaxSize(PGLOBAL g) +int TDBPIVOT::GetMaxSize(PGLOBAL g __attribute__((unused))) { #if 0 if (MaxSize < 0) @@ -649,7 +649,7 @@ int TDBPIVOT::GetMaxSize(PGLOBAL g) /* In this sample, ROWID will be the (virtual) row number, */ /* while ROWNUM will be the occurence rank in the multiple column. */ /***********************************************************************/ -int TDBPIVOT::RowNumber(PGLOBAL g, bool b) +int TDBPIVOT::RowNumber(PGLOBAL, bool b) { return (b) ? M : N; } // end of RowNumber @@ -806,7 +806,7 @@ int TDBPIVOT::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for PIVOT access methods. */ /***********************************************************************/ -int TDBPIVOT::DeleteDB(PGLOBAL g, int irc) +int TDBPIVOT::DeleteDB(PGLOBAL g, int) { sprintf(g->Message, MSG(NO_TABLE_DEL), "PIVOT"); return RC_FX; diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp index 3ed182c5e33..76890e84429 100644 --- a/storage/connect/tabsys.cpp +++ b/storage/connect/tabsys.cpp @@ -3,7 +3,7 @@ /* ------------- */ /* Version 2.3 */ /* */ -/* Author Olivier BERTRAND 2004-2014 */ +/* Author Olivier BERTRAND 2004-2015 */ /* */ /* This program are the INI/CFG tables classes. */ /***********************************************************************/ @@ -12,12 +12,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -25,7 +25,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -36,9 +36,9 @@ #include "global.h" #include "plgdbsem.h" #include "reldef.h" -#if !defined(WIN32) +#if !defined(__WIN__) #include "osutil.h" -#endif // !WIN32 +#endif // !__WIN__ #include "filamtxt.h" #include "tabdos.h" #include "tabsys.h" @@ -48,10 +48,10 @@ #define CSZ 36 // Column section name length #define CDZ 256 // Column definition length -#if !defined(WIN32) +#if !defined(__WIN__) #define GetPrivateProfileSectionNames(S,L,I) \ GetPrivateProfileString(NULL,NULL,"",S,L,I) -#endif // !WIN32 +#endif // !__WIN__ /* -------------- Implementation of the INI classes ------------------ */ @@ -70,7 +70,7 @@ INIDEF::INIDEF(void) /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ -bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool INIDEF::DefineAM(PGLOBAL g, LPCSTR, int) { char buf[8]; @@ -96,7 +96,7 @@ bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB INIDEF::GetTable(PGLOBAL g, MODE m) +PTDB INIDEF::GetTable(PGLOBAL g, MODE) { PTDBASE tdbp; @@ -123,7 +123,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g) // Delete the INI table file if not protected if (!IsReadOnly()) { PlugSetPath(filename, Fn, GetPath()); -#if defined(WIN32) +#if defined(__WIN__) rc = !DeleteFile(filename); #else // UNIX rc = remove(filename); @@ -277,49 +277,27 @@ bool TDBINI::OpenDB(PGLOBAL g) /***********************************************************************/ /* Data Base read routine for INI access method. */ /***********************************************************************/ -int TDBINI::ReadDB(PGLOBAL g) +int TDBINI::ReadDB(PGLOBAL) { /*********************************************************************/ /* Now start the pseudo reading process. */ /*********************************************************************/ -#if 0 // INI tables are not indexable - if (To_Kindex) { - /*******************************************************************/ - /* Reading is by an index table. */ - /*******************************************************************/ - int recpos = To_Kindex->Fetch(g); - - switch (recpos) { - case -1: // End of file reached - return RC_EF; - case -2: // No match for join - return RC_NF; - case -3: // Same record as last non null one - return RC_OK; - default: - Section = (char*)recpos; // No good on 64 bit machines - } // endswitch recpos - - } else { -#endif // 0 - if (!Section) - Section = Seclist; - else - Section += (strlen(Section) + 1); - - if (trace > 1) - htrc("INI ReadDB: section=%s N=%d\n", Section, N); + if (!Section) + Section = Seclist; + else + Section += (strlen(Section) + 1); - N++; -//} // endif To_Kindex + if (trace > 1) + htrc("INI ReadDB: section=%s N=%d\n", Section, N); + N++; return (*Section) ? RC_OK : RC_EF; } // end of ReadDB /***********************************************************************/ /* WriteDB: Data Base write routine for INI access methods. */ /***********************************************************************/ -int TDBINI::WriteDB(PGLOBAL g) +int TDBINI::WriteDB(PGLOBAL) { // This is to check that section name was given when inserting if (Mode == MODE_INSERT) @@ -365,11 +343,11 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for INI access methods. */ /***********************************************************************/ -void TDBINI::CloseDB(PGLOBAL g) +void TDBINI::CloseDB(PGLOBAL) { -#if !defined(WIN32) +#if !defined(__WIN__) PROFILE_Close(Ifile); -#endif // !WIN32 +#endif // !__WIN__ } // end of CloseDB // ------------------------ INICOL functions ---------------------------- @@ -377,7 +355,7 @@ void TDBINI::CloseDB(PGLOBAL g) /***********************************************************************/ /* INICOL public constructor. */ /***********************************************************************/ -INICOL::INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) +INICOL::INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) : COLBLK(cdp, tdbp, i) { if (cprec) { @@ -471,7 +449,7 @@ bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) /* from the corresponding section, extract from it the key value */ /* corresponding to this column name and convert it to buffer type. */ /***********************************************************************/ -void INICOL::ReadColumn(PGLOBAL g) +void INICOL::ReadColumn(PGLOBAL) { PTDBINI tdbp = (PTDBINI)To_Tdb; @@ -747,7 +725,7 @@ int TDBXIN::ReadDB(PGLOBAL g) /***********************************************************************/ /* WriteDB: Data Base write routine for XIN access methods. */ /***********************************************************************/ -int TDBXIN::WriteDB(PGLOBAL g) +int TDBXIN::WriteDB(PGLOBAL) { // To check that section and key names were given when inserting if (Mode == MODE_INSERT) { @@ -809,7 +787,7 @@ XINCOL::XINCOL(XINCOL *col1, PTDB tdbp) : INICOL(col1, tdbp) /* from the corresponding section, extract from it the key value */ /* corresponding to this column name and convert it to buffer type. */ /***********************************************************************/ -void XINCOL::ReadColumn(PGLOBAL g) +void XINCOL::ReadColumn(PGLOBAL) { PTDBXIN tdbp = (PTDBXIN)To_Tdb; diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 2bf26a5f183..7f979eaf4be 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -39,7 +39,7 @@ //#include "sql_base.h" #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -73,15 +73,15 @@ #include "tabmysql.h" #include "ha_connect.h" -#if defined(WIN32) +#if defined(__WIN__) #if defined(__BORLANDC__) #define SYSEXIT void _USERENTRY #else #define SYSEXIT void #endif -#else // !WIN32 +#else // !__WIN__ #define SYSEXIT void * -#endif // !WIN32 +#endif // !__WIN__ /* ---------------------------- Class TBLDEF ---------------------------- */ @@ -101,7 +101,7 @@ TBLDEF::TBLDEF(void) /**************************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /**************************************************************************/ -bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR, int) { char *tablist, *dbname, *def = NULL; @@ -161,7 +161,7 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new Table Description Block. */ /***********************************************************************/ -PTDB TBLDEF::GetTable(PGLOBAL g, MODE m) +PTDB TBLDEF::GetTable(PGLOBAL g, MODE) { if (Catfunc == FNC_COL) return new(g) TDBTBC(this); @@ -202,7 +202,7 @@ PCOL TDBTBL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/ -PCOL TDBTBL::InsertSpecialColumn(PGLOBAL g, PCOL scp) +PCOL TDBTBL::InsertSpecialColumn(PCOL scp) { PCOL colp; @@ -548,7 +548,7 @@ int TDBTBL::ReadDB(PGLOBAL g) /***********************************************************************/ /* ReadColumn: */ /***********************************************************************/ -void TBTBLK::ReadColumn(PGLOBAL g) +void TBTBLK::ReadColumn(PGLOBAL) { if (trace) htrc("TBT ReadColumn: name=%s\n", Name); diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index 8bf440985ea..9d3f297f9e7 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -81,7 +81,7 @@ class DllExport TDBTBL : public TDBPRX { virtual int Cardinality(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g); virtual int RowNumber(PGLOBAL g, bool b = FALSE); - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); + virtual PCOL InsertSpecialColumn(PCOL scp); virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g); diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index c26d766af01..331a7f45d4d 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -14,7 +14,7 @@ #include "sql_class.h" #include "table.h" #include "field.h" -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -292,7 +292,7 @@ PRXDEF::PRXDEF(void) /***********************************************************************/ /* DefineAM: define specific AM block values from XCOL file. */ /***********************************************************************/ -bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR, int) { char *pn, *db, *tab, *def = NULL; @@ -322,7 +322,7 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB PRXDEF::GetTable(PGLOBAL g, MODE mode) +PTDB PRXDEF::GetTable(PGLOBAL g, MODE) { if (Catfunc == FNC_COL) return new(g) TDBTBC(this); @@ -341,7 +341,7 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp) Tdbp = NULL; // The object table } // end of TDBPRX constructor -TDBPRX::TDBPRX(PGLOBAL g, PTDBPRX tdbp) : TDBASE(tdbp) +TDBPRX::TDBPRX(PTDBPRX tdbp) : TDBASE(tdbp) { Tdbp = tdbp->Tdbp; } // end of TDBPRX copy constructor @@ -353,7 +353,7 @@ PTDB TDBPRX::CopyOne(PTABS t) PPRXCOL cp1, cp2; PGLOBAL g = t->G; - tp = new(g) TDBPRX(g, this); + tp = new(g) TDBPRX(this); for (cp1 = (PPRXCOL)Columns; cp1; cp1 = (PPRXCOL)cp1->GetNext()) { cp2 = new(g) PRXCOL(cp1, tp); // Make a copy diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index c5935d72184..b320d169b36 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -59,12 +59,12 @@ class DllExport TDBPRX : public TDBASE { public: // Constructors TDBPRX(PPRXDEF tdp); - TDBPRX(PGLOBAL g, PTDBPRX tdbp); + TDBPRX(PTDBPRX tdbp); // Implementation virtual AMT GetAmType(void) {return TYPE_AM_PRX;} virtual PTDB Duplicate(PGLOBAL g) - {return (PTDB)new(g) TDBPRX(g, this);} + {return (PTDB)new(g) TDBPRX(this);} // Methods virtual PTDB CopyOne(PTABS t); diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp index 3ed40540395..e788529075f 100644 --- a/storage/connect/tabvct.cpp +++ b/storage/connect/tabvct.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -35,7 +35,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) @@ -94,7 +94,7 @@ PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int, /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ -bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) { DOSDEF::DefineAM(g, "BIN", poff); @@ -146,7 +146,7 @@ bool VCTDEF::Erase(char *filename) for (i = 1, cdp = To_Cols; cdp; i++, cdp = cdp->GetNext()) { sprintf(filename, fpat, i); -//#if defined(WIN32) +//#if defined(__WIN__) // rc |= !DeleteFile(filename); //#else // UNIX rc |= remove(filename); @@ -175,7 +175,7 @@ bool VCTDEF::Erase(char *filename) int VCTDEF::MakeFnPattern(char *fpat) { char pat[8]; -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -290,7 +290,7 @@ PCOL TDBVCT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ /* VEC tables are not ready yet to use temporary files. */ /***********************************************************************/ -bool TDBVCT::IsUsingTemp(PGLOBAL g) +bool TDBVCT::IsUsingTemp(PGLOBAL) { // For developpers return (UseTemp() == TMP_TEST); @@ -570,7 +570,7 @@ void VCTCOL::ReadColumn(PGLOBAL g) /* On each change of block the buffer is written back to file and */ /* in mode Insert the buffer is filled with the block to update. */ /***********************************************************************/ -void VCTCOL::WriteColumn(PGLOBAL g) +void VCTCOL::WriteColumn(PGLOBAL) { PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;; diff --git a/storage/connect/tabvir.cpp b/storage/connect/tabvir.cpp index b4c76f5ad56..356fc981357 100644 --- a/storage/connect/tabvir.cpp +++ b/storage/connect/tabvir.cpp @@ -29,7 +29,7 @@ /***********************************************************************/ /* Return the unique column definition to MariaDB. */ /***********************************************************************/ -PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info) +PQRYRES VirColumns(PGLOBAL g, bool info) { int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_STRING, TYPE_STRING}; @@ -95,7 +95,7 @@ PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info) /***********************************************************************/ /* GetTable: makes a new Table Description Block. */ /***********************************************************************/ -PTDB VIRDEF::GetTable(PGLOBAL g, MODE m) +PTDB VIRDEF::GetTable(PGLOBAL g, MODE) { // Column blocks will be allocated only when needed. if (Catfunc == FNC_COL) @@ -241,7 +241,7 @@ bool TDBVIR::OpenDB(PGLOBAL g) /***********************************************************************/ /* Data Base read routine for the VIR access method. */ /***********************************************************************/ -int TDBVIR::ReadDB(PGLOBAL g) +int TDBVIR::ReadDB(PGLOBAL) { return (++N >= Size) ? RC_EF : RC_OK; } // end of ReadDB @@ -258,7 +258,7 @@ int TDBVIR::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for the VIR access methods. */ /***********************************************************************/ -int TDBVIR::DeleteDB(PGLOBAL g, int irc) +int TDBVIR::DeleteDB(PGLOBAL g, int) { sprintf(g->Message, MSG(VIR_NO_DELETE), To_Def->GetType()); return RC_FX; @@ -269,7 +269,7 @@ int TDBVIR::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ /* VIRCOL public constructor. */ /***********************************************************************/ -VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) +VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) : COLBLK(cdp, tdbp, i) { if (cprec) { @@ -299,7 +299,7 @@ void VIRCOL::ReadColumn(PGLOBAL g) /***********************************************************************/ PQRYRES TDBVICL::GetResult(PGLOBAL g) { - return VirColumns(g, NULL, NULL, false); + return VirColumns(g, false); } // end of GetResult /* ------------------------- End of Virtual -------------------------- */ diff --git a/storage/connect/tabvir.h b/storage/connect/tabvir.h index 8d0caa257e7..a53aceaeceb 100644 --- a/storage/connect/tabvir.h +++ b/storage/connect/tabvir.h @@ -11,7 +11,7 @@ typedef class TDBVIR *PTDBVIR; /***********************************************************************/ /* Return the unique column definition to MariaDB. */ /***********************************************************************/ -PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info); +PQRYRES VirColumns(PGLOBAL g, bool info); /* --------------------------- VIR classes --------------------------- */ diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp index 7c69426a066..98a44b9d635 100644 --- a/storage/connect/tabwmi.cpp +++ b/storage/connect/tabwmi.cpp @@ -2,9 +2,9 @@ /* TABWMI: Author Olivier Bertrand -- PlugDB -- 2012 - 2013 */ /* TABWMI: Virtual table to get WMI information. */ /***********************************************************************/ -#if !defined(WIN32) -#error This is a WIN32 only table type -#endif // !WIN32 +#if !defined(__WIN__) +#error This is a WINDOWS only table type +#endif // !__WIN__ #include "my_global.h" #include <stdio.h> diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index dffbaf6e187..add61431493 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -17,7 +17,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -83,7 +83,7 @@ bool XCLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode) +PTDB XCLDEF::GetTable(PGLOBAL g, MODE) { if (Catfunc == FNC_COL) return new(g) TDBTBC(this); @@ -117,7 +117,7 @@ PCOL TDBXCL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) PCOL colp; if (!stricmp(cdp->GetName(), Xcolumn)) { - Xcolp = new(g) XCLCOL(g, cdp, this, cprec, n); + Xcolp = new(g) XCLCOL(cdp, this, cprec, n); colp = Xcolp; } else colp = new(g) PRXCOL(cdp, this, cprec, n); @@ -144,7 +144,7 @@ int TDBXCL::GetMaxSize(PGLOBAL g) /* For this table type, ROWID is the (virtual) row number, */ /* while ROWNUM is be the occurence rank in the multiple column. */ /***********************************************************************/ -int TDBXCL::RowNumber(PGLOBAL g, bool b) +int TDBXCL::RowNumber(PGLOBAL, bool b) { return (b) ? M : N; } // end of RowNumber @@ -232,7 +232,7 @@ int TDBXCL::ReadDB(PGLOBAL g) /***********************************************************************/ /* XCLCOL public constructor. */ /***********************************************************************/ -XCLCOL::XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i) +XCLCOL::XCLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i) : PRXCOL(cdp, tdbp, cprec, i, "XCL") { // Set additional XXL access method information for column. diff --git a/storage/connect/tabxcl.h b/storage/connect/tabxcl.h index ed15a67b629..291f0b4263a 100644 --- a/storage/connect/tabxcl.h +++ b/storage/connect/tabxcl.h @@ -85,7 +85,7 @@ class XCLCOL : public PRXCOL { friend class TDBXCL; public: // Constructors - XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); + XCLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); // Methods using PRXCOL::Init; diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index 1c1ff8a2ffe..49fa9a1c554 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -15,12 +15,12 @@ #include <stdio.h> #include <fcntl.h> #include <errno.h> -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <winsock2.h> //#include <windows.h> #include <comdef.h> -#else // !WIN32 +#else // !__WIN__ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> @@ -28,7 +28,7 @@ //#include <ctype.h> #include "osutil.h" #define _O_RDONLY O_RDONLY -#endif // !WIN32 +#endif // !__WIN__ #include "resource.h" // for IDS_COLUMNS #define INCLUDE_TDBXML @@ -53,11 +53,11 @@ extern "C" char version[]; -#if defined(WIN32) && defined(DOMDOC_SUPPORT) +#if defined(__WIN__) && defined(DOMDOC_SUPPORT) #define XMLSUP "MS-DOM" -#else // !WIN32 +#else // !__WIN__ #define XMLSUP "libxml2" -#endif // !WIN32 +#endif // !__WIN__ #define TYPE_UNKNOWN 12 /* Must be greater than other types */ @@ -110,15 +110,15 @@ typedef struct LVL { /* XMLColumns: construct the result blocks containing the description */ /* of all the columns of a table contained inside an XML file. */ /***********************************************************************/ -PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) +PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) { static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT}; static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0}; - char *op, colname[65], fmt[129], buf[512]; - int i, j, lvl, rc, n = 0; + char *fn, *op, colname[65], fmt[129], buf[512]; + int i, j, lvl, n = 0; int ncol = sizeof(buftyp) / sizeof(int); bool ok = true; PXCL xcol, xcp, fxcp = NULL, pxcp = NULL; @@ -138,33 +138,35 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) /*********************************************************************/ /* Open the input file. */ /*********************************************************************/ - if (!topt->filename) { + if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) { strcpy(g->Message, MSG(MISSING_FNAME)); return NULL; - } else - lvl = atoi(GetListOption(g, "Level", topt->oplist, "0")); + } else { + lvl = GetIntegerTableOption(g, topt, "Level", 0); + lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl; + } // endif fn if (trace) htrc("File %s lvl=%d\n", topt->filename, lvl); tdp = new(g) XMLDEF; - tdp->Database = dp; - tdp->Fn = (char*)topt->filename; + tdp->Fn = fn; + tdp->Database = SetPath(g, db); tdp->Tabname = tab; - if (!(op = GetListOption(g, "Xmlsup", topt->oplist, NULL))) -#if defined(WIN32) + if (!(op = GetStringTableOption(g, topt, "Xmlsup", NULL))) +#if defined(__WIN__) tdp->Usedom = true; -#else // !WIN32 +#else // !__WIN__ tdp->Usedom = false; -#endif // !WIN32 +#endif // !__WIN__ else tdp->Usedom = (toupper(*op) == 'M' || toupper(*op) == 'D'); txmp = new(g) TDBXML(tdp); if (txmp->Initialize(g)) - return NULL; + goto err; xcol = new(g) XMCOL; colname[64] = 0; @@ -224,8 +226,16 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) if (vp->atp) { strncpy(colname, vp->atp->GetName(g), sizeof(colname)); strncat(xcol->Name, colname, 64); - rc = vp->atp->GetText(g, buf, sizeof(buf)); - strncat(fmt, "@", sizeof(fmt)); + + switch (vp->atp->GetText(g, buf, sizeof(buf))) { + case RC_INFO: + PushWarning(g, txmp); + case RC_OK: + strncat(fmt, "@", sizeof(fmt)); + break; + default: + goto err; + } // enswitch rc if (j) strncat(fmt, colname, sizeof(fmt)); @@ -273,7 +283,15 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) } else ok = true; - rc = node->GetContent(g, buf, sizeof(buf)); + switch (node->GetContent(g, buf, sizeof(buf))) { + case RC_INFO: + PushWarning(g, txmp); + case RC_OK: + break; + default: + goto err; + } // enswitch rc + } // endif atp; xcol->Len = strlen(buf); @@ -313,10 +331,6 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) pxcp = xcp; -// for (j = lvl - 1; j >= 0; j--) -// if (jrp[j] && (jrp[j] = jrp[j]->GetNext())) -// goto more; - if (vp->atp) vp->atp = vp->atp->GetNext(g); @@ -420,9 +434,7 @@ XMLDEF::XMLDEF(void) /***********************************************************************/ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - char *defrow, *defcol, buf[10]; -//void *memp = Cat->GetDescp(); -//PSZ dbfile = Cat->GetDescFile(); + char *defrow, *defcol, buf[10]; Fn = GetStringCatInfo(g, "Filename", NULL); Encoding = GetStringCatInfo(g, "Encoding", "UTF-8"); @@ -437,7 +449,7 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) return true; } // endif flag - defrow = defcol = ""; + defrow = defcol = NULL; GetCharCatInfo("Coltype", "", buf, sizeof(buf)); switch (toupper(*buf)) { @@ -470,36 +482,29 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Tabname = GetStringCatInfo(g, "Tabname", Tabname); Rowname = GetStringCatInfo(g, "Rownode", defrow); Colname = GetStringCatInfo(g, "Colnode", defcol); - Mulnode = GetStringCatInfo(g, "Mulnode", ""); - XmlDB = GetStringCatInfo(g, "XmlDB", ""); - Nslist = GetStringCatInfo(g, "Nslist", ""); - DefNs = GetStringCatInfo(g, "DefNs", ""); + Mulnode = GetStringCatInfo(g, "Mulnode", NULL); + XmlDB = GetStringCatInfo(g, "XmlDB", NULL); + Nslist = GetStringCatInfo(g, "Nslist", NULL); + DefNs = GetStringCatInfo(g, "DefNs", NULL); Limit = GetIntCatInfo("Limit", 10); - Xpand = (GetIntCatInfo("Expand", 0) != 0); + Xpand = GetBoolCatInfo("Expand", false); Header = GetIntCatInfo("Header", 0); GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf)); -//if (*buf == '*') // Try the old (deprecated) option -// GetCharCatInfo("Method", "*", buf, sizeof(buf)); - -//if (*buf == '*') // Is there a default for the database? -// GetCharCatInfo("Defxml", XMLSUP, buf, sizeof(buf)); - // Note that if no support is specified, the default is MS-DOM // on Windows and libxml2 otherwise if (*buf == '*') -#if defined(WIN32) +#if defined(__WIN__) Usedom = true; -#else // !WIN32 +#else // !__WIN__ Usedom = false; -#endif // !WIN32 +#endif // !__WIN__ else Usedom = (toupper(*buf) == 'M' || toupper(*buf) == 'D'); // Get eventual table node attribute - Attrib = GetStringCatInfo(g, "Attribute", ""); - Hdattr = GetStringCatInfo(g, "HeadAttr", ""); - + Attrib = GetStringCatInfo(g, "Attribute", NULL); + Hdattr = GetStringCatInfo(g, "HeadAttr", NULL); return false; } // end of DefineAM @@ -519,30 +524,6 @@ PTDB XMLDEF::GetTable(PGLOBAL g, MODE m) return tdbp; } // end of GetTable -#if 0 -/***********************************************************************/ -/* DeleteTableFile: Delete XML table files using platform API. */ -/***********************************************************************/ -bool XMLDEF::DeleteTableFile(PGLOBAL g) - { - char filename[_MAX_PATH]; - bool rc; - - // Delete the XML table file if not protected - if (!IsReadOnly()) { - PlugSetPath(filename, Fn, GetPath()); -#if defined(WIN32) - rc = !DeleteFile(filename); -#else // UNIX - rc = remove(filename); -#endif // UNIX - } else - rc =true; - - return rc; // Return true if error - } // end of DeleteTableFile -#endif // 0 - /* ------------------------- TDBXML Class ---------------------------- */ /***********************************************************************/ @@ -564,14 +545,14 @@ TDBXML::TDBXML(PXMLDEF tdp) : TDBASE(tdp) Xfile = tdp->Fn; Enc = tdp->Encoding; Tabname = tdp->Tabname; - Rowname = (tdp->Rowname && *tdp->Rowname) ? tdp->Rowname : NULL; - Colname = (tdp->Colname && *tdp->Colname) ? tdp->Colname : NULL; - Mulnode = (tdp->Mulnode && *tdp->Mulnode) ? tdp->Mulnode : NULL; - XmlDB = (tdp->XmlDB && *tdp->XmlDB) ? tdp->XmlDB : NULL; - Nslist = (tdp->Nslist && *tdp->Nslist) ? tdp->Nslist : NULL; - DefNs = (tdp->DefNs && *tdp->DefNs) ? tdp->DefNs : NULL; - Attrib = (tdp->Attrib && *tdp->Attrib) ? tdp->Attrib : NULL; - Hdattr = (tdp->Hdattr && *tdp->Hdattr) ? tdp->Hdattr : NULL; + Rowname = (tdp->Rowname) ? tdp->Rowname : NULL; + Colname = (tdp->Colname) ? tdp->Colname : NULL; + Mulnode = (tdp->Mulnode) ? tdp->Mulnode : NULL; + XmlDB = (tdp->XmlDB) ? tdp->XmlDB : NULL; + Nslist = (tdp->Nslist) ? tdp->Nslist : NULL; + DefNs = (tdp->DefNs) ? tdp->DefNs : NULL; + Attrib = (tdp->Attrib) ? tdp->Attrib : NULL; + Hdattr = (tdp->Hdattr) ? tdp->Hdattr : NULL; Coltype = tdp->Coltype; Limit = tdp->Limit; Xpand = tdp->Xpand; @@ -667,7 +648,7 @@ PCOL TDBXML::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/ -PCOL TDBXML::InsertSpecialColumn(PGLOBAL g, PCOL colp) +PCOL TDBXML::InsertSpecialColumn(PCOL colp) { if (!colp->IsSpecial()) return NULL; @@ -854,7 +835,6 @@ bool TDBXML::Initialize(PGLOBAL g) To_Xb = Docp->LinkXblock(g, Mode, rc, filename); // Add a CONNECT comment node -// sprintf(buf, " Created by CONNECT %s ", version); strcpy(buf, " Created by the MariaDB CONNECT Storage Engine"); Docp->AddComment(g, buf); @@ -898,7 +878,7 @@ bool TDBXML::Initialize(PGLOBAL g) Nlist = TabNode->GetChildElements(g); Docp->SetNofree(true); // For libxml2 -#if defined(WIN32) +#if defined(__WIN__) } catch(_com_error e) { // We come here if a DOM command threw an error char buf[128]; @@ -912,7 +892,7 @@ bool TDBXML::Initialize(PGLOBAL g) sprintf(g->Message, "%s hr=%p", MSG(COM_ERROR), e.Error()); goto error; -#endif // WIN32 +#endif // __WIN__ #if !defined(UNIX) } catch(...) { // Other errors @@ -1037,7 +1017,7 @@ int TDBXML::GetMaxSize(PGLOBAL g) else MaxSize = 10; - } // endif MaxSize + } // endif MaxSize return MaxSize; } // end of GetMaxSize @@ -1278,8 +1258,7 @@ void TDBXML::CloseDB(PGLOBAL g) { if (Docp) { if (Changed) { - char filename[_MAX_PATH]; -// PDBUSER dup = (PDBUSER)g->Activityp->Aptr; + char filename[_MAX_PATH]; // We used the file name relative to recorded datapath PlugSetPath(filename, Xfile, GetPath()); @@ -1321,7 +1300,6 @@ void TDBXML::CloseDB(PGLOBAL g) NewRow = false; Hasnod = false; Write = false; -// Bufdone = false; Nodedone = false; Void = false; Nrow = -1; @@ -1413,8 +1391,6 @@ bool XMLCOL::AllocBuf(PGLOBAL g, bool mode) if (Valbuf) return false; // Already done -//Valbuf = (char*)PlugSubAlloc(g, NULL, Long + 1); -//Valbuf[Long] = '\0'; return ParseXpath(g, mode); } // end of AllocBuf @@ -1506,8 +1482,6 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode) // HTML like table, columns are retrieved by position new(this) XPOSCOL(Value); // Change the class of this column Inod = -1; -// Tdbp->Hasnod = true; -// return false; } else if (Type == 0 && !mode) { strcat(strcat(pbuf, "@"), Name); } else { // Type == 1 @@ -1657,7 +1631,6 @@ void XMLCOL::WriteColumn(PGLOBAL g) int done = 0; int i, n, k = 0; PXNODE TopNode = NULL; -//PXATTR AttNode = NULL; if (trace > 1) htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", @@ -1689,7 +1662,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) /*********************************************************************/ /* Null values are represented by no node. */ /*********************************************************************/ - if (Value->IsNull()) + if (Value->IsNull()) return; /*********************************************************************/ @@ -1892,7 +1865,6 @@ void XMULCOL::WriteColumn(PGLOBAL g) int done = 0; int i, n, len, k = 0; PXNODE TopNode = NULL; -//PXATTR AttNode = NULL; if (trace) htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", @@ -2190,7 +2162,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g) TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp) { Topt = tdp->GetTopt(); - Dp = tdp->GetPath(); + Db = (char*)tdp->GetDB(); Tabn = tdp->Tabname; } // end of TDBXCT constructor @@ -2199,7 +2171,7 @@ TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBXCT::GetResult(PGLOBAL g) { - return XMLColumns(g, Dp, Tabn, Topt, false); + return XMLColumns(g, Db, Tabn, Topt, false); } // end of GetResult /* ------------------------ End of Tabxml ---------------------------- */ diff --git a/storage/connect/tabxml.h b/storage/connect/tabxml.h index f6cfd3fb510..7ba3166881d 100644 --- a/storage/connect/tabxml.h +++ b/storage/connect/tabxml.h @@ -1,7 +1,7 @@ /*************** Tabxml H Declares Source Code File (.H) ***************/ /* Name: TABXML.H Version 1.6 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */ +/* (C) Copyright to the author Olivier BERTRAND 2007-2015 */ /* */ /* This file contains the XML table classes declares. */ /***********************************************************************/ @@ -84,7 +84,7 @@ class DllExport TDBXML : public TDBASE { // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); + virtual PCOL InsertSpecialColumn(PCOL colp); //virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;} virtual int Cardinality(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g); @@ -255,8 +255,7 @@ class TDBXCT : public TDBCAT { // Members PTOS Topt; - char *Dp; -//const char *Fn; + char *Db; char *Tabn; }; // end of class TDBXCT diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc index 4affe447b00..34d192361a5 100644 --- a/storage/connect/user_connect.cc +++ b/storage/connect/user_connect.cc @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2014 +/* Copyright (C) Olivier Bertrand 2004 - 2015 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ */ /****************************************************************************/ -/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2014 */ +/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2015 */ /****************************************************************************/ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation @@ -63,7 +63,7 @@ void SetWorkSize(uint); /****************************************************************************/ /* Constructor. */ /****************************************************************************/ -user_connect::user_connect(THD *thd, const char *dbn) +user_connect::user_connect(THD *thd) { thdp= thd; next= NULL; diff --git a/storage/connect/user_connect.h b/storage/connect/user_connect.h index 44e4e94fa8a..7f37973f378 100644 --- a/storage/connect/user_connect.h +++ b/storage/connect/user_connect.h @@ -45,7 +45,7 @@ class user_connect friend int connect_done_func(void *); public: // Constructor - user_connect(THD *thd, const char *dbn); + user_connect(THD *thd); // Destructor virtual ~user_connect(); diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index e731ad156d9..5fefcba5856 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -23,7 +23,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> #else #include "osutil.h" @@ -132,7 +132,7 @@ VALBLK::VALBLK(void *mp, int type, int nval, bool un) /***********************************************************************/ /* Raise error for numeric types. */ /***********************************************************************/ -PSZ VALBLK::GetCharValue(int n) +PSZ VALBLK::GetCharValue(int) { PGLOBAL& g = Global; @@ -145,7 +145,7 @@ PSZ VALBLK::GetCharValue(int n) /***********************************************************************/ /* Set format so formatted dates can be converted on input. */ /***********************************************************************/ -bool VALBLK::SetFormat(PGLOBAL g, PSZ fmt, int len, int year) +bool VALBLK::SetFormat(PGLOBAL g, PSZ, int, int) { sprintf(g->Message, MSG(NO_DATE_FMT), Type); return true; @@ -752,7 +752,7 @@ double CHRBLK::GetFloatValue(int n) /***********************************************************************/ /* STRING GetCharString: get string representation of a char value. */ /***********************************************************************/ -char *CHRBLK::GetCharString(char *p, int n) +char *CHRBLK::GetCharString(char *, int n) { return (char *)GetValPtrEx(n); } // end of GetCharString diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h index 5a98257f98f..f6eb7258a77 100644 --- a/storage/connect/valblk.h +++ b/storage/connect/valblk.h @@ -95,17 +95,17 @@ class VALBLK : public BLOCK { virtual bool IsCi(void) {return false;} // Methods - virtual void SetValue(short sval, int n) {assert(false);} - virtual void SetValue(ushort sval, int n) {assert(false);} - virtual void SetValue(int lval, int n) {assert(false);} - virtual void SetValue(uint lval, int n) {assert(false);} - virtual void SetValue(longlong lval, int n) {assert(false);} - virtual void SetValue(ulonglong lval, int n) {assert(false);} - virtual void SetValue(double fval, int n) {assert(false);} - virtual void SetValue(char cval, int n) {assert(false);} - virtual void SetValue(uchar cval, int n) {assert(false);} - virtual void SetValue(PSZ sp, int n) {assert(false);} - virtual void SetValue(char *sp, uint len, int n) {assert(false);} + virtual void SetValue(short, int) {assert(false);} + virtual void SetValue(ushort, int) {assert(false);} + virtual void SetValue(int, int) {assert(false);} + virtual void SetValue(uint, int) {assert(false);} + virtual void SetValue(longlong, int) {assert(false);} + virtual void SetValue(ulonglong, int) {assert(false);} + virtual void SetValue(double, int) {assert(false);} + virtual void SetValue(char, int) {assert(false);} + virtual void SetValue(uchar, int) {assert(false);} + virtual void SetValue(PSZ, int) {assert(false);} + virtual void SetValue(char *, uint, int) {assert(false);} virtual void SetValue(PVAL valp, int n) = 0; virtual void SetValue(PVBLK pv, int n1, int n2) = 0; virtual void SetMin(PVAL valp, int n) = 0; @@ -271,7 +271,7 @@ class STRBLK : public VALBLK { // Implementation virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}} virtual bool IsNull(int n) {return Strp[n] == NULL;} - virtual void SetNullable(bool b) {} // Always nullable + virtual void SetNullable(bool) {} // Always nullable virtual bool Init(PGLOBAL g, bool check); virtual int GetVlen(void) {return sizeof(PSZ);} virtual PSZ GetCharValue(int n) {return Strp[n];} @@ -284,7 +284,7 @@ class STRBLK : public VALBLK { virtual longlong GetBigintValue(int n); virtual ulonglong GetUBigintValue(int n); virtual double GetFloatValue(int n) {return atof(Strp[n]);} - virtual char *GetCharString(char *p, int n) {return Strp[n];} + virtual char *GetCharString(char *, int n) {return Strp[n];} virtual void Reset(int n) {Strp[n] = NULL;} // Methods diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index d14fc367cc7..03ec0eb8e40 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -30,11 +30,11 @@ #include "sql_class.h" #include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include <string.h> -#endif // !WIN32 +#endif // !__WIN__ #include <math.h> @@ -77,12 +77,12 @@ int DTVAL::Shift = 0; /***********************************************************************/ bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool); -#if !defined(WIN32) +#if !defined(__WIN__) extern "C" { PSZ strupr(PSZ s); PSZ strlwr(PSZ s); } -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Get a long long number from its character representation. */ @@ -475,7 +475,7 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns) break; case TYPE_DATE: - vp = new(g) DTVAL(g, valp->GetIntValue()); + vp = new(g) DTVAL(valp->GetIntValue()); break; case TYPE_DOUBLE: vp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_DOUBLE, @@ -551,7 +551,7 @@ BYTE VALUE::TestValue(PVAL vp) /***********************************************************************/ /* Compute a function on a string. */ /***********************************************************************/ -bool VALUE::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) +bool VALUE::Compute(PGLOBAL g, PVAL *, int, OPVAL) { strcpy(g->Message, "Compute not implemented for this value type"); return true; @@ -976,7 +976,7 @@ ulonglong TYPVAL<ulonglong>::MinMaxVal(bool b) {return (b) ? 0xFFFFFFFFFFFFFFFFLL : 0;} template <> -double TYPVAL<double>::MinMaxVal(bool b) +double TYPVAL<double>::MinMaxVal(bool) {assert(false); return 0.0;} template <> @@ -1566,7 +1566,7 @@ bool TYPVAL<PSZ>::GetBinValue(void *buf, int buflen, bool go) /***********************************************************************/ /* STRING ShowValue: get string representation of a char value. */ /***********************************************************************/ -char *TYPVAL<PSZ>::ShowValue(char *buf, int len) +char *TYPVAL<PSZ>::ShowValue(char *, int) { return Strp; } // end of ShowValue @@ -1574,7 +1574,7 @@ char *TYPVAL<PSZ>::ShowValue(char *buf, int len) /***********************************************************************/ /* STRING GetCharString: get string representation of a char value. */ /***********************************************************************/ -char *TYPVAL<PSZ>::GetCharString(char *p) +char *TYPVAL<PSZ>::GetCharString(char *) { return Strp; } // end of GetCharString @@ -1618,10 +1618,10 @@ int TYPVAL<PSZ>::CompareValue(PVAL vp) else n = strcmp(Strp, vp->GetCharValue()); -#if defined(WIN32) +#if defined(__WIN__) if (n == _NLSCMPERROR) return n; // Here we should raise an error -#endif // WIN32 +#endif // __WIN__ return (n > 0) ? 1 : (n < 0) ? -1 : 0; } // end of CompareValue @@ -1681,7 +1681,7 @@ bool TYPVAL<PSZ>::FormatValue(PVAL vp, char *fmt) /***********************************************************************/ /* STRING SetFormat function (used to set SELECT output format). */ /***********************************************************************/ -bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL g, FORMAT& fmt) +bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL, FORMAT& fmt) { fmt.Type[0] = 'C'; fmt.Length = Len; @@ -2300,7 +2300,7 @@ char *BINVAL::ShowValue(char *buf, int len) /***********************************************************************/ /* BINVAL GetCharString: get string representation of a binary value. */ /***********************************************************************/ -char *BINVAL::GetCharString(char *p) +char *BINVAL::GetCharString(char *) { if (!Chrp) Chrp = (char*)PlugSubAlloc(Global, NULL, Clen * 2 + 1); @@ -2349,7 +2349,7 @@ bool BINVAL::FormatValue(PVAL vp, char *fmt) /***********************************************************************/ /* BINVAL SetFormat function (used to set SELECT output format). */ /***********************************************************************/ -bool BINVAL::SetConstFormat(PGLOBAL g, FORMAT& fmt) +bool BINVAL::SetConstFormat(PGLOBAL, FORMAT& fmt) { fmt.Type[0] = 'B'; fmt.Length = Clen; @@ -2379,7 +2379,7 @@ DTVAL::DTVAL(PGLOBAL g, int n, int prec, PSZ fmt) /***********************************************************************/ /* DTVAL public constructor from int. */ /***********************************************************************/ -DTVAL::DTVAL(PGLOBAL g, int n) : TYPVAL<int>(n, TYPE_DATE) +DTVAL::DTVAL(int n) : TYPVAL<int>(n, TYPE_DATE) { Pdtp = NULL; Len = 19; diff --git a/storage/connect/value.h b/storage/connect/value.h index c5aeb5c2a2f..780917c9962 100644 --- a/storage/connect/value.h +++ b/storage/connect/value.h @@ -36,8 +36,9 @@ typedef struct _datpar *PDTP; // For DTVAL DllExport PSZ GetTypeName(int); DllExport int GetTypeSize(int, int); #ifdef ODBC_SUPPORT -/* This function is exported for use in EOM table type DLLs */ -DllExport int TranslateSQLType(int stp, int prec, int& len, char& v); +/* This function is exported for use in OEM table type DLLs */ +DllExport int TranslateSQLType(int stp, int prec, + int& len, char& v, bool& w); #endif DllExport char *GetFormatType(int); DllExport int GetFormatType(char); @@ -94,18 +95,18 @@ class DllExport VALUE : public BLOCK { virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; virtual bool SetValue_char(char *p, int n) = 0; virtual void SetValue_psz(PSZ s) = 0; - virtual void SetValue_bool(bool b) {assert(FALSE);} + virtual void SetValue_bool(bool) {assert(FALSE);} virtual int CompareValue(PVAL vp) = 0; virtual BYTE TestValue(PVAL vp); - virtual void SetValue(char c) {assert(false);} - virtual void SetValue(uchar c) {assert(false);} - virtual void SetValue(short i) {assert(false);} - virtual void SetValue(ushort i) {assert(false);} - virtual void SetValue(int n) {assert(false);} - virtual void SetValue(uint n) {assert(false);} - virtual void SetValue(longlong n) {assert(false);} - virtual void SetValue(ulonglong n) {assert(false);} - virtual void SetValue(double f) {assert(false);} + virtual void SetValue(char) {assert(false);} + virtual void SetValue(uchar) {assert(false);} + virtual void SetValue(short) {assert(false);} + virtual void SetValue(ushort) {assert(false);} + virtual void SetValue(int) {assert(false);} + virtual void SetValue(uint) {assert(false);} + virtual void SetValue(longlong) {assert(false);} + virtual void SetValue(ulonglong) {assert(false);} + virtual void SetValue(double) {assert(false);} virtual void SetValue_pvblk(PVBLK blk, int n) = 0; virtual void SetBinValue(void *p) = 0; virtual bool GetBinValue(void *buf, int buflen, bool go) = 0; @@ -338,7 +339,7 @@ class DllExport BINVAL: public VALUE { virtual void SetValue(double f); virtual void SetBinValue(void *p); virtual bool GetBinValue(void *buf, int buflen, bool go); - virtual int CompareValue(PVAL vp) {assert(false); return 0;} + virtual int CompareValue(PVAL) {assert(false); return 0;} virtual char *ShowValue(char *buf, int); virtual char *GetCharString(char *p); virtual bool IsEqual(PVAL vp, bool chktype); @@ -359,14 +360,9 @@ class DllExport DTVAL : public TYPVAL<int> { public: // Constructors DTVAL(PGLOBAL g, int n, int p, PSZ fmt); - DTVAL(PGLOBAL g, PSZ s, int n); - DTVAL(PGLOBAL g, short i); - DTVAL(PGLOBAL g, int n); - DTVAL(PGLOBAL g, longlong n); - DTVAL(PGLOBAL g, double f); + DTVAL(int n); // Implementation - virtual bool IsZero(void) {return Null;} virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_char(char *p, int n); virtual void SetValue_psz(PSZ s); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 024a9c081cd..a2d75cec8ab 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -1,7 +1,7 @@ /***************** Xindex C++ Class Xindex Code (.CPP) *****************/ /* Name: XINDEX.CPP Version 2.9 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */ /* */ /* This file contains the class XINDEX implementation code. */ /***********************************************************************/ @@ -10,12 +10,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -25,7 +25,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include required application header files */ @@ -179,7 +179,7 @@ XXBASE::XXBASE(PTDBDOS tbxp, bool b) : CSORT(b), /***********************************************************************/ /* Make file output of XINDEX contents. */ /***********************************************************************/ -void XXBASE::Print(PGLOBAL g, FILE *f, uint n) +void XXBASE::Print(PGLOBAL, FILE *f, uint n) { char m[64]; @@ -191,7 +191,7 @@ void XXBASE::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of XINDEX contents. */ /***********************************************************************/ -void XXBASE::Print(PGLOBAL g, char *ps, uint z) +void XXBASE::Print(PGLOBAL, char *ps, uint z) { *ps = '\0'; strncat(ps, "Xindex", z); @@ -287,7 +287,7 @@ int XINDEX::Qcompare(int *i1, int *i2) /* Sure enough, it is done while records are read and permit to avoid */ /* reading the table while doing the join (Dynamic index only) */ /***********************************************************************/ -bool XINDEX::AddColumns(PIXDEF xdp) +bool XINDEX::AddColumns(void) { if (!Dynamic) return false; // Not applying to static index @@ -340,6 +340,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) } // endif n + if (trace) + htrc("XINDEX Make: n=%d\n", n); + // File position must be stored Record.Size = n * sizeof(int); @@ -377,7 +380,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) To_LastCol = prev; - if (AddColumns(sxp)) { + if (AddColumns()) { PCOL kolp = To_Cols[0]; // Temporary while imposing Nk = 1 i = 0; @@ -477,6 +480,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) } else To_Rec[nkey] = Tdbp->GetRecpos(); + if (trace > 1) + htrc("Make: To_Rec[%d]=%d\n", nkey, To_Rec[nkey]); + /*******************************************************************/ /* Get the keys and place them in the key blocks. */ /*******************************************************************/ @@ -733,7 +739,7 @@ int XINDEX::ColMaxSame(PXCOL kp) /* Reorder: use the sort index to reorder the data in storage so */ /* it will be physically sorted and sort index can be removed. */ /***********************************************************************/ -bool XINDEX::Reorder(PGLOBAL g) +bool XINDEX::Reorder(PGLOBAL g __attribute__((unused))) { register int i, j, k, n; bool sorted = true; @@ -835,7 +841,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) if ((sep = defp->GetBoolCatInfo("SepIndex", false))) { // Index is saved in a separate file -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -988,7 +994,7 @@ bool XINDEX::Init(PGLOBAL g) if (defp->SepIndex()) { // Index was saved in a separate file -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1241,7 +1247,7 @@ bool XINDEX::MapInit(PGLOBAL g) if (defp->SepIndex()) { // Index was save in a separate file -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1454,7 +1460,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk) if (defp->SepIndex()) { // Index was saved in a separate file -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1585,7 +1591,7 @@ int XINDEX::Range(PGLOBAL g, int limit, bool incl) if (++i == Nval) break; } // endfor kp - if ((k = FastFind(Nval)) < Num_K) + if ((k = FastFind()) < Num_K) n = k; // if (limit) // n = (Mul) ? k : kp->Val_K; @@ -1759,6 +1765,9 @@ int XINDEX::Fetch(PGLOBAL g) if (Num_K == 0) return -1; // means end of file + if (trace > 1) + htrc("XINDEX Fetch: Op=%d\n", Op); + /*********************************************************************/ /* Table read through a sorted index. */ /*********************************************************************/ @@ -1776,9 +1785,6 @@ int XINDEX::Fetch(PGLOBAL g) break; case OP_SAME: // Read next same // Logically the key values should be the same as before - if (trace > 1) - htrc("looking for next same value\n"); - if (NextVal(true)) { Op = OP_EQ; return -2; // no more equal values @@ -1824,9 +1830,9 @@ int XINDEX::Fetch(PGLOBAL g) Nth++; if (trace > 1) - htrc("Fetch: Looking for new value\n"); + htrc("Fetch: Looking for new value Nth=%d\n", Nth); - Cur_K = FastFind(Nval); + Cur_K = FastFind(); if (Cur_K >= Num_K) /*************************************************************/ @@ -1857,12 +1863,12 @@ int XINDEX::Fetch(PGLOBAL g) /* FastFind: Returns the index of matching record in a join using an */ /* optimized algorithm based on dichotomie and optimized comparing. */ /***********************************************************************/ -int XINDEX::FastFind(int nv) +int XINDEX::FastFind(void) { register int curk, sup, inf, i= 0, k, n = 2; register PXCOL kp, kcp; - assert((int)nv == Nval); +//assert((int)nv == Nval); if (Nblk && Op == OP_EQ) { // Look in block values to find in which block to search @@ -1896,6 +1902,10 @@ int XINDEX::FastFind(int nv) sup = To_KeyCol->Ndf; } // endif Nblk + if (trace > 2) + htrc("XINDEX FastFind: Nblk=%d Op=%d inf=%d sup=%d\n", + Nblk, Op, inf, sup); + for (k = 0, kcp = To_KeyCol; kcp; kcp = kcp->Next) { while (sup - inf > 1) { i = (inf + sup) >> 1; @@ -1970,6 +1980,9 @@ int XINDEX::FastFind(int nv) curk = (kcp->Kof) ? kcp->Kof[kcp->Val_K] : kcp->Val_K; } // endfor kcp + if (trace > 2) + htrc("XINDEX FastFind: curk=%d\n", curk); + return curk; } // end of FastFind @@ -2018,7 +2031,7 @@ int XINDXS::Range(PGLOBAL g, int limit, bool incl) /*********************************************************************/ if (xp->GetType() == TYPE_CONST) { kp->Valp->SetValue_pval(xp->GetValue(), !kp->Prefix); - k = FastFind(Nval); + k = FastFind(); if (k < Num_K || Op != OP_EQ) if (limit) @@ -2043,8 +2056,7 @@ int XINDXS::GroupSize(void) #if defined(_DEBUG) assert(To_KeyCol->Val_K >= 0 && To_KeyCol->Val_K < Ndif); #endif // _DEBUG - return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] - : 1; + return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] : 1; } // end of GroupSize /***********************************************************************/ @@ -2106,6 +2118,9 @@ int XINDXS::Fetch(PGLOBAL g) if (Num_K == 0) return -1; // means end of file + if (trace > 1) + htrc("XINDXS Fetch: Op=%d\n", Op); + /*********************************************************************/ /* Table read through a sorted index. */ /*********************************************************************/ @@ -2120,9 +2135,6 @@ int XINDXS::Fetch(PGLOBAL g) Op = OP_NEXT; break; case OP_SAME: // Read next same - if (trace > 1) - htrc("looking for next same value\n"); - if (!Mul || NextVal(true)) { Op = OP_EQ; return -2; // No more equal values @@ -2160,9 +2172,9 @@ int XINDXS::Fetch(PGLOBAL g) Nth++; if (trace > 1) - htrc("Fetch: Looking for new value\n"); + htrc("Fetch: Looking for new value Nth=%d\n", Nth); - Cur_K = FastFind(1); + Cur_K = FastFind(); if (Cur_K >= Num_K) // Rank not whithin index table, signal record not found @@ -2190,9 +2202,9 @@ int XINDXS::Fetch(PGLOBAL g) /* FastFind: Returns the index of matching indexed record using an */ /* optimized algorithm based on dichotomie and optimized comparing. */ /***********************************************************************/ -int XINDXS::FastFind(int nk) +int XINDXS::FastFind(void) { - register int sup, inf, i= 0, n = 2; + register int sup, inf, i= 0, n = 2; register PXCOL kcp = To_KeyCol; if (Nblk && Op == OP_EQ) { @@ -2215,7 +2227,6 @@ int XINDXS::FastFind(int nk) if (inf < 0) return Num_K; -// i = inf; inf *= Sblk; if ((sup = inf + Sblk) > Ndif) @@ -2227,6 +2238,10 @@ int XINDXS::FastFind(int nk) sup = Ndif; } // endif Nblk + if (trace > 2) + htrc("XINDXS FastFind: Nblk=%d Op=%d inf=%d sup=%d\n", + Nblk, Op, inf, sup); + while (sup - inf > 1) { i = (inf + sup) >> 1; @@ -2249,6 +2264,9 @@ int XINDXS::FastFind(int nk) n = 0; } // endif sup + if (trace > 2) + htrc("XINDXS FastFind: n=%d i=%d\n", n, i); + // Loop on kcp because of dynamic indexing for (; kcp; kcp = kcp->Next) kcp->Val_K = i; // Used by FillValue @@ -2330,6 +2348,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) } // endif NewOff.Low = (int)ftell(Xfile); + + if (trace) + htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low); + } else if (mode == MODE_WRITE) { if (id >= 0) { // New not sep index file. Write the header. @@ -2337,6 +2359,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) Write(g, noff, sizeof(IOFF), MAX_INDX, rc); fseek(Xfile, 0, SEEK_END); NewOff.Low = (int)ftell(Xfile); + + if (trace) + htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low); + } // endif id } else if (mode == MODE_READ && id >= 0) { @@ -2346,6 +2372,9 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif MAX_INDX + if (trace) + htrc("XFILE Open: noff[%d].Low=%d\n", id, noff[id].Low); + // Position the cursor at the offset of this index if (fseek(Xfile, noff[id].Low, SEEK_SET)) { sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek"); @@ -2360,7 +2389,8 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) /***********************************************************************/ /* Move into an index file. */ /***********************************************************************/ -bool XFILE::Seek(PGLOBAL g, int low, int high, int origin) +bool XFILE::Seek(PGLOBAL g, int low, int high __attribute__((unused)), + int origin) { #if defined(_DEBUG) assert(high == 0); @@ -2371,7 +2401,6 @@ bool XFILE::Seek(PGLOBAL g, int low, int high, int origin) return true; } // endif -//ftell(Xfile); return false; } // end of Seek @@ -2479,7 +2508,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) if (trace) htrc(" Xopen: filename=%s id=%d mode=%d\n", filename, id, mode); -#if defined(WIN32) +#if defined(__WIN__) LONG high = 0; DWORD rc, drc, access, share, creation; @@ -2655,7 +2684,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) /***********************************************************************/ bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin) { -#if defined(WIN32) +#if defined(__WIN__) LONG hi = high; DWORD rc = SetFilePointer(Hfile, low, &hi, origin); @@ -2691,7 +2720,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size) { bool rc = false; -#if defined(WIN32) +#if defined(__WIN__) bool brc; DWORD nbr, count = (DWORD)(n * size); @@ -2737,7 +2766,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size) /***********************************************************************/ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc) { -#if defined(WIN32) +#if defined(__WIN__) bool brc; DWORD nbw, count = (DWORD)n * (DWORD) size; @@ -2779,7 +2808,7 @@ void XHUGE::Close(char *fn, int id) if (trace) htrc("XHUGE::Close: fn=%s id=%d NewOff=%lld\n", fn, id, NewOff.Val); -#if defined(WIN32) +#if defined(__WIN__) if (id >= 0 && fn) { CloseFileHandle(Hfile); Hfile = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, NULL, @@ -2794,7 +2823,7 @@ void XHUGE::Close(char *fn, int id) } // endif SetFilePointer } // endif id -#else // !WIN32 +#else // !__WIN__ if (id >= 0 && fn) { if (Hfile != INVALID_HANDLE_VALUE) { if (lseek64(Hfile, id * sizeof(IOFF), SEEK_SET) >= 0) { @@ -2810,7 +2839,7 @@ void XHUGE::Close(char *fn, int id) htrc("(XHUGE)error reopening %s: %s\n", fn, strerror(errno)); } // endif id -#endif // !WIN32 +#endif // !__WIN__ XLOAD::Close(); } // end of Close @@ -2819,7 +2848,7 @@ void XHUGE::Close(char *fn, int id) /***********************************************************************/ /* Don't know whether this is possible for huge files. */ /***********************************************************************/ -void *XHUGE::FileView(PGLOBAL g, char *fn) +void *XHUGE::FileView(PGLOBAL g, char *) { strcpy(g->Message, MSG(NO_PART_MAP)); return NULL; @@ -2879,7 +2908,7 @@ bool XXROW::Init(PGLOBAL g) /***********************************************************************/ /* RANGE: Tell how many record exist in a given value range. */ /***********************************************************************/ -int XXROW::Range(PGLOBAL g, int limit, bool incl) +int XXROW::Range(PGLOBAL, int limit, bool incl) { int n = Valp->GetIntValue(); @@ -2895,7 +2924,7 @@ int XXROW::Range(PGLOBAL g, int limit, bool incl) /***********************************************************************/ /* XXROW: Fetch a physical or logical record. */ /***********************************************************************/ -int XXROW::Fetch(PGLOBAL g) +int XXROW::Fetch(PGLOBAL) { if (Num_K == 0) return -1; // means end of file @@ -2904,7 +2933,7 @@ int XXROW::Fetch(PGLOBAL g) /* Look for a key equal to the link column of previous table, */ /* and return its rank whithin the index table. */ /*********************************************************************/ - Cur_K = FastFind(1); + Cur_K = FastFind(); if (Cur_K >= Num_K) /*******************************************************************/ @@ -2926,7 +2955,7 @@ int XXROW::Fetch(PGLOBAL g) /***********************************************************************/ /* FastFind: Returns the index of matching record in a join. */ /***********************************************************************/ -int XXROW::FastFind(int nk) +int XXROW::FastFind(void) { int n = Valp->GetIntValue(); @@ -3158,12 +3187,18 @@ bool KXYCOL::InitFind(PGLOBAL g, PXOB xp) xp->Reset(); xp->Eval(g); Valp->SetValue_pval(xp->GetValue(), false); -// Valp->SetValue_pval(xp->GetValue(), !Prefix); } // endif Type + if (trace > 1) { + char buf[32]; + + htrc("KCOL InitFind: value=%s\n", Valp->GetCharString(buf)); + } // endif trace + return false; } // end of InitFind +#if 0 /***********************************************************************/ /* InitBinFind: initialize Value to the value pointed by vp. */ /***********************************************************************/ @@ -3171,6 +3206,7 @@ void KXYCOL::InitBinFind(void *vp) { Valp->SetBinValue(vp); } // end of InitBinFind +#endif // 0 /***********************************************************************/ /* KXYCOL FillValue: called by COLBLK::Eval when a column value is */ diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h index 6e40e9b160e..51b678992ea 100644 --- a/storage/connect/xindex.h +++ b/storage/connect/xindex.h @@ -1,7 +1,7 @@ /*************** Xindex H Declares Source Code File (.H) ***************/ /* Name: XINDEX.H Version 3.5 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2004 - 2013 */ +/* (C) Copyright to the author Olivier BERTRAND 2004 - 2015 */ /* */ /* This file contains the XINDEX class declares. */ /***********************************************************************/ @@ -65,7 +65,11 @@ typedef struct index_def : public BLOCK { typedef struct index_off { union { +#if defined(WORDS_BIGENDIAN) + struct {int High; int Low;}; +#else // !WORDS_BIGENDIAN struct {int Low; int High;}; +#endif //!WORDS_BIGENDIAN longlong Val; // File position }; // end of union } IOFF; @@ -205,12 +209,11 @@ class DllExport XXBASE : public CSORT, public BLOCK { #endif // XMAP virtual int MaxRange(void) {return 1;} virtual int Fetch(PGLOBAL g) = 0; - virtual bool NextVal(bool eq) {return true;} + virtual bool NextVal(bool) {return true;} virtual bool PrevVal(void) {return true;} - virtual int FastFind(int nk) = 0; - virtual bool Reorder(PGLOBAL g) {return true;} - virtual int Range(PGLOBAL g, int limit = 0, bool incl = true) - {return -1;} // Means error + virtual int FastFind(void) = 0; + virtual bool Reorder(PGLOBAL) {return true;} + virtual int Range(PGLOBAL, int = 0, bool = true) {return -1;} // Means error virtual int Qcompare(int *, int *) = 0; virtual int GroupSize(void) {return 1;} virtual void Close(void) = 0; @@ -266,7 +269,7 @@ class DllExport XINDEX : public XXBASE { #endif // XMAP virtual int Qcompare(int *, int *); virtual int Fetch(PGLOBAL g); - virtual int FastFind(int nk); + virtual int FastFind(void); virtual int GroupSize(void); virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); virtual int MaxRange(void) {return MaxSame;} @@ -280,7 +283,7 @@ class DllExport XINDEX : public XXBASE { bool GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk); protected: - bool AddColumns(PIXDEF xdp); + bool AddColumns(void); bool NextValDif(void); // Members @@ -312,7 +315,7 @@ class DllExport XINDXS : public XINDEX { // Methods virtual int Qcompare(int *, int *); virtual int Fetch(PGLOBAL g); - virtual int FastFind(int nk); + virtual int FastFind(void); virtual bool NextVal(bool eq); virtual bool PrevVal(void); virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); @@ -347,7 +350,7 @@ class DllExport XLOAD : public BLOCK { protected: // Members -#if defined(WIN32) +#if defined(__WIN__) HANDLE Hfile; // Handle to file or map #else // UNIX int Hfile; // Descriptor to file or map @@ -421,14 +424,14 @@ class DllExport XXROW : public XXBASE { // Methods virtual bool Init(PGLOBAL g); #if defined(XMAP) - virtual bool MapInit(PGLOBAL g) {return true;} + virtual bool MapInit(PGLOBAL) {return true;} #endif // XMAP virtual int Fetch(PGLOBAL g); - virtual int FastFind(int nk); + virtual int FastFind(void); virtual int MaxRange(void) {return 1;} virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); virtual int Qcompare(int *, int *) {assert(false); return 0;} - virtual bool Make(PGLOBAL g, PIXDEF sxp) {return false;} + virtual bool Make(PGLOBAL, PIXDEF) {return false;} virtual void Close(void) {} protected: @@ -463,7 +466,7 @@ class KXYCOL: public BLOCK { virtual void FreeData(void); virtual void FillValue(PVAL valp); virtual int CompVal(int i); - void InitBinFind(void *vp); +// void InitBinFind(void *vp); bool MakeBlockArray(PGLOBAL g, int nb, int size); int Compare(int i1, int i2); int CompBval(int i); diff --git a/storage/connect/xobject.cpp b/storage/connect/xobject.cpp index 92bf039c07c..a6faebf3c2b 100644 --- a/storage/connect/xobject.cpp +++ b/storage/connect/xobject.cpp @@ -11,6 +11,7 @@ /* Include mariaDB header file. */ /***********************************************************************/ #include "my_global.h" +#include "m_string.h" /***********************************************************************/ /* Include required application header files */ diff --git a/storage/connect/xobject.h b/storage/connect/xobject.h index 8e2358dd526..82ff9e21225 100644 --- a/storage/connect/xobject.h +++ b/storage/connect/xobject.h @@ -42,9 +42,9 @@ class DllExport XOBJECT : public BLOCK { virtual int GetResultType(void) {return TYPE_VOID;} virtual int GetKey(void) {return 0;} #if defined(_DEBUG) - virtual void SetKey(int k) {assert(false);} + virtual void SetKey(int) {assert(false);} #else // !_DEBUG - virtual void SetKey(int k) {} // Only defined for COLBLK + virtual void SetKey(int) {} // Only defined for COLBLK #endif // !_DEBUG virtual int GetLength(void) = 0; virtual int GetLengthEx(void) = 0; diff --git a/storage/connect/xtable.h b/storage/connect/xtable.h index d1ea2b0d85f..1a75d97bafa 100644 --- a/storage/connect/xtable.h +++ b/storage/connect/xtable.h @@ -77,21 +77,21 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block. virtual int GetTdb_No(void) {return Tdb_No;} virtual PTDB GetNext(void) {return Next;} virtual PCATLG GetCat(void) {return NULL;} - virtual void SetAbort(bool b) {;} + virtual void SetAbort(bool) {;} // Methods virtual bool IsSame(PTDB tp) {return tp == this;} virtual bool IsSpecial(PSZ name) = 0; - virtual bool GetBlockValues(PGLOBAL g) {return false;} - virtual int Cardinality(PGLOBAL g) {return 0;} + virtual bool GetBlockValues(PGLOBAL) {return false;} + virtual int Cardinality(PGLOBAL) {return 0;} virtual int GetMaxSize(PGLOBAL) = 0; virtual int GetProgMax(PGLOBAL) = 0; virtual int GetProgCur(void) = 0; virtual int RowNumber(PGLOBAL g, bool b = false); virtual bool IsReadOnly(void) {return true;} virtual const CHARSET_INFO *data_charset() {return NULL;} - virtual PTDB Duplicate(PGLOBAL g) {return NULL;} - virtual PTDB CopyOne(PTABS t) {return this;} + virtual PTDB Duplicate(PGLOBAL) {return NULL;} + virtual PTDB CopyOne(PTABS) {return this;} virtual PTDB Copy(PTABS t); virtual void PrintAM(FILE *f, char *m) {fprintf(f, "%s AM(%d)\n", m, GetAmType());} @@ -108,7 +108,7 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block. virtual int WriteDB(PGLOBAL) = 0; virtual int DeleteDB(PGLOBAL, int) = 0; virtual void CloseDB(PGLOBAL) = 0; - virtual int CheckWrite(PGLOBAL g) {return 0;} + virtual int CheckWrite(PGLOBAL) {return 0;} virtual bool ReadKey(PGLOBAL, OPVAL, const void *, int) = 0; protected: @@ -155,7 +155,7 @@ class DllExport TDBASE : public TDB { PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;} // Methods - virtual bool IsUsingTemp(PGLOBAL g) {return false;} + virtual bool IsUsingTemp(PGLOBAL) {return false;} virtual bool IsIndexed(void) {return false;} virtual bool IsSpecial(PSZ name); virtual PCATLG GetCat(void); @@ -170,9 +170,9 @@ class DllExport TDBASE : public TDB { virtual CHARSET_INFO *data_charset(void); virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);} virtual int GetProgCur(void) {return GetRecpos();} - virtual PSZ GetFile(PGLOBAL g) {return "Not a file";} + virtual PSZ GetFile(PGLOBAL) {return "Not a file";} virtual int GetRemote(void) {return 0;} - virtual void SetFile(PGLOBAL g, PSZ fn) {} + virtual void SetFile(PGLOBAL, PSZ) {} virtual void ResetDB(void) {} virtual void ResetSize(void) {MaxSize = -1;} virtual void RestoreNrec(void) {} @@ -183,12 +183,12 @@ class DllExport TDBASE : public TDB { virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); virtual PCOL MakeCol(PGLOBAL, PCOLDEF, PCOL, int) {assert(false); return NULL;} - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); + virtual PCOL InsertSpecialColumn(PCOL colp); virtual PCOL InsertSpcBlk(PGLOBAL g, PCOLDEF cdp); virtual void MarkDB(PGLOBAL g, PTDB tdb2); - virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) + virtual int MakeIndex(PGLOBAL g, PIXDEF, bool) {strcpy(g->Message, "Remote index"); return RC_INFO;} - virtual bool ReadKey(PGLOBAL g, OPVAL op, const void *key, int len) + virtual bool ReadKey(PGLOBAL, OPVAL, const void *, int) {assert(false); return true;} protected: @@ -225,7 +225,7 @@ class DllExport TDBCAT : public TDBASE { // Methods virtual int GetRecpos(void) {return N;} virtual int GetProgCur(void) {return N;} - virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} + virtual int RowNumber(PGLOBAL, bool = false) {return N + 1;} virtual bool SetRecpos(PGLOBAL g, int recpos); // Database routines |