From e8ea671c2523f56fce0eacabbba05689aa4824f9 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 2 Jun 2015 10:34:51 +0200 Subject: Commit changes pulled from ob-10.0 --- storage/connect/array.cpp | 6 +- storage/connect/blkfil.cpp | 6 +- storage/connect/block.h | 8 +- storage/connect/colblk.cpp | 4 +- storage/connect/domdoc.cpp | 2 +- storage/connect/filamap.cpp | 16 +- storage/connect/filamdbf.cpp | 10 +- storage/connect/filamfix.cpp | 44 ++-- storage/connect/filamtxt.cpp | 46 ++-- storage/connect/filamvct.cpp | 74 +++--- storage/connect/filamzip.cpp | 16 +- storage/connect/filter.cpp | 6 +- storage/connect/filter.h | 2 +- storage/connect/fmdlex.c | 5 +- storage/connect/global.h | 18 +- storage/connect/ha_connect.cc | 313 ++++++++++++++---------- storage/connect/json.cpp | 2 +- storage/connect/libdoc.cpp | 5 +- storage/connect/macutil.cpp | 8 +- storage/connect/macutil.h | 8 +- storage/connect/maputil.cpp | 2 +- storage/connect/mycat.cc | 46 ++-- storage/connect/mycat.h | 2 +- storage/connect/myconn.cpp | 12 +- storage/connect/myconn.h | 12 +- storage/connect/mysql-test/connect/r/bin.result | 32 +-- storage/connect/mysql-test/connect/t/bin.test | 16 +- storage/connect/myutil.cpp | 6 +- storage/connect/odbconn.cpp | 30 ++- storage/connect/odbconn.h | 4 +- storage/connect/os.h | 10 +- storage/connect/osutil.c | 2 +- storage/connect/plgdbsem.h | 10 +- storage/connect/plgdbutl.cpp | 46 ++-- storage/connect/plugutil.c | 30 +-- storage/connect/rcmsg.c | 4 +- storage/connect/reldef.cpp | 77 ++++-- storage/connect/reldef.h | 6 +- storage/connect/tabdos.cpp | 20 +- storage/connect/tabdos.h | 1 + storage/connect/tabfix.cpp | 154 +++++++----- storage/connect/tabfix.h | 6 +- storage/connect/tabfmt.cpp | 12 +- storage/connect/tabjson.cpp | 69 +++--- storage/connect/tabjson.h | 12 +- storage/connect/tabmac.cpp | 8 +- storage/connect/tabmac.h | 8 +- storage/connect/tabmul.cpp | 78 +++--- storage/connect/tabmul.h | 18 +- storage/connect/tabmysql.cpp | 6 +- storage/connect/taboccur.cpp | 2 +- storage/connect/tabodbc.cpp | 2 +- storage/connect/tabpivot.cpp | 2 +- storage/connect/tabsys.cpp | 20 +- storage/connect/tabtbl.cpp | 8 +- storage/connect/tabutil.cpp | 2 +- storage/connect/tabvct.cpp | 6 +- storage/connect/tabwmi.cpp | 6 +- storage/connect/tabxcl.cpp | 2 +- storage/connect/tabxml.cpp | 90 +++---- storage/connect/tabxml.h | 5 +- storage/connect/valblk.cpp | 2 +- storage/connect/value.cpp | 14 +- storage/connect/value.h | 10 +- storage/connect/xindex.cpp | 90 +++++-- storage/connect/xindex.h | 4 +- 66 files changed, 866 insertions(+), 737 deletions(-) (limited to 'storage/connect') diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index 0e8829d66a6..193514eeb99 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -19,14 +19,14 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include -#else // !WIN32 +#else // !__WIN__ #include #include #include #include // for uintprt_h -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include required application header files */ diff --git a/storage/connect/blkfil.cpp b/storage/connect/blkfil.cpp index c6fb528aa5f..1f5a1a27ae5 100644 --- a/storage/connect/blkfil.cpp +++ b/storage/connect/blkfil.cpp @@ -20,13 +20,13 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include -#else // !WIN32 +#else // !__WIN__ #include #include #include -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ diff --git a/storage/connect/block.h b/storage/connect/block.h index 40529ffc81f..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)); diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index 7166af8027b..80b405be041 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -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); 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 -#if defined(WIN32) +#if defined(__WIN__) //#include #if defined(MSX2) #import "msxml2.dll" //Does not exist on Vista diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index cac34827b7a..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 -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #include @@ -30,7 +30,7 @@ #include #endif // !UNIX #include -#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 @@ -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); diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp index 4d66c2ab2ff..8afda723578 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -22,12 +22,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include #include //#include //#include -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #include @@ -35,7 +35,7 @@ //#include #endif // !UNIX //#include -#endif // !WIN32 +#endif // !__WIN__ #include #include #include @@ -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. */ diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp index c352db47044..cd25429318a 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include #include #include @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #include @@ -34,7 +34,7 @@ #endif // !UNIX #include #include -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -338,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) @@ -678,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; @@ -694,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 @@ -714,7 +714,7 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)), { int rc; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbr, drc, len = (DWORD)req; bool brc = ReadFile(h, inbuf, len, &nbr, NULL); @@ -736,12 +736,12 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)), 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 @@ -753,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); @@ -780,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); @@ -795,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 @@ -830,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; /*********************************************************************/ @@ -987,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; @@ -1346,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; @@ -1356,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 @@ -1386,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); @@ -1526,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 cce9cec56bd..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 #include #include @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) || defined(UNIV_LINUX) #include #include @@ -36,7 +36,7 @@ #include #endif // !UNIX #include -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -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 @@ -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/filamvct.cpp b/storage/connect/filamvct.cpp index 60a8875e015..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 #include #if defined(__BORLANDC__) @@ -29,7 +29,7 @@ #endif // __BORLAND__ //#include #include -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #include @@ -40,7 +40,7 @@ #include #endif // !UNIX #include -#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" @@ -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) { @@ -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) { @@ -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 54af93e11fa..56faa555069 100644 --- a/storage/connect/filamzip.cpp +++ b/storage/connect/filamzip.cpp @@ -17,21 +17,21 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include #include #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif //#include -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #else // !UNIX #include #endif #include -#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 @@ -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 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 -#else // !WIN32 +#else // !__WIN__ #include #include #include -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ diff --git a/storage/connect/filter.h b/storage/connect/filter.h index ab7c2139b68..15730e2cc44 100644 --- a/storage/connect/filter.h +++ b/storage/connect/filter.h @@ -106,7 +106,7 @@ class FILTERX : public FILTER { // Fake operator new used to change a filter into a derived filter void * operator new(size_t, PFIL filp) {return filp;} -#if defined(WIN32) +#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 -#ifndef WIN32 +#ifndef __WIN__ #include #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_t type declaration */ #include /* 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 964185b1b27..6769760c5fa 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 #include "tabwmi.h" -#endif // WIN32 +#endif // __WIN__ #include "connect.h" #include "user_connect.h" #include "ha_connect.h" @@ -170,12 +170,12 @@ extern "C" { char version[]= "Version 1.03.0007 April 30, 2015"; -#if defined(WIN32) +#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) @@ -195,9 +195,8 @@ extern "C" { /***********************************************************************/ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); PQRYRES VirColumns(PGLOBAL g, 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 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); @@ -630,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(); @@ -676,9 +675,9 @@ static int connect_done_func(void *) 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) @@ -745,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; @@ -1017,6 +1016,117 @@ char *GetListOption(PGLOBAL g, const char *opname, return opval; } // 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. */ /****************************************************************************/ @@ -1035,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); @@ -1048,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) { @@ -1066,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; @@ -1104,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, "*")) { @@ -1145,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 @@ -1198,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 /****************************************************************************/ @@ -3957,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) @@ -4720,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 @@ -4965,12 +5003,12 @@ static int connect_assisted_discovery(handlerton *, 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= 0, mxe= 0, rc= 0, lvl= 0; - int cop __attribute__((unused))= 0, pty= 2, lrecl= 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; @@ -5000,7 +5038,7 @@ static int connect_assisted_discovery(handlerton *, 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); @@ -5031,11 +5069,10 @@ static int connect_assisted_discovery(handlerton *, 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")); @@ -5049,8 +5086,6 @@ static int connect_assisted_discovery(handlerton *, 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"); @@ -5194,11 +5229,11 @@ static int connect_assisted_discovery(handlerton *, 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; @@ -5311,11 +5346,11 @@ static int connect_assisted_discovery(handlerton *, 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: @@ -5342,7 +5377,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, 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: @@ -5491,10 +5526,11 @@ static int connect_assisted_discovery(handlerton *, 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)", @@ -5511,6 +5547,13 @@ static int connect_assisted_discovery(handlerton *, 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 @@ -5769,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': @@ -6120,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()); @@ -6608,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/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 -#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 0ef43a245fa..9c72e9cd665 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -30,7 +30,7 @@ /***********************************************************************/ #include -#if defined(WIN32) +#if defined(__WIN__) //#include //#include #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,9 +93,9 @@ /***********************************************************************/ /* 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); @@ -142,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 @@ -349,11 +349,11 @@ 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, soname[_MAX_PATH], getname[40] = "Col"; -#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__ XCOLDEF coldef = NULL; PQRYRES qrp = NULL; @@ -381,7 +381,7 @@ 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(soname))) { char buf[256]; @@ -401,7 +401,7 @@ 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 @@ -418,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); @@ -426,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 @@ -442,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; @@ -489,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); @@ -554,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; diff --git a/storage/connect/mycat.h b/storage/connect/mycat.h index f7c4c70eaf5..d4024e6b6c3 100644 --- a/storage/connect/mycat.h +++ b/storage/connect/mycat.h @@ -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) diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 2b958b512f3..ada0109a820 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -35,11 +35,11 @@ #include "my_sys.h" #include "mysqld_error.h" #endif // !MYSQL_PREPARED_STATEMENTS -#if defined(WIN32) +#if defined(__WIN__) //#include -#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, "*")) { 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 -#else // !WIN32 +#else // !__WIN__ #include -#endif // !WIN32 +#endif // !__WIN__ #include #include #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 69453d97534..4ba353ac705 100644 --- a/storage/connect/mysql-test/connect/r/bin.result +++ b/storage/connect/mysql-test/connect/r/bin.result @@ -15,11 +15,11 @@ CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', name CHAR(10) NOT NULL, -birth DATE NOT NULL FIELD_FORMAT='L', -id CHAR(5) NOT NULL FIELD_FORMAT='L2', +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='L2' -) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; +dept INT(4) NOT NULL FIELD_FORMAT='S' +) 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 @@ -42,11 +42,11 @@ CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', name CHAR(10) NOT NULL, -birth DATE NOT NULL FIELD_FORMAT='L', -id CHAR(5) NOT NULL FIELD_FORMAT='L2', +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='L2' -) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat'; +dept INT(4) NOT NULL FIELD_FORMAT='S' +) 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; @@ -55,11 +55,11 @@ Table Create Table t1 CREATE TABLE `t1` ( `fig` int(4) NOT NULL `FIELD_FORMAT`='C', `name` char(10) NOT NULL, - `birth` date NOT NULL `FIELD_FORMAT`='L', - `id` char(5) NOT NULL `FIELD_FORMAT`='L2', + `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`='L2' -) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `READONLY`=NO + `dept` int(4) NOT NULL `FIELD_FORMAT`='S' +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=NO INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); SELECT * FROM t1; fig name birth id salary dept @@ -74,11 +74,11 @@ Table Create Table t1 CREATE TABLE `t1` ( `fig` int(4) NOT NULL `FIELD_FORMAT`='C', `name` char(10) NOT NULL, - `birth` date NOT NULL `FIELD_FORMAT`='L', - `id` char(5) NOT NULL `FIELD_FORMAT`='L2', + `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`='L2' -) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `READONLY`=YES + `dept` int(4) NOT NULL `FIELD_FORMAT`='S' +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=YES INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); ERROR HY000: Table 't1' is read only DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/t/bin.test b/storage/connect/mysql-test/connect/t/bin.test index e9d1ad58c37..1e45bcaf93a 100644 --- a/storage/connect/mysql-test/connect/t/bin.test +++ b/storage/connect/mysql-test/connect/t/bin.test @@ -20,11 +20,11 @@ CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', name CHAR(10) NOT NULL, - birth DATE NOT NULL FIELD_FORMAT='L', - id CHAR(5) NOT NULL FIELD_FORMAT='L2', + 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='L2' -) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; + dept INT(4) NOT NULL FIELD_FORMAT='S' +) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; SELECT * FROM t1; --error ER_GET_ERRMSG @@ -41,11 +41,11 @@ CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', name CHAR(10) NOT NULL, - birth DATE NOT NULL FIELD_FORMAT='L', - id CHAR(5) NOT NULL FIELD_FORMAT='L2', + 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='L2' -) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat'; + dept INT(4) NOT NULL FIELD_FORMAT='S' +) 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/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 -#if defined(WIN32) +#if defined(__WIN__) //#include -#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 #include -#if defined(WIN32) +#if defined(__WIN__) //nclude //nclude #include // 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 #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 a2b1baf1249..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 #include #include #define BIGMEM 1048576 // 1 Megabyte -#else // !WIN32 +#else // !__WIN__ #include #include #if defined(THREAD) @@ -51,7 +51,7 @@ #endif // THREAD #include #define BIGMEM 2147483647 // Max int value -#endif // !WIN32 +#endif // !__WIN__ #include /***********************************************************************/ @@ -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) @@ -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 #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 4563500254b..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 #else #include // dlopen(), dlclose(), dlsym() ... @@ -48,9 +48,9 @@ #include "tabmul.h" #include "ha_connect.h" -#if !defined(WIN32) +#if !defined(__WIN__) extern handlerton *connect_hton; -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* External function. */ @@ -247,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 /***********************************************************************/ @@ -256,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; @@ -331,28 +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 : cdp->Decode ? 'C' : 'X') { - case 'X': nof= cdp->Clen; - 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: /* New format */ - for (nof= 0, i= 0; cdp->Fmt[i]; i++) - if (isdigit(cdp->Fmt[i])) - nof= (nof * 10 + (cdp->Fmt[i] - '0')); - - if (!nof) + 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; - } // endswitch Fmt + break; + case 'C': break; + case 'R': + 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; @@ -454,7 +479,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) } else PlugSetPath(soname, Module, GetPluginDir()); -#if defined(WIN32) +#if defined(__WIN__) // Is the DLL already loaded? if (!Hdll && !(Hdll = GetModuleHandle(soname))) // No, load the Dll implementing the function @@ -483,7 +508,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) FreeLibrary((HMODULE)Hdll); return NULL; } // endif getdef -#else // !WIN32 +#else // !__WIN__ const char *error = NULL; Dl_info dl_info; @@ -526,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); diff --git a/storage/connect/reldef.h b/storage/connect/reldef.h index ec70f18e151..4aa29037dfc 100644 --- a/storage/connect/reldef.h +++ b/storage/connect/reldef.h @@ -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/tabdos.cpp b/storage/connect/tabdos.cpp index 37bd94cf1bb..a1e58ab3344 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include #include // For testing only #include @@ -26,7 +26,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #include @@ -34,7 +34,7 @@ #include #endif // !UNIX #include -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -112,6 +112,7 @@ DOSDEF::DOSDEF(void) Maxerr = 0; ReadMode = 0; Ending = 0; + Teds = 0; } // end of DOSDEF constructor /***********************************************************************/ @@ -146,6 +147,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int) 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 @@ -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 diff --git a/storage/connect/tabdos.h b/storage/connect/tabdos.h index 9115b1fae86..c098886f14b 100644 --- a/storage/connect/tabdos.h +++ b/storage/connect/tabdos.h @@ -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 /***********************************************************************/ diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp index af92ec0410a..acd548c86ab 100644 --- a/storage/connect/tabfix.cpp +++ b/storage/connect/tabfix.cpp @@ -17,7 +17,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include #include #include @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #include @@ -35,7 +35,7 @@ #include #endif // !UNIX #include -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -68,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 @@ -374,42 +376,63 @@ 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) { - char *fmt = cdp->GetFmt(); + 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) { - Fmt = 'H'; + for (N = 0, i = 0; fmt[i]; i++) { + c = toupper(fmt[i]); - for (N = 0, i = 0; fmt[i]; i++) - if (isdigit(fmt[i])) - N = (N * 10 + (fmt[i] - '0')); + if (isdigit(c)) + N = (N * 10 + (c - '0')); + else if (c == 'L' || c == 'B' || c == 'H') + Eds = c; else - Fmt = toupper(fmt[i]); - - if (N == GetTypeSize(Buf_Type, -1) && (Fmt == 'H' || Fmt == Endian)) { - // New format is a no op - N = 0; - Fmt = 'X'; - } else if (Fmt == 'L' || Fmt == 'B' || Fmt == 'H') { - // This is a new format - if (!N) - N = GetTypeSize(Buf_Type, Long); - - if (Fmt == 'H') - Fmt = Endian; - + 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); - } // endif Fmt + } else + Eds = 0; // New format is a no op - } else { - N = 0; - Fmt = GetDomain() ? 'C' : 'X'; - } // endif fmt + } // endif Eds } // end of BINCOL constructor @@ -419,6 +442,7 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am) /***********************************************************************/ BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp) { + Eds = col1->Eds; Fmt = col1->Fmt; N = col1->N; M = col1->M; @@ -470,25 +494,27 @@ void BINCOL::ReadColumn(PGLOBAL g) /*********************************************************************/ /* Set Value from the line field. */ /*********************************************************************/ - if (N) { + if (Eds) { for (int i = 0; i < Lim; i++) - if (Fmt == 'B' && Endian == 'L') + if (Eds == 'B' && Endian == 'L') Buff[i] = p[N - i - 1]; - else if (Fmt == 'L' && Endian == 'B') + 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]; - if (IsTypeChar(Buf_Type)) - Value->SetValue(*(longlong*)Buff); - else - Value->SetBinValue(Buff); + p = Buff; + } // endif Eds - } else switch (Fmt) { + 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(*(short*)p); @@ -496,12 +522,12 @@ void BINCOL::ReadColumn(PGLOBAL g) case 'T': // Tiny integer 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); @@ -553,41 +579,23 @@ 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. */ /* Updating will be done only during the second pass (Status=true) */ /* Conversion occurs if the external format Fmt is specified. */ /*********************************************************************/ - if (N) { - if (IsTypeChar(Buf_Type)) - *(longlong *)Buff = Value->GetBigintValue(); - else if (Value->GetBinValue(Buff, M, Status)) { - sprintf(g->Message, MSG(BIN_F_TOO_LONG), - Name, Value->GetSize(), M); - longjmp(g->jumper[g->jump_level], 31); - } // endif Buff - - if (Status) - for (int i = 0; i < Lim; i++) - if (Fmt == 'B' && Endian == 'L') - p[N - i - 1] = Buff[i]; - else if (Fmt == '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]; - - } else switch (Fmt) { + 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 p + } // endif p break; case 'S': // Short integer @@ -610,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(); @@ -623,7 +628,7 @@ void BINCOL::WriteColumn(PGLOBAL g) *(int *)p = Value->GetIntValue(); break; - case 'B': // Large (big) integer + case 'G': // Large (great) integer if (Status) *(longlong *)p = Value->GetBigintValue(); @@ -657,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 b6307e8f60b..49956ba0711 100644 --- a/storage/connect/tabfix.h +++ b/storage/connect/tabfix.h @@ -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 /***********************************************************************/ @@ -86,7 +87,8 @@ class DllExport BINCOL : public DOSCOL { // Members static char Endian; // The host endian setting (L or B) char *Buff; // Utility buffer - char Fmt; // The file endian setting or old format + 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) diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index a5e14e1b81f..015f8d93b15 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -20,7 +20,7 @@ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include #include #include @@ -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; diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 34d5827345f..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; @@ -91,26 +90,29 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, 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)) @@ -118,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); @@ -265,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: @@ -285,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: @@ -341,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; @@ -356,8 +357,7 @@ JSONDEF::JSONDEF(void) Xcol = NULL; Pretty = 2; Limit = 1; - Level = 0; - ReadMode = 0; + Base = 0; Strict = false; } // end of JSONDEF constructor @@ -370,9 +370,8 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) 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); + Base = GetIntCatInfo("Base", 0) ? 1 : 0; return DOSDEF::DefineAM(g, "DOS", poff); } // end of DefineAM @@ -624,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) { @@ -1856,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 /***********************************************************************/ @@ -1868,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 4e5f84b1190..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); @@ -226,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/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 -#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 #include -#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 12e8de2c808..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 #include #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 @@ -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 @@ -876,17 +876,17 @@ int TDBDIR::DeleteDB(PGLOBAL g, int) /***********************************************************************/ 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 @@ -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 -#else // !WIN32 +#else // !__WIN__ #include #include #include #include -#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 cb7011822d8..19a5dfd758f 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -35,9 +35,9 @@ #include "my_global.h" #include "sql_class.h" #include "sql_servers.h" -#if defined(WIN32) +#if defined(__WIN__) //#include -#else // !WIN32 +#else // !__WIN__ //#include //#include #include @@ -46,7 +46,7 @@ #include "osutil.h" //#include //#include -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index da3cafc3c8f..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 #include #if defined(__BORLANDC__) diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index 3bf1238cebc..ad7892469cd 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 #include #if defined(__BORLANDC__) diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index b36dcbf94af..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 diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp index 623aeca36fe..76890e84429 100644 --- a/storage/connect/tabsys.cpp +++ b/storage/connect/tabsys.cpp @@ -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 -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #include @@ -25,7 +25,7 @@ #include #endif // !UNIX #include -#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 ------------------ */ @@ -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); @@ -345,9 +345,9 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ void TDBINI::CloseDB(PGLOBAL) { -#if !defined(WIN32) +#if !defined(__WIN__) PROFILE_Close(Ifile); -#endif // !WIN32 +#endif // !__WIN__ } // end of CloseDB // ------------------------ INICOL functions ---------------------------- diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index f2affe75d2b..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 #include #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 ---------------------------- */ diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 5ed958b2f7a..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 #include #if defined(__BORLANDC__) diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp index 6394ea5e2d6..e788529075f 100644 --- a/storage/connect/tabvct.cpp +++ b/storage/connect/tabvct.cpp @@ -35,7 +35,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include #include #if defined(__BORLANDC__) @@ -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; 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 diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index 7d6d94d34c0..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 #include #if defined(__BORLANDC__) diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index 46f762efc35..49fa9a1c554 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -15,12 +15,12 @@ #include #include #include -#if defined(WIN32) +#if defined(__WIN__) #include #include //#include #include -#else // !WIN32 +#else // !__WIN__ #include #include #include @@ -28,7 +28,7 @@ //#include #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,14 +110,14 @@ 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]; + char *fn, *op, colname[65], fmt[129], buf[512]; int i, j, lvl, n = 0; int ncol = sizeof(buftyp) / sizeof(int); bool ok = true; @@ -138,26 +138,28 @@ 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'); @@ -432,7 +434,7 @@ XMLDEF::XMLDEF(void) /***********************************************************************/ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - char *defrow, *defcol, buf[10]; + char *defrow, *defcol, buf[10]; Fn = GetStringCatInfo(g, "Filename", NULL); Encoding = GetStringCatInfo(g, "Encoding", "UTF-8"); @@ -447,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)) { @@ -480,29 +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)); // 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 @@ -543,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; @@ -876,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]; @@ -890,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 @@ -1015,7 +1017,7 @@ int TDBXML::GetMaxSize(PGLOBAL g) else MaxSize = 10; - } // endif MaxSize + } // endif MaxSize return MaxSize; } // end of GetMaxSize @@ -1256,7 +1258,7 @@ void TDBXML::CloseDB(PGLOBAL g) { if (Docp) { if (Changed) { - char filename[_MAX_PATH]; + char filename[_MAX_PATH]; // We used the file name relative to recorded datapath PlugSetPath(filename, Xfile, GetPath()); @@ -1660,7 +1662,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) /*********************************************************************/ /* Null values are represented by no node. */ /*********************************************************************/ - if (Value->IsNull()) + if (Value->IsNull()) return; /*********************************************************************/ @@ -2160,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 @@ -2169,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 4eae5c082c1..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. */ /***********************************************************************/ @@ -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/valblk.cpp b/storage/connect/valblk.cpp index 94e09e1a85c..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 #else #include "osutil.h" diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 5a8b1de326a..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 -#else // !WIN32 +#else // !__WIN__ #include -#endif // !WIN32 +#endif // !__WIN__ #include @@ -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. */ @@ -1618,10 +1618,10 @@ int TYPVAL::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 diff --git a/storage/connect/value.h b/storage/connect/value.h index 207944594f1..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); @@ -359,14 +360,9 @@ class DllExport DTVAL : public TYPVAL { public: // Constructors DTVAL(PGLOBAL g, int n, int p, PSZ fmt); -//DTVAL(PGLOBAL g, PSZ s, int n); -//DTVAL(PGLOBAL g, short i); DTVAL(int n); -//DTVAL(PGLOBAL g, longlong n); -//DTVAL(PGLOBAL g, double f); // 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 ee8dc3ac4cb..a2d75cec8ab 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -10,12 +10,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include #include #include //#include -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include #include @@ -25,7 +25,7 @@ #include #endif // !UNIX #include -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include required application header files */ @@ -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); @@ -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. */ /*******************************************************************/ @@ -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; @@ -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,7 +1830,7 @@ 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(); @@ -1896,6 +1902,10 @@ int XINDEX::FastFind(void) 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(void) 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 @@ -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,7 +2172,7 @@ 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(); @@ -2192,7 +2204,7 @@ int XINDXS::Fetch(PGLOBAL g) /***********************************************************************/ 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(void) if (inf < 0) return Num_K; -// i = inf; inf *= Sblk; if ((sup = inf + Sblk) > Ndif) @@ -2227,6 +2238,10 @@ int XINDXS::FastFind(void) 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(void) 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"); @@ -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 @@ -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 079412b32cf..a4e98075222 100644 --- a/storage/connect/xindex.h +++ b/storage/connect/xindex.h @@ -346,7 +346,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 @@ -462,7 +462,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); -- cgit v1.2.1