summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-06-27 20:35:26 +0200
committerSergei Golubchik <serg@mariadb.org>2015-06-27 20:35:26 +0200
commit658992699b204da04382142e77af042c8a33a334 (patch)
tree464bc87eae9ffb0fd1a7ba6fa11148b50a295d6b /storage
parentfe7e334f3e238368e18fc2ccb98b3357ecb1e03e (diff)
parenta6087e7dc1ef3561d8189c8db15e9591d0f9b520 (diff)
downloadmariadb-git-658992699b204da04382142e77af042c8a33a334.tar.gz
Merge tag 'mariadb-10.0.20' into 10.1
Diffstat (limited to 'storage')
-rw-r--r--storage/connect/array.cpp16
-rw-r--r--storage/connect/blkfil.cpp28
-rw-r--r--storage/connect/block.h10
-rw-r--r--storage/connect/catalog.h48
-rw-r--r--storage/connect/colblk.cpp18
-rw-r--r--storage/connect/colblk.h6
-rw-r--r--storage/connect/connect.cc46
-rw-r--r--storage/connect/domdoc.cpp2
-rw-r--r--storage/connect/filamap.cpp30
-rw-r--r--storage/connect/filamdbf.cpp63
-rw-r--r--storage/connect/filamfix.cpp84
-rw-r--r--storage/connect/filamtxt.cpp58
-rw-r--r--storage/connect/filamtxt.h4
-rwxr-xr-xstorage/connect/filamvct.cpp90
-rw-r--r--storage/connect/filamzip.cpp38
-rw-r--r--storage/connect/filter.cpp6
-rw-r--r--storage/connect/filter.h6
-rw-r--r--storage/connect/fmdlex.c5
-rw-r--r--storage/connect/global.h18
-rw-r--r--storage/connect/ha_connect.cc358
-rw-r--r--storage/connect/json.cpp2
-rw-r--r--storage/connect/jsonudf.cpp34
-rw-r--r--storage/connect/libdoc.cpp5
-rw-r--r--storage/connect/macutil.cpp8
-rw-r--r--storage/connect/macutil.h8
-rw-r--r--storage/connect/maputil.cpp2
-rw-r--r--storage/connect/mycat.cc95
-rw-r--r--storage/connect/mycat.h6
-rw-r--r--storage/connect/myconn.cpp16
-rw-r--r--storage/connect/myconn.h12
-rw-r--r--storage/connect/mysql-test/connect/r/bin.result12
-rw-r--r--storage/connect/mysql-test/connect/r/json.result20
-rw-r--r--storage/connect/mysql-test/connect/t/bin.test8
-rw-r--r--storage/connect/mysql-test/connect/t/json.test20
-rw-r--r--storage/connect/myutil.cpp6
-rw-r--r--storage/connect/odbconn.cpp30
-rw-r--r--storage/connect/odbconn.h4
-rw-r--r--storage/connect/os.h10
-rw-r--r--storage/connect/osutil.c2
-rw-r--r--storage/connect/plgdbsem.h10
-rw-r--r--storage/connect/plgdbutl.cpp48
-rw-r--r--storage/connect/plugutil.c30
-rw-r--r--storage/connect/rcmsg.c4
-rw-r--r--storage/connect/reldef.cpp126
-rw-r--r--storage/connect/reldef.h10
-rw-r--r--storage/connect/tabcol.cpp8
-rw-r--r--storage/connect/tabdos.cpp45
-rw-r--r--storage/connect/tabdos.h13
-rw-r--r--storage/connect/tabfix.cpp152
-rw-r--r--storage/connect/tabfix.h29
-rw-r--r--storage/connect/tabfmt.cpp18
-rw-r--r--storage/connect/tabfmt.h4
-rw-r--r--storage/connect/tabjson.cpp154
-rw-r--r--storage/connect/tabjson.h20
-rw-r--r--storage/connect/table.cpp28
-rw-r--r--storage/connect/tabmac.cpp8
-rw-r--r--storage/connect/tabmac.h8
-rw-r--r--storage/connect/tabmul.cpp90
-rw-r--r--storage/connect/tabmul.h18
-rw-r--r--storage/connect/tabmysql.cpp30
-rw-r--r--storage/connect/tabmysql.h8
-rw-r--r--storage/connect/taboccur.cpp8
-rw-r--r--storage/connect/tabodbc.cpp8
-rw-r--r--storage/connect/tabpivot.cpp10
-rw-r--r--storage/connect/tabsys.cpp76
-rw-r--r--storage/connect/tabtbl.cpp16
-rw-r--r--storage/connect/tabtbl.h2
-rw-r--r--storage/connect/tabutil.cpp10
-rw-r--r--storage/connect/tabutil.h4
-rw-r--r--storage/connect/tabvct.cpp14
-rw-r--r--storage/connect/tabvir.cpp12
-rw-r--r--storage/connect/tabvir.h2
-rw-r--r--storage/connect/tabwmi.cpp6
-rw-r--r--storage/connect/tabxcl.cpp10
-rw-r--r--storage/connect/tabxcl.h2
-rw-r--r--storage/connect/tabxml.cpp162
-rw-r--r--storage/connect/tabxml.h7
-rw-r--r--storage/connect/user_connect.cc6
-rw-r--r--storage/connect/user_connect.h2
-rw-r--r--storage/connect/valblk.cpp8
-rw-r--r--storage/connect/valblk.h26
-rw-r--r--storage/connect/value.cpp32
-rw-r--r--storage/connect/value.h34
-rwxr-xr-xstorage/connect/xindex.cpp130
-rw-r--r--storage/connect/xindex.h31
-rw-r--r--storage/connect/xobject.cpp1
-rw-r--r--storage/connect/xobject.h4
-rw-r--r--storage/connect/xtable.h26
-rw-r--r--storage/federatedx/README.windows46
-rw-r--r--storage/innobase/api/api0api.cc15
-rw-r--r--storage/innobase/buf/buf0buf.cc277
-rw-r--r--storage/innobase/buf/buf0checksum.cc11
-rw-r--r--storage/innobase/handler/ha_innodb.cc42
-rw-r--r--storage/innobase/include/api0api.h10
-rw-r--r--storage/innobase/include/os0file.h8
-rw-r--r--storage/innobase/include/os0sync.h2
-rw-r--r--storage/innobase/include/page0page.h16
-rw-r--r--storage/innobase/include/page0zip.h15
-rw-r--r--storage/innobase/include/univ.i2
-rw-r--r--storage/innobase/os/os0file.cc11
-rw-r--r--storage/innobase/page/page0page.cc44
-rw-r--r--storage/innobase/page/page0zip.cc99
-rw-r--r--storage/innobase/row/row0mysql.cc95
-rw-r--r--storage/innobase/srv/srv0start.cc30
-rw-r--r--storage/innobase/sync/sync0arr.cc8
-rw-r--r--storage/innobase/trx/trx0sys.cc4
-rw-r--r--storage/innobase/trx/trx0trx.cc5
-rw-r--r--storage/maria/ma_check.c6
-rw-r--r--storage/mroonga/vendor/groonga/CMakeLists.txt4
-rw-r--r--storage/myisam/mi_check.c12
-rw-r--r--storage/myisam/rt_split.c9
-rw-r--r--storage/oqgraph/CMakeLists.txt1
-rw-r--r--storage/perfschema/ha_perfschema.cc2
-rw-r--r--storage/sphinx/mysql-test/sphinx/my.cnf3
-rw-r--r--storage/tokudb/CMakeLists.txt2
-rw-r--r--storage/tokudb/ft-index/buildheader/make_tdb.cc3
-rw-r--r--storage/tokudb/ft-index/ft/ft-verify.cc20
-rw-r--r--storage/tokudb/ft-index/ft/logger/recover.cc62
-rw-r--r--storage/tokudb/ft-index/ft/txn/txn.cc5
-rw-r--r--storage/tokudb/ft-index/ft/txn/txn.h3
-rw-r--r--storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc4
-rw-r--r--storage/tokudb/ft-index/src/tests/test_stress0.cc4
-rw-r--r--storage/tokudb/ft-index/src/ydb.cc21
-rw-r--r--storage/tokudb/ft-index/src/ydb_txn.cc6
-rw-r--r--storage/tokudb/ft-index/tools/CMakeLists.txt9
-rw-r--r--storage/tokudb/ft-index/tools/tokuft_logprint.cc (renamed from storage/tokudb/ft-index/tools/tdb_logprint.cc)2
-rw-r--r--storage/tokudb/ft-index/tools/tokuftdump.cc6
-rw-r--r--storage/tokudb/ft-index/util/scoped_malloc.cc25
-rw-r--r--storage/tokudb/ft-index/util/scoped_malloc.h4
-rw-r--r--storage/tokudb/ft-index/util/tests/sm-basic.cc127
-rw-r--r--storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc128
-rw-r--r--storage/tokudb/ha_tokudb.cc67
-rw-r--r--storage/tokudb/ha_tokudb_admin.cc18
-rw-r--r--storage/tokudb/ha_tokudb_alter_56.cc15
-rw-r--r--storage/tokudb/hatoku_defines.h1
-rw-r--r--storage/tokudb/hatoku_hton.cc18
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result10
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result6
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result10
-rw-r--r--storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test10
-rw-r--r--storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test6
-rw-r--r--storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test10
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/r/db805.result18
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/r/db806.result9
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/r/db811.result14
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result14
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/r/db823.result11
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result5
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/t/db805.test17
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/t/db806.test13
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/t/db811.test22
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test22
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/t/db823.test16
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test3
-rw-r--r--storage/xtradb/api/api0api.cc208
-rw-r--r--storage/xtradb/dict/dict0boot.cc12
-rw-r--r--storage/xtradb/dict/dict0dict.cc94
-rw-r--r--storage/xtradb/dict/dict0load.cc3
-rw-r--r--storage/xtradb/dict/dict0mem.cc31
-rw-r--r--storage/xtradb/fsp/fsp0fsp.cc40
-rw-r--r--storage/xtradb/fts/fts0fts.cc111
-rw-r--r--storage/xtradb/fts/fts0opt.cc9
-rw-r--r--storage/xtradb/fts/fts0que.cc5
-rw-r--r--storage/xtradb/handler/ha_innodb.cc57
-rw-r--r--storage/xtradb/handler/handler0alter.cc2
-rw-r--r--storage/xtradb/handler/i_s.cc11
-rw-r--r--storage/xtradb/ibuf/ibuf0ibuf.cc5
-rw-r--r--storage/xtradb/include/dict0mem.h136
-rw-r--r--storage/xtradb/include/os0sync.h2
-rw-r--r--storage/xtradb/include/univ.i4
-rw-r--r--storage/xtradb/lock/lock0lock.cc4
-rw-r--r--storage/xtradb/log/log0recv.cc4
-rw-r--r--storage/xtradb/mtr/mtr0log.cc2
-rw-r--r--storage/xtradb/os/os0sync.cc20
-rw-r--r--storage/xtradb/page/page0zip.cc6
-rw-r--r--storage/xtradb/pars/pars0pars.cc2
-rw-r--r--storage/xtradb/que/que0que.cc28
-rw-r--r--storage/xtradb/row/row0log.cc23
-rw-r--r--storage/xtradb/row/row0merge.cc151
-rw-r--r--storage/xtradb/row/row0mysql.cc71
-rw-r--r--storage/xtradb/srv/srv0start.cc2
-rw-r--r--storage/xtradb/sync/sync0sync.cc2
-rw-r--r--storage/xtradb/trx/trx0trx.cc5
183 files changed, 3145 insertions, 2192 deletions
diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp
index a2f537436c9..193514eeb99 100644
--- a/storage/connect/array.cpp
+++ b/storage/connect/array.cpp
@@ -1,7 +1,7 @@
/************* Array C++ Functions Source Code File (.CPP) *************/
/* Name: ARRAY.CPP Version 2.3 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */
/* This file contains the XOBJECT derived class ARRAY functions. */
/* ARRAY is used for elaborate type of processing, such as sorting */
@@ -19,14 +19,14 @@
#include "sql_class.h"
//#include "sql_time.h"
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h> // for uintprt_h
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include required application header files */
@@ -186,7 +186,7 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
// The error message was built by PlgDBalloc
Type = TYPE_ERROR;
else if (type != TYPE_PCHAR)
- Value = AllocateValue(g, type, Len, prec, NULL);
+ Value = AllocateValue(g, type, Len, prec);
Constant = TRUE;
} // end of ARRAY constructor
@@ -610,7 +610,7 @@ int ARRAY::Convert(PGLOBAL g, int k, PVAL vp)
// The error message was built by PlgDBalloc
return TYPE_ERROR;
else
- Value = AllocateValue(g, Type, Len, prec, NULL);
+ Value = AllocateValue(g, Type, Len, prec);
/*********************************************************************/
/* Converting STRING to DATE can be done according to date format. */
@@ -848,7 +848,7 @@ void *ARRAY::GetSortIndex(PGLOBAL g)
/* the indication of whether the Find will be always true, always not */
/* true or other. */
/***********************************************************************/
-int ARRAY::BlockTest(PGLOBAL g, int opc, int opm,
+int ARRAY::BlockTest(PGLOBAL, int opc, int opm,
void *minp, void *maxp, bool s)
{
bool bin, bax, pin, pax, veq, all = (opm == 2);
@@ -1038,7 +1038,7 @@ void ARRAY::Print(PGLOBAL g, FILE *f, uint n)
/***********************************************************************/
/* Make string output of ARRAY contents. */
/***********************************************************************/
-void ARRAY::Print(PGLOBAL g, char *ps, uint z)
+void ARRAY::Print(PGLOBAL, char *ps, uint z)
{
if (z < 16)
return;
diff --git a/storage/connect/blkfil.cpp b/storage/connect/blkfil.cpp
index 802231b24ec..1f5a1a27ae5 100644
--- a/storage/connect/blkfil.cpp
+++ b/storage/connect/blkfil.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -20,13 +20,13 @@
#include "sql_class.h"
//#include "sql_time.h"
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -56,7 +56,7 @@ BLOCKFILTER::BLOCKFILTER(PTDBDOS tdbp, int op)
/***********************************************************************/
/* Make file output of BLOCKFILTER contents. */
/***********************************************************************/
-void BLOCKFILTER::Print(PGLOBAL g, FILE *f, uint n)
+void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n)
{
char m[64];
@@ -70,7 +70,7 @@ void BLOCKFILTER::Print(PGLOBAL g, FILE *f, uint n)
/***********************************************************************/
/* Make string output of BLOCKFILTER contents. */
/***********************************************************************/
-void BLOCKFILTER::Print(PGLOBAL g, char *ps, uint z)
+void BLOCKFILTER::Print(PGLOBAL, char *ps, uint z)
{
strncat(ps, "BlockFilter(s)", z);
} // end of Print
@@ -186,7 +186,7 @@ void BLKFILARI::Reset(PGLOBAL g)
/***********************************************************************/
/* Evaluate block filter for arithmetic operators. */
/***********************************************************************/
-int BLKFILARI::BlockEval(PGLOBAL g)
+int BLKFILARI::BlockEval(PGLOBAL)
{
int mincmp, maxcmp, n;
@@ -306,7 +306,7 @@ void BLKFILAR2::MakeValueBitmap(void)
/***********************************************************************/
/* Evaluate XDB2 block filter for arithmetic operators. */
/***********************************************************************/
-int BLKFILAR2::BlockEval(PGLOBAL g)
+int BLKFILAR2::BlockEval(PGLOBAL)
{
#if defined(_DEBUG)
assert (Colp->IsClustered());
@@ -428,7 +428,7 @@ void BLKFILMR2::MakeValueBitmap(void)
/***********************************************************************/
/* Evaluate XDB2 block filter for arithmetic operators. */
/***********************************************************************/
-int BLKFILMR2::BlockEval(PGLOBAL g)
+int BLKFILMR2::BlockEval(PGLOBAL)
{
#if defined(_DEBUG)
assert (Colp->IsClustered());
@@ -514,7 +514,7 @@ void BLKSPCARI::Reset(PGLOBAL g)
/***********************************************************************/
/* Evaluate block filter for arithmetic operators (ROWID) */
/***********************************************************************/
-int BLKSPCARI::BlockEval(PGLOBAL g)
+int BLKSPCARI::BlockEval(PGLOBAL)
{
int mincmp, maxcmp, n, m;
@@ -605,7 +605,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
/***********************************************************************/
/* Reset: have the sorted array reset its Bot value to -1 (bottom). */
/***********************************************************************/
-void BLKFILIN::Reset(PGLOBAL g)
+void BLKFILIN::Reset(PGLOBAL)
{
Arap->Reset();
// MakeValueBitmap(); // Does nothing for class BLKFILIN
@@ -736,7 +736,7 @@ void BLKFILIN2::MakeValueBitmap(void)
/* ended string in case of string argument. This is because the ARRAY */
/* can have a different width than the char column. */
/***********************************************************************/
-int BLKFILIN2::BlockEval(PGLOBAL g)
+int BLKFILIN2::BlockEval(PGLOBAL)
{
if (N < 0)
return Result; // Was set in MakeValueBitmap
@@ -909,7 +909,7 @@ int BLKFILIN2::BlockEval(PGLOBAL g)
/***********************************************************************/
/* BLKSPCIN constructor. */
/***********************************************************************/
-BLKSPCIN::BLKSPCIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm,
+BLKSPCIN::BLKSPCIN(PGLOBAL, PTDBDOS tdbp, int op, int opm,
PXOB *xp, int bsize)
: BLOCKFILTER(tdbp, op)
{
@@ -930,7 +930,7 @@ BLKSPCIN::BLKSPCIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm,
/***********************************************************************/
/* Reset: have the sorted array reset its Bot value to -1 (bottom). */
/***********************************************************************/
-void BLKSPCIN::Reset(PGLOBAL g)
+void BLKSPCIN::Reset(PGLOBAL)
{
Arap->Reset();
} // end of Reset
diff --git a/storage/connect/block.h b/storage/connect/block.h
index d63a899d1f5..aa4edde5ec9 100644
--- a/storage/connect/block.h
+++ b/storage/connect/block.h
@@ -24,11 +24,11 @@
#if !defined(BLOCK_DEFINED)
#define BLOCK_DEFINED
-#if defined(WIN32) && !defined(NOEX)
+#if defined(__WIN__) && !defined(NOEX)
#define DllExport __declspec( dllexport )
-#else // !WIN32
+#else // !__WIN__
#define DllExport
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Definition of class BLOCK with its method function new. */
@@ -38,7 +38,7 @@ typedef class BLOCK *PBLOCK;
class DllExport BLOCK {
public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
-// if (trace > 2)
+// if (trace > 3)
// htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
return (PlugSubAlloc(g, p, size));
@@ -50,7 +50,7 @@ class DllExport BLOCK {
#if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, PGLOBAL, void *) {}
- void operator delete(void *ptr,size_t size) {}
+ void operator delete(void *, size_t) {}
#endif
virtual ~BLOCK() {}
diff --git a/storage/connect/catalog.h b/storage/connect/catalog.h
index 5baab294737..6488b513ba9 100644
--- a/storage/connect/catalog.h
+++ b/storage/connect/catalog.h
@@ -1,7 +1,7 @@
/*************** Catalog H Declares Source Code File (.H) **************/
/* Name: CATALOG.H Version 3.3 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2000-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2000-2015 */
/* */
/* This file contains the CATALOG PlugDB classes definitions. */
/***********************************************************************/
@@ -73,33 +73,29 @@ class DllExport CATALOG {
// Methods
virtual void Reset(void) {}
//virtual void SetDataPath(PGLOBAL g, const char *path) {}
- virtual bool CheckName(PGLOBAL g, char *name) {return true;}
- virtual bool ClearName(PGLOBAL g, PSZ name) {return true;}
- virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
- virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;}
- virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type,
- PRELDEF *prp = NULL) {return NULL;}
- virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;}
- virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;}
- virtual bool TestCond(PGLOBAL g, const char *name, const char *type)
- {return true;}
- virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;}
- virtual PTDB GetTable(PGLOBAL g, PTABLE tablep,
- MODE mode = MODE_READ, LPCSTR type = NULL)
- {return NULL;}
- virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {}
- virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer,
- int maxbuf, int info[]) {}
- virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer,
- int maxbuf, int info[]) {}
- virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname,
- char *buffer, int maxbuf, int info[]) {return NULL;}
- virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;}
- virtual void ClearDB(PGLOBAL g) {}
+ virtual bool CheckName(PGLOBAL, char*) {return true;}
+ virtual bool ClearName(PGLOBAL, PSZ) {return true;}
+ virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}
+ virtual PRELDEF GetTableDescEx(PGLOBAL, PTABLE) {return NULL;}
+ virtual PRELDEF GetTableDesc(PGLOBAL, LPCSTR, LPCSTR,
+ PRELDEF* = NULL) {return NULL;}
+ virtual PRELDEF GetFirstTable(PGLOBAL) {return NULL;}
+ virtual PRELDEF GetNextTable(PGLOBAL) {return NULL;}
+ virtual bool TestCond(PGLOBAL, const char*, const char*) {return true;}
+ virtual bool DropTable(PGLOBAL, PSZ, bool) {return true;}
+ virtual PTDB GetTable(PGLOBAL, PTABLE,
+ MODE = MODE_READ, LPCSTR = NULL) {return NULL;}
+ virtual void TableNames(PGLOBAL, char*, int, int[]) {}
+ virtual void ColumnNames(PGLOBAL, char*, char*, int, int[]) {}
+ virtual void ColumnDefs(PGLOBAL, char*, char*, int, int[]) {}
+ virtual void *DecodeValues(PGLOBAL, char*, char*, char*,
+ int, int[]) {return NULL;}
+ virtual int ColumnType(PGLOBAL, char*, char*) {return 0;}
+ virtual void ClearDB(PGLOBAL) {}
protected:
- virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;}
- virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
+ virtual bool ClearSection(PGLOBAL, const char*, const char*) {return true;}
+ virtual PRELDEF MakeTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}
// Members
char *Cbuf; /* Buffer used for col section */
diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp
index f5bd32db738..80b405be041 100644
--- a/storage/connect/colblk.cpp
+++ b/storage/connect/colblk.cpp
@@ -1,7 +1,7 @@
/************* Colblk C++ Functions Source Code File (.CPP) ************/
/* Name: COLBLK.CPP Version 2.1 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */
/* This file contains the COLBLK class functions. */
/***********************************************************************/
@@ -111,7 +111,7 @@ bool COLBLK::Compare(PXOB xp)
/***********************************************************************/
/* SetFormat: function used to set SELECT output format. */
/***********************************************************************/
-bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
+bool COLBLK::SetFormat(PGLOBAL, FORMAT& fmt)
{
fmt = Format;
@@ -175,7 +175,7 @@ bool COLBLK::InitValue(PGLOBAL g)
/***********************************************************************/
/* SetBuffer: prepare a column block for write operation. */
/***********************************************************************/
-bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
+bool COLBLK::SetBuffer(PGLOBAL g, PVAL, bool, bool)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer");
return true;
@@ -214,7 +214,7 @@ void COLBLK::WriteColumn(PGLOBAL g)
/***********************************************************************/
/* Make file output of a column descriptor block. */
/***********************************************************************/
-void COLBLK::Print(PGLOBAL g, FILE *f, uint n)
+void COLBLK::Print(PGLOBAL, FILE *f, uint n)
{
char m[64];
int i;
@@ -237,7 +237,7 @@ void COLBLK::Print(PGLOBAL g, FILE *f, uint n)
/***********************************************************************/
/* Make string output of a column descriptor block. */
/***********************************************************************/
-void COLBLK::Print(PGLOBAL g, char *ps, uint z)
+void COLBLK::Print(PGLOBAL, char *ps, uint)
{
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
} // end of Print
@@ -297,9 +297,9 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op)
Buf_Type = TYPE_STRING;
*Format.Type = 'C';
Format.Length = Long;
-#if defined(WIN32)
+#if defined(__WIN__)
Format.Prec = 1; // Case insensitive
-#endif // WIN32
+#endif // __WIN__
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() &&
To_Tdb->GetAmType() != TYPE_AM_PLG &&
To_Tdb->GetAmType() != TYPE_AM_PLM);
@@ -347,7 +347,7 @@ TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp)
/***********************************************************************/
/* ReadColumn: what this routine does is to return the table ID. */
/***********************************************************************/
-void TIDBLK::ReadColumn(PGLOBAL g)
+void TIDBLK::ReadColumn(PGLOBAL)
{
if (Tname == NULL) {
Tname = (char*)To_Tdb->GetName();
@@ -406,7 +406,7 @@ SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp)
/***********************************************************************/
/* ReadColumn: what this routine does is to return the server ID. */
/***********************************************************************/
-void SIDBLK::ReadColumn(PGLOBAL g)
+void SIDBLK::ReadColumn(PGLOBAL)
{
//if (Sname == NULL) {
Sname = (char*)To_Tdb->GetServer();
diff --git a/storage/connect/colblk.h b/storage/connect/colblk.h
index 5e8dc77ff69..c64f9d95129 100644
--- a/storage/connect/colblk.h
+++ b/storage/connect/colblk.h
@@ -1,7 +1,7 @@
/*************** Colblk H Declares Source Code File (.H) ***************/
/* Name: COLBLK.H Version 1.7 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */
/* This file contains the COLBLK and derived classes declares. */
/***********************************************************************/
@@ -23,7 +23,7 @@ class DllExport COLBLK : public XOBJECT {
// Default constructors used by derived classes
COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0);
COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process
- COLBLK(int n) {} // Used when changing a column class in TDBXML
+ COLBLK(int) {} // Used when changing a column class in TDBXML
public:
// Implementation
@@ -69,7 +69,7 @@ class DllExport COLBLK : public XOBJECT {
virtual bool IsSpecial(void) {return false;}
virtual bool Eval(PGLOBAL g);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
- virtual void SetTo_Val(PVAL valp) {}
+ virtual void SetTo_Val(PVAL) {}
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint);
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc
index 7c32c65226d..4e554b16638 100644
--- a/storage/connect/connect.cc
+++ b/storage/connect/connect.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) Olivier Bertrand 2004 - 2012
+/* Copyright (C) Olivier Bertrand 2004 - 2015
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/***********************************************************************/
-/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2012 */
+/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -237,7 +237,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
/* OPENTAB: Open a Table. */
/***********************************************************************/
bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
- bool del, PHC h)
+ bool del, PHC)
{
char *p;
int i, n, rc;
@@ -709,6 +709,28 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
return (tdbp->To_Kindex->IsMul()) ? 2 : 1;
} // end of CntIndexInit
+#if defined(WORDS_BIGENDIAN)
+/***********************************************************************/
+/* Swap bytes of the key that are written in little endian order. */
+/***********************************************************************/
+static void SetSwapValue(PVAL valp, char *kp)
+{
+ if (valp->IsTypeNum() && valp->GetType() != TYPE_DECIM) {
+ uchar buf[8];
+ int i, k= valp->GetClen();
+
+ for (i = 0; k > 0;)
+ buf[i++]= kp[--k];
+
+
+
+ valp->SetBinValue((void*)buf);
+ } else
+ valp->SetBinValue((void*)kp);
+
+} // end of SetSwapValue
+#endif // WORDS_BIGENDIAN
+
/***********************************************************************/
/* IndexRead: fetch a record having the index value. */
/***********************************************************************/
@@ -779,7 +801,12 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
if (!valp->IsTypeNum()) {
if (colp->GetColUse(U_VAR)) {
+#if defined(WORDS_BIGENDIAN)
+ ((char*)&lg)[0]= ((char*)kp)[1];
+ ((char*)&lg)[1]= ((char*)kp)[0];
+#else // !WORDS_BIGENDIAN
lg= *(short*)kp;
+#endif //!WORDS_BIGENDIAN
kp+= sizeof(short);
rcb= valp->SetValue_char(kp, (int)lg);
} else
@@ -797,7 +824,11 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
} // endif b
} else
+#if defined(WORDS_BIGENDIAN)
+ SetSwapValue(valp, kp);
+#else // !WORDS_BIGENDIAN
valp->SetBinValue((void*)kp);
+#endif //!WORDS_BIGENDIAN
kp+= valp->GetClen();
@@ -893,7 +924,12 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
if (!valp->IsTypeNum()) {
if (colp->GetColUse(U_VAR)) {
+#if defined(WORDS_BIGENDIAN)
+ ((char*)&lg)[0]= ((char*)p)[1];
+ ((char*)&lg)[1]= ((char*)p)[0];
+#else // !WORDS_BIGENDIAN
lg= *(short*)p;
+#endif //!WORDS_BIGENDIAN
p+= sizeof(short);
rcb= valp->SetValue_char((char*)p, (int)lg);
} else
@@ -912,7 +948,11 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
} // endif b
} else
+#if defined(WORDS_BIGENDIAN)
+ SetSwapValue(valp, (char*)p);
+#else // !WORDS_BIGENDIAN
valp->SetBinValue((void*)p);
+#endif // !WORDS_BIGENDIAN
if (trace) {
char bf[32];
diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp
index 9e518775c0f..64a0a172956 100644
--- a/storage/connect/domdoc.cpp
+++ b/storage/connect/domdoc.cpp
@@ -4,7 +4,7 @@
/******************************************************************/
#include "my_global.h"
#include <stdio.h>
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
#if defined(MSX2)
#import "msxml2.dll" //Does not exist on Vista
diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp
index 1e65fa2a413..5cf9a4d945c 100644
--- a/storage/connect/filamap.cpp
+++ b/storage/connect/filamap.cpp
@@ -17,12 +17,12 @@
/* Include relevant sections of the System header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <errno.h>
#include <unistd.h>
@@ -30,7 +30,7 @@
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -191,11 +191,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
return true;
} // endif Memory
-#if defined(WIN32)
+#if defined(__WIN__)
if (mode != MODE_DELETE) {
-#else // !WIN32
+#else // !__WIN__
if (mode == MODE_READ) {
-#endif // !WIN32
+#endif // !__WIN__
CloseFileHandle(hFile); // Not used anymore
hFile = INVALID_HANDLE_VALUE; // For Fblock
} // endif Mode
@@ -276,7 +276,7 @@ bool MAPFAM::SetPos(PGLOBAL g, int pos)
/***********************************************************************/
/* Record file position in case of UPDATE or DELETE. */
/***********************************************************************/
-bool MAPFAM::RecordPos(PGLOBAL g)
+bool MAPFAM::RecordPos(PGLOBAL)
{
Fpos = Mempos;
return false;
@@ -285,7 +285,7 @@ bool MAPFAM::RecordPos(PGLOBAL g)
/***********************************************************************/
/* Initialize Fpos and Mempos for indexed DELETE. */
/***********************************************************************/
-int MAPFAM::InitDelete(PGLOBAL g, int fpos, int spos)
+int MAPFAM::InitDelete(PGLOBAL, int fpos, int spos)
{
Fpos = Memory + (ptrdiff_t)fpos;
Mempos = Memory + (ptrdiff_t)spos;
@@ -371,7 +371,7 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
/***********************************************************************/
/* WriteBuffer: File write routine for MAP access method. */
/***********************************************************************/
-int MAPFAM::WriteBuffer(PGLOBAL g)
+int MAPFAM::WriteBuffer(PGLOBAL g __attribute__((unused)))
{
#if defined(_DEBUG)
// Insert mode is no more handled using file mapping
@@ -452,7 +452,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/
n = Tpos - Memory;
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) {
@@ -482,7 +482,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
#endif // UNIX
} // endif Abort
-#if defined(WIN32)
+#if defined(__WIN__)
CloseHandle(fp->Handle);
#else // UNIX
close(fp->Handle);
@@ -495,7 +495,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
/* Table file close routine for MAP access method. */
/***********************************************************************/
-void MAPFAM::CloseTableFile(PGLOBAL g, bool abort)
+void MAPFAM::CloseTableFile(PGLOBAL g, bool)
{
PlugCloseFile(g, To_Fb);
To_Fb = NULL; // To get correct file size in Cardinality
@@ -551,7 +551,7 @@ int MBKFAM::Cardinality(PGLOBAL g)
/***********************************************************************/
/* Skip one record in file. */
/***********************************************************************/
-int MBKFAM::SkipRecord(PGLOBAL g, bool header)
+int MBKFAM::SkipRecord(PGLOBAL, bool)
{
return RC_OK;
} // end of SkipRecord
@@ -685,7 +685,7 @@ bool MPXFAM::SetPos(PGLOBAL g, int pos)
/***********************************************************************/
/* Initialize CurBlk, CurNum, Mempos and Fpos for indexed DELETE. */
/***********************************************************************/
-int MPXFAM::InitDelete(PGLOBAL g, int fpos, int spos)
+int MPXFAM::InitDelete(PGLOBAL, int fpos, int)
{
Fpos = Memory + Headlen + (ptrdiff_t)fpos * Lrecl;
Mempos = Fpos + Lrecl;
@@ -740,7 +740,7 @@ int MPXFAM::ReadBuffer(PGLOBAL g)
/***********************************************************************/
/* WriteBuffer: File write routine for MAP access method. */
/***********************************************************************/
-int MPXFAM::WriteBuffer(PGLOBAL g)
+int MPXFAM::WriteBuffer(PGLOBAL g __attribute__((unused)))
{
#if defined(_DEBUG)
// Insert mode is no more handled using file mapping
diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp
index f1fc466a5fc..8afda723578 100644
--- a/storage/connect/filamdbf.cpp
+++ b/storage/connect/filamdbf.cpp
@@ -1,11 +1,11 @@
/*********** File AM Dbf C++ Program Source Code File (.CPP) ****************/
/* PROGRAM NAME: FILAMDBF */
/* ------------- */
-/* Version 1.7 */
+/* Version 1.8 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -22,12 +22,12 @@
/* Include relevant sections of the System header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
//#include <errno.h>
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <errno.h>
#include <unistd.h>
@@ -35,7 +35,7 @@
//#include <io.h>
#endif // !UNIX
//#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
#include <ctype.h>
#include <stdio.h>
#include <string.h>
@@ -74,28 +74,28 @@ typedef struct _dbfheader {
//uchar Dbfox :4; /* FoxPro if equal to 3 */
uchar Version; /* Version information flags */
char Filedate[3]; /* date, YYMMDD, binary. YY=year-1900 */
-private:
+ private:
/* The following four members are stored in little-endian format on disk */
char m_RecordsBuf[4]; /* records in the file */
char m_HeadlenBuf[2]; /* bytes in the header */
char m_ReclenBuf[2]; /* bytes in a record */
char m_FieldsBuf[2]; /* Reserved but used to store fields */
-public:
+ public:
char Incompleteflag; /* 01 if incomplete, else 00 */
char Encryptflag; /* 01 if encrypted, else 00 */
char Reserved2[12]; /* for LAN use */
char Mdxflag; /* 01 if production .mdx, else 00 */
char Language; /* Codepage */
char Reserved3[2];
-
- uint Records() const { return uint4korr(m_RecordsBuf); }
- ushort Headlen() const { return uint2korr(m_HeadlenBuf); }
- ushort Reclen() const { return uint2korr(m_ReclenBuf); }
- ushort Fields() const { return uint2korr(m_FieldsBuf); }
-
- void SetHeadlen(ushort num) { int2store(m_HeadlenBuf, num); }
- void SetReclen(ushort num) { int2store(m_ReclenBuf, num); }
- void SetFields(ushort num) { int2store(m_FieldsBuf, num); }
+
+ uint Records(void) const {return uint4korr(m_RecordsBuf);}
+ ushort Headlen(void) const {return uint2korr(m_HeadlenBuf);}
+ ushort Reclen(void) const {return uint2korr(m_ReclenBuf);}
+ ushort Fields(void) const {return uint2korr(m_FieldsBuf);}
+
+ void SetHeadlen(ushort num) {int2store(m_HeadlenBuf, num);}
+ void SetReclen(ushort num) {int2store(m_ReclenBuf, num);}
+ void SetFields(ushort num) {int2store(m_FieldsBuf, num);}
} DBFHEADER;
/****************************************************************************/
@@ -410,13 +410,13 @@ int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath)
} else if (rc == RC_FX)
return -1;
- if ((int) header.Reclen() != lrecl) {
+ if ((int)header.Reclen() != lrecl) {
sprintf(g->Message, MSG(BAD_LRECL), lrecl, header.Reclen());
return -1;
} // endif Lrecl
- Records = (int) header.Records();
- return (int) header.Headlen();
+ Records = (int)header.Records();
+ return (int)header.Headlen();
} // end of ScanHeader
/* ---------------------------- Class DBFFAM ------------------------------ */
@@ -528,7 +528,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
if (mode == MODE_INSERT) {
-#if defined(WIN32)
+#if defined(__WIN__)
/************************************************************************/
/* Now we can revert to binary mode in particular because the eventual */
/* writing of a new header must be done in binary mode to avoid */
@@ -538,7 +538,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno));
return true;
} // endif setmode
-#endif // WIN32
+#endif // __WIN__
/************************************************************************/
/* If this is a new file, the header must be generated. */
@@ -577,8 +577,8 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
header->Filedate[0] = datm->tm_year - 100;
header->Filedate[1] = datm->tm_mon + 1;
header->Filedate[2] = datm->tm_mday;
- header->SetHeadlen((ushort) hlen);
- header->SetReclen((ushort) reclen);
+ header->SetHeadlen((ushort)hlen);
+ header->SetReclen((ushort)reclen);
descp = (DESCRIPTOR*)header;
// Currently only standard Xbase types are supported
@@ -639,13 +639,13 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
DBFHEADER header;
if ((rc = dbfhead(g, Stream, Tdbp->GetFile(g), &header)) == RC_OK) {
- if (Lrecl != (int) header.Reclen()) {
+ if (Lrecl != (int)header.Reclen()) {
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, header.Reclen());
return true;
} // endif Lrecl
- Records = (int) header.Records();
- Headlen = (int) header.Headlen();
+ Records = (int)header.Records();
+ Headlen = (int)header.Headlen();
} else if (rc == RC_NF) {
Records = 0;
Headlen = 0;
@@ -881,9 +881,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
if ((Stream= global_fopen(g, MSGID_OPEN_MODE_STRERROR, filename, "r+b")))
{
char nRecords[4];
- int4store(&nRecords, n);
+ int4store(nRecords, n);
+
fseek(Stream, 4, SEEK_SET); // Get header.Records position
- fwrite(&nRecords, sizeof(nRecords), 1, Stream);
+ fwrite(nRecords, sizeof(nRecords), 1, Stream);
fclose(Stream);
Stream= NULL;
Records= n; // Update Records value
@@ -958,13 +959,13 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
/************************************************************************/
DBFHEADER *hp = (DBFHEADER*)Memory;
- if (Lrecl != (int) hp->Reclen()) {
+ if (Lrecl != (int)hp->Reclen()) {
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, hp->Reclen());
return true;
} // endif Lrecl
- Records = (int) hp->Records();
- Headlen = (int) hp->Headlen();
+ Records = (int)hp->Records();
+ Headlen = (int)hp->Headlen();
} // endif Headlen
/**************************************************************************/
diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp
index 980d558eee5..cd25429318a 100644
--- a/storage/connect/filamfix.cpp
+++ b/storage/connect/filamfix.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -17,7 +17,7 @@
/* Include relevant sections of the System header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#include <errno.h>
@@ -25,7 +25,7 @@
#define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <errno.h>
#include <unistd.h>
@@ -34,7 +34,7 @@
#endif // !UNIX
#include <sys/stat.h>
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -46,6 +46,7 @@
#include "plgdbsem.h"
#include "filamfix.h"
#include "tabdos.h"
+#include "tabfix.h"
#include "osutil.h"
#ifndef INVALID_SET_FILE_POINTER
@@ -102,7 +103,7 @@ bool FIXFAM::SetPos(PGLOBAL g, int pos)
/***********************************************************************/
/* Initialize CurBlk and CurNum for indexed DELETE. */
/***********************************************************************/
-int FIXFAM::InitDelete(PGLOBAL g, int fpos, int spos)
+int FIXFAM::InitDelete(PGLOBAL, int fpos, int)
{
CurBlk = fpos / Nrec;
CurNum = fpos % Nrec;
@@ -133,18 +134,35 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g)
if (Tdbp->GetFtype() == RECFM_BIN) {
// The buffer must be prepared depending on column types
int n = 0;
+ bool b = false;
PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
- PCOLDEF cdp;
+// PCOLDEF cdp;
+ PBINCOL colp;
// Prepare the first line of the buffer
memset(To_Buf, 0, Buflen);
+#if 0
for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) {
- if (IsTypeNum(cdp->GetType()))
- memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen());
+ if (!IsTypeNum(cdp->GetType())) {
+ memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen());
+ b = true;
+ } // endif not num
- n = MY_MAX(n, cdp->GetPoff() + cdp->GetClen());
+ n = MY_MAX(n, cdp->GetOffset() + cdp->GetClen());
} // endfor cdp
+#endif // 0
+
+ for (colp = (PBINCOL)Tdbp->GetColumns(); colp;
+ colp = (PBINCOL)colp->GetNext())
+ if (!colp->IsSpecial()) {
+ if (!IsTypeNum(colp->GetResultType())) {
+ memset(To_Buf + colp->GetDeplac(), ' ', colp->GetLength());
+ b = true;
+ } // endif not num
+
+ n = MY_MAX(n, colp->GetDeplac() + colp->GetFileSize());
+ } // endif !special
// We do this for binary table because the lrecl can have been
// specified with additional space to include line ending.
@@ -156,9 +174,10 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g)
} // endif n
- // Now repeat this for the whole buffer
- for (int len = Lrecl; len <= Buflen - Lrecl; len += Lrecl)
- memcpy(To_Buf + len, To_Buf, Lrecl);
+ if (b)
+ // Now repeat this for the whole buffer
+ for (int len = Lrecl; len <= Buflen - Lrecl; len += Lrecl)
+ memcpy(To_Buf + len, To_Buf, Lrecl);
} else {
memset(To_Buf, ' ', Buflen);
@@ -319,10 +338,10 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
} else if (feof(Stream)) {
rc = RC_EF;
} else {
-#if defined(UNIX)
- sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
-#else
+#if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
+#else
+ sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#endif
if (trace)
@@ -659,7 +678,7 @@ BGXFAM::BGXFAM(PBGXFAM txfp) : FIXFAM(txfp)
/***********************************************************************/
bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
{
-#if defined(WIN32)
+#if defined(__WIN__)
char buf[256];
DWORD drc;
LARGE_INTEGER of;
@@ -675,14 +694,14 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
sprintf(g->Message, MSG(SFP_ERROR), buf);
return true;
} // endif
-#else // !WIN32
+#else // !__WIN__
if (lseek64(h, pos, org) < 0) {
// sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
sprintf(g->Message, "lseek64: %s", strerror(errno));
printf("%s\n", g->Message);
return true;
} // endif
-#endif // !WIN32
+#endif // !__WIN__
return false;
} // end of BigSeek
@@ -690,11 +709,12 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
/***********************************************************************/
/* Read from a big file. */
/***********************************************************************/
-int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
+int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)),
+ HANDLE h, void *inbuf, int req)
{
int rc;
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD nbr, drc, len = (DWORD)req;
bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
@@ -716,12 +736,12 @@ int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = -1;
} else
rc = (int)nbr;
-#else // !WIN32
+#else // !__WIN__
size_t len = (size_t)req;
ssize_t nbr = read(h, inbuf, len);
rc = (int)nbr;
-#endif // !WIN32
+#endif // !__WIN__
return rc;
} // end of BigRead
@@ -733,7 +753,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
{
bool rc = false;
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD nbw, drc, len = (DWORD)req;
bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
@@ -760,7 +780,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true;
} // endif brc || nbw
-#else // !WIN32
+#else // !__WIN__
size_t len = (size_t)req;
ssize_t nbw = write(h, inbuf, len);
@@ -775,7 +795,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true;
} // endif nbr
-#endif // !WIN32
+#endif // !__WIN__
return rc;
} // end of BigWrite
@@ -810,7 +830,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
if (trace)
htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD rc, access, creation, share = 0;
/*********************************************************************/
@@ -967,7 +987,7 @@ int BGXFAM::Cardinality(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath());
-#if defined(WIN32) // OB
+#if defined(__WIN__) // OB
LARGE_INTEGER len;
DWORD rc = 0;
@@ -1326,7 +1346,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/
/* Remove extra records. */
/*****************************************************************/
-#if defined(WIN32)
+#if defined(__WIN__)
if (BigSeek(g, Hfile, (BIGINT)Tpos * (BIGINT)Lrecl))
return RC_FX;
@@ -1336,12 +1356,12 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
sprintf(g->Message, MSG(SETEOF_ERROR), drc);
return RC_FX;
} // endif error
-#else // !WIN32
+#else // !__WIN__
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
return RC_FX;
} // endif
-#endif // !WIN32
+#endif // !__WIN__
} // endif UseTemp
@@ -1366,7 +1386,7 @@ bool BGXFAM::OpenTempFile(PGLOBAL g)
strcat(PlugRemoveType(tempname, tempname), ".t");
remove(tempname); // Be sure it does not exist yet
-#if defined(WIN32)
+#if defined(__WIN__)
Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -1506,7 +1526,7 @@ void BGXFAM::CloseTableFile(PGLOBAL g, bool abort)
void BGXFAM::Rewind(void)
{
#if 0 // This is probably unuseful because file is accessed directly
-#if defined(WIN32) //OB
+#if defined(__WIN__) //OB
SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
#else // UNIX
lseek64(Hfile, 0, SEEK_SET);
diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp
index eb4e026ee8a..e53cdcd9ba9 100644
--- a/storage/connect/filamtxt.cpp
+++ b/storage/connect/filamtxt.cpp
@@ -17,7 +17,7 @@
/* Include relevant sections of the System header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#include <errno.h>
@@ -25,7 +25,7 @@
#define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX) || defined(UNIV_LINUX)
#include <errno.h>
#include <unistd.h>
@@ -36,7 +36,7 @@
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -436,7 +436,7 @@ err:
/* The purpose of this function is to deal with access methods that */
/* are not coherent regarding the use of SetPos and GetPos. */
/***********************************************************************/
-int TXTFAM::InitDelete(PGLOBAL g, int fpos, int spos)
+int TXTFAM::InitDelete(PGLOBAL g, int, int)
{
strcpy(g->Message, "InitDelete should not be used by this table type");
return RC_FX;
@@ -519,7 +519,7 @@ int DOSFAM::Cardinality(PGLOBAL g)
/* Use BlockTest to reduce the table estimated size. */
/* Note: This function is not really implemented yet. */
/***********************************************************************/
-int DOSFAM::MaxBlkSize(PGLOBAL g, int s)
+int DOSFAM::MaxBlkSize(PGLOBAL, int s)
{
return s;
} // end of MaxBlkSize
@@ -716,10 +716,10 @@ int DOSFAM::SkipRecord(PGLOBAL g, bool header)
if (feof(Stream))
return RC_EF;
-#if defined(UNIX) || defined(UNIV_LINUX)
- sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
-#else
+#if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
+#else
+ sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
#endif
return RC_FX;
} // endif fgets
@@ -799,12 +799,12 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
if (trace > 1)
htrc(" Read: To_Buf=%p p=%c\n", To_Buf, To_Buf, p);
-#if defined(UNIX)
- if (true) {
- // Data files can be imported from Windows (having CRLF)
-#else
+#if defined(__WIN__)
if (Bin) {
// Data file is read in binary so CRLF remains
+#else
+ if (true) {
+ // Data files can be imported from Windows (having CRLF)
#endif
if (*p == '\n' || *p == '\r') {
// is this enough for Unix ???
@@ -833,10 +833,10 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
} else if (feof(Stream)) {
rc = RC_EF;
} else {
-#if defined(UNIX)
- sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
-#else
+#if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
+#else
+ sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
#endif
if (trace)
@@ -1028,15 +1028,15 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/
/* Remove extra records. */
/*****************************************************************/
-#if defined(UNIX)
- if (ftruncate(h, (off_t)Tpos)) {
- sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
+#if defined(__WIN__)
+ if (chsize(h, Tpos)) {
+ sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
close(h);
return RC_FX;
} // endif
#else
- if (chsize(h, Tpos)) {
- sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
+ if (ftruncate(h, (off_t)Tpos)) {
+ sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
close(h);
return RC_FX;
} // endif
@@ -1272,7 +1272,7 @@ int BLKFAM::Cardinality(PGLOBAL g)
/***********************************************************************/
/* Use BlockTest to reduce the table estimated size. */
/***********************************************************************/
-int BLKFAM::MaxBlkSize(PGLOBAL g, int s)
+int BLKFAM::MaxBlkSize(PGLOBAL g, int)
{
int rc = RC_OK, savcur = CurBlk;
int size;
@@ -1343,7 +1343,7 @@ int BLKFAM::GetNextPos(void)
/***********************************************************************/
/* SetPos: Replace the table at the specified position. */
/***********************************************************************/
-bool BLKFAM::SetPos(PGLOBAL g, int pos)
+bool BLKFAM::SetPos(PGLOBAL g, int)
{
strcpy(g->Message, "Blocked variable tables cannot be used indexed");
return true;
@@ -1353,7 +1353,7 @@ bool BLKFAM::SetPos(PGLOBAL g, int pos)
/* Record file position in case of UPDATE or DELETE. */
/* Not used yet for blocked tables. */
/***********************************************************************/
-bool BLKFAM::RecordPos(PGLOBAL g)
+bool BLKFAM::RecordPos(PGLOBAL)
{
Fpos = (CurNum + Nrec * CurBlk); // Computed file index
return false;
@@ -1362,7 +1362,7 @@ bool BLKFAM::RecordPos(PGLOBAL g)
/***********************************************************************/
/* Skip one record in file. */
/***********************************************************************/
-int BLKFAM::SkipRecord(PGLOBAL g, bool header)
+int BLKFAM::SkipRecord(PGLOBAL, bool header)
{
if (header) {
// For Delete
@@ -1466,10 +1466,10 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
} else if (feof(Stream)) {
rc = RC_EF;
} else {
-#if defined(UNIX)
- sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
-#else
+#if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
+#else
+ sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#endif
if (trace)
@@ -1551,11 +1551,11 @@ int BLKFAM::WriteBuffer(PGLOBAL g)
Spos = GetNextPos(); // New start position
// Prepare the output buffer
-#if defined(WIN32)
+#if defined(__WIN__)
crlf = "\r\n";
#else
crlf = "\n";
-#endif // WIN32
+#endif // __WIN__
strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf);
len = strlen(OutBuf);
} else {
diff --git a/storage/connect/filamtxt.h b/storage/connect/filamtxt.h
index 1c8ea1e3a6c..ae8f74a9830 100644
--- a/storage/connect/filamtxt.h
+++ b/storage/connect/filamtxt.h
@@ -57,8 +57,8 @@ class DllExport TXTFAM : public BLOCK {
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
- virtual bool AllocateBuffer(PGLOBAL g) {return false;}
- virtual void ResetBuffer(PGLOBAL g) {}
+ virtual bool AllocateBuffer(PGLOBAL) {return false;}
+ virtual void ResetBuffer(PGLOBAL) {}
virtual int GetNerr(void) {return 0;}
virtual int GetRowID(void) = 0;
virtual bool RecordPos(PGLOBAL g) = 0;
diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp
index e1f11bbf4cf..fdc5433f4a4 100755
--- a/storage/connect/filamvct.cpp
+++ b/storage/connect/filamvct.cpp
@@ -21,7 +21,7 @@
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#if defined(__BORLANDC__)
@@ -29,7 +29,7 @@
#endif // __BORLAND__
//#include <windows.h>
#include <sys/stat.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <sys/types.h>
#include <sys/stat.h>
@@ -40,7 +40,7 @@
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -49,7 +49,7 @@
/* tabdos.h is header containing the TABDOS class declarations. */
/***********************************************************************/
#include "global.h"
-#include "osutil.h" // Unuseful for WIN32
+#include "osutil.h" // Unuseful for WINDOWS
#include "plgdbsem.h"
#include "valblk.h"
#include "filamfix.h"
@@ -279,7 +279,7 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g)
/***********************************************************************/
/* Use BlockTest to reduce the table estimated size. */
/***********************************************************************/
-int VCTFAM::MaxBlkSize(PGLOBAL g, int s)
+int VCTFAM::MaxBlkSize(PGLOBAL g, int)
{
int rc = RC_OK, savcur = CurBlk;
int size;
@@ -376,11 +376,11 @@ bool VCTFAM::MakeEmptyFile(PGLOBAL g, char *fn)
int h, n;
PlugSetPath(filename, fn, Tdbp->GetPath());
-#if defined(WIN32)
+#if defined(__WIN__)
h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE);
-#else // !WIN32
+#else // !__WIN__
h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE);
-#endif // !WIN32
+#endif // !__WIN__
if (h == -1)
return true;
@@ -1669,7 +1669,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
// Remove extra blocks
n = Block * Blksize;
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) {
@@ -1716,7 +1716,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
/* Move intermediate deleted or updated lines. */
/***********************************************************************/
-bool VCMFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
+bool VCMFAM::MoveIntermediateLines(PGLOBAL, bool *)
{
int i, m, n;
@@ -1765,7 +1765,7 @@ bool VCMFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
/***********************************************************************/
/* Data Base close routine for VMP access method. */
/***********************************************************************/
-void VCMFAM::CloseTableFile(PGLOBAL g, bool abort)
+void VCMFAM::CloseTableFile(PGLOBAL g, bool)
{
int wrc = RC_OK;
MODE mode = Tdbp->GetMode();
@@ -1800,7 +1800,7 @@ void VCMFAM::CloseTableFile(PGLOBAL g, bool abort)
/***********************************************************************/
/* ReadBlock: Read column values from current block. */
/***********************************************************************/
-bool VCMFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
+bool VCMFAM::ReadBlock(PGLOBAL, PVCTCOL colp)
{
char *mempos;
int i = colp->Index - 1;
@@ -1830,7 +1830,7 @@ bool VCMFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
/* the mapped file, except when checking for Update but in this case */
/* we do not want to write back the modifications either. */
/***********************************************************************/
-bool VCMFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
+bool VCMFAM::WriteBlock(PGLOBAL, PVCTCOL colp __attribute__((unused)))
{
#if defined(_DEBUG)
char *mempos;
@@ -2124,7 +2124,7 @@ bool VECFAM::AllocateBuffer(PGLOBAL g)
/***********************************************************************/
/* Do initial action when inserting. */
/***********************************************************************/
-bool VECFAM::InitInsert(PGLOBAL g)
+bool VECFAM::InitInsert(PGLOBAL)
{
// We come here in MODE_INSERT only
CurBlk = 0;
@@ -2365,7 +2365,7 @@ bool VECFAM::MoveLines(PGLOBAL g)
/***********************************************************************/
/* Move intermediate deleted or updated lines. */
/***********************************************************************/
-bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *bn)
+bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *)
{
int i, n;
bool b = false;
@@ -2574,11 +2574,11 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
char fn[_MAX_PATH];
sprintf(fn, Colfn, colp->Index);
-#if defined(WIN32)
+#if defined(__WIN__)
if (feof(Streams[i]))
-#else // !WIN32
+#else // !__WIN__
if (errno == NO_ERROR)
-#endif // !WIN32
+#endif // !__WIN__
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn);
else
sprintf(g->Message, MSG(READ_ERROR),
@@ -2969,7 +2969,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/
n = Tpos * Clens[i];
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) {
@@ -3009,7 +3009,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
/* Data Base close routine for VMP access method. */
/***********************************************************************/
-void VMPFAM::CloseTableFile(PGLOBAL g, bool abort)
+void VMPFAM::CloseTableFile(PGLOBAL g, bool)
{
if (Tdbp->GetMode() == MODE_DELETE) {
// Set Block and Nrec values for TDBVCT::MakeBlockValues
@@ -3049,7 +3049,7 @@ BGVFAM::BGVFAM(PBGVFAM txfp) : VCTFAM(txfp)
/***********************************************************************/
bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
{
-#if defined(WIN32)
+#if defined(__WIN__)
char buf[256];
DWORD drc, m = (b) ? FILE_END : FILE_BEGIN;
LARGE_INTEGER of;
@@ -3065,12 +3065,12 @@ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
sprintf(g->Message, MSG(SFP_ERROR), buf);
return true;
} // endif
-#else // !WIN32
+#else // !__WIN__
if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) {
sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
return true;
} // endif
-#endif // !WIN32
+#endif // !__WIN__
return false;
} // end of BigSeek
@@ -3082,7 +3082,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
{
bool rc = false;
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD nbr, drc, len = (DWORD)req;
bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
@@ -3108,7 +3108,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true;
} // endif brc || nbr
-#else // !WIN32
+#else // !__WIN__
size_t len = (size_t)req;
ssize_t nbr = read(h, inbuf, len);
@@ -3123,7 +3123,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true;
} // endif nbr
-#endif // !WIN32
+#endif // !__WIN__
return rc;
} // end of BigRead
@@ -3135,7 +3135,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
{
bool rc = false;
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD nbw, drc, len = (DWORD)req;
bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
@@ -3162,7 +3162,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true;
} // endif brc || nbw
-#else // !WIN32
+#else // !__WIN__
size_t len = (size_t)req;
ssize_t nbw = write(h, inbuf, len);
@@ -3177,7 +3177,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true;
} // endif nbr
-#endif // !WIN32
+#endif // !__WIN__
return rc;
} // end of BigWrite
@@ -3203,7 +3203,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
if (Header == 2)
strcat(PlugRemoveType(filename, filename), ".blk");
-#if defined(WIN32)
+#if defined(__WIN__)
LARGE_INTEGER len;
h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
@@ -3215,11 +3215,11 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
} // endif h
if (h == INVALID_HANDLE_VALUE || !len.QuadPart) {
-#else // !WIN32
+#else // !__WIN__
h = open64(filename, O_RDONLY, 0);
if (h == INVALID_HANDLE_VALUE || !_filelength(h)) {
-#endif // !WIN32
+#endif // !__WIN__
// Consider this is a void table
if (trace)
htrc("Void table h=%d\n", h);
@@ -3280,17 +3280,17 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
strcat(PlugRemoveType(filename, filename), ".blk");
if (h == INVALID_HANDLE_VALUE) {
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING;
h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0,
NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
-#else // !WIN32
+#else // !__WIN__
int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC;
h = open64(filename, oflag, 0);
-#endif // !WIN32
+#endif // !__WIN__
if (h == INVALID_HANDLE_VALUE) {
sprintf(g->Message, "Error opening header file %s", filename);
@@ -3328,7 +3328,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
PlugSetPath(filename, fn, Tdbp->GetPath());
-#if defined(WIN32)
+#if defined(__WIN__)
char *p;
DWORD rc;
bool brc;
@@ -3380,7 +3380,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
CloseHandle(h);
return true;
-#else // !WIN32
+#else // !__WIN__
int h;
BIGINT pos;
@@ -3409,7 +3409,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
close(h);
return true;
-#endif // !WIN32
+#endif // !__WIN__
} // end of MakeEmptyFile
/***********************************************************************/
@@ -3440,7 +3440,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
htrc("OpenTableFile: filename=%s mode=%d Last=%d\n",
filename, mode, Last);
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD access, creation, share = 0, rc = 0;
/*********************************************************************/
@@ -3766,7 +3766,7 @@ int BGVFAM::WriteBuffer(PGLOBAL g)
if (!Closing && !MaxBlk) {
// Close the VCT file and reopen it in mode Insert
-//#if defined(WIN32) //OB
+//#if defined(__WIN__) //OB
// CloseHandle(Hfile);
//#else // UNIX
// close(Hfile);
@@ -3893,7 +3893,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc)
/***************************************************************/
/* Remove extra records. */
/***************************************************************/
-#if defined(WIN32)
+#if defined(__WIN__)
BIGINT pos = (BIGINT)Block * (BIGINT)Blksize;
if (BigSeek(g, Hfile, pos))
@@ -3905,12 +3905,12 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc)
sprintf(g->Message, MSG(SETEOF_ERROR), drc);
return RC_FX;
} // endif error
-#else // !WIN32
+#else // !__WIN__
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
return RC_FX;
} // endif
-#endif // !WIN32
+#endif // !__WIN__
} else // MaxBlk
// Clean the unused space in the file, this is required when
// inserting again with a partial column list.
@@ -3947,7 +3947,7 @@ bool BGVFAM::OpenTempFile(PGLOBAL g)
else if (MakeEmptyFile(g, tempname))
return true;
-#if defined(WIN32)
+#if defined(__WIN__)
DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW;
Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
@@ -4218,7 +4218,7 @@ void BGVFAM::Rewind(void)
CurNum = Nrec - 1;
#if 0 // This is probably unuseful as the file is directly accessed
-#if defined(WIN32) //OB
+#if defined(__WIN__) //OB
SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
#else // UNIX
lseek64(Hfile, 0, SEEK_SET);
diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp
index 1288689325c..56faa555069 100644
--- a/storage/connect/filamzip.cpp
+++ b/storage/connect/filamzip.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -17,21 +17,21 @@
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro
#endif
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <errno.h>
#else // !UNIX
#include <io.h>
#endif
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -89,11 +89,11 @@ int ZIPFAM::Zerror(PGLOBAL g)
strcpy(g->Message, gzerror(Zfile, &errnum));
if (errnum == Z_ERRNO)
-#if defined(WIN32)
+#if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL));
-#else // !WIN32
+#else // !__WIN__
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
-#endif // !WIN32
+#endif // !__WIN__
return (errnum == Z_STREAM_END) ? RC_EF : RC_FX;
} // end of Zerror
@@ -247,7 +247,7 @@ int ZIPFAM::GetNextPos(void)
/***********************************************************************/
/* SetPos: Replace the table at the specified position. */
/***********************************************************************/
-bool ZIPFAM::SetPos(PGLOBAL g, int pos)
+bool ZIPFAM::SetPos(PGLOBAL g, int pos __attribute__((unused)))
{
sprintf(g->Message, MSG(NO_SETPOS_YET), "ZIP");
return true;
@@ -267,7 +267,7 @@ bool ZIPFAM::SetPos(PGLOBAL g, int pos)
/***********************************************************************/
/* Record file position in case of UPDATE or DELETE. */
/***********************************************************************/
-bool ZIPFAM::RecordPos(PGLOBAL g)
+bool ZIPFAM::RecordPos(PGLOBAL)
{
Zpos = gztell(Zfile);
return false;
@@ -376,7 +376,7 @@ int ZIPFAM::WriteBuffer(PGLOBAL g)
/***********************************************************************/
/* Data Base delete line routine for ZDOS access method. (NIY) */
/***********************************************************************/
-int ZIPFAM::DeleteRecords(PGLOBAL g, int irc)
+int ZIPFAM::DeleteRecords(PGLOBAL g, int)
{
strcpy(g->Message, MSG(NO_ZIP_DELETE));
return RC_FX;
@@ -385,7 +385,7 @@ int ZIPFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
/* Data Base close routine for DOS access method. */
/***********************************************************************/
-void ZIPFAM::CloseTableFile(PGLOBAL g, bool abort)
+void ZIPFAM::CloseTableFile(PGLOBAL, bool)
{
int rc = gzclose(Zfile);
@@ -431,7 +431,7 @@ ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp)
/***********************************************************************/
/* Use BlockTest to reduce the table estimated size. */
/***********************************************************************/
-int ZBKFAM::MaxBlkSize(PGLOBAL g, int s)
+int ZBKFAM::MaxBlkSize(PGLOBAL g, int)
{
int rc = RC_OK, savcur = CurBlk;
int size;
@@ -503,7 +503,7 @@ int ZBKFAM::GetPos(void)
/* Record file position in case of UPDATE or DELETE. */
/* Not used yet for fixed tables. */
/***********************************************************************/
-bool ZBKFAM::RecordPos(PGLOBAL g)
+bool ZBKFAM::RecordPos(PGLOBAL /*g*/)
{
//strcpy(g->Message, "RecordPos not implemented for zip blocked tables");
//return true;
@@ -513,7 +513,7 @@ bool ZBKFAM::RecordPos(PGLOBAL g)
/***********************************************************************/
/* Skip one record in file. */
/***********************************************************************/
-int ZBKFAM::SkipRecord(PGLOBAL g, bool header)
+int ZBKFAM::SkipRecord(PGLOBAL /*g*/, bool)
{
//strcpy(g->Message, "SkipRecord not implemented for zip blocked tables");
//return RC_FX;
@@ -668,7 +668,7 @@ int ZBKFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
/* Data Base close routine for ZBK access method. */
/***********************************************************************/
-void ZBKFAM::CloseTableFile(PGLOBAL g, bool abort)
+void ZBKFAM::CloseTableFile(PGLOBAL g, bool)
{
int rc = RC_OK;
@@ -764,9 +764,9 @@ bool ZIXFAM::AllocateBuffer(PGLOBAL g)
if (Tdbp->GetFtype() < 2)
// if not binary, the file is physically a text file
for (int len = Lrecl; len <= Buflen; len += Lrecl) {
-#if defined(WIN32)
+#if defined(__WIN__)
To_Buf[len - 2] = '\r';
-#endif // WIN32
+#endif // __WIN__
To_Buf[len - 1] = '\n';
} // endfor len
@@ -1060,7 +1060,7 @@ int ZLBFAM::GetNextPos(void)
/***********************************************************************/
/* SetPos: Replace the table at the specified position. */
/***********************************************************************/
-bool ZLBFAM::SetPos(PGLOBAL g, int pos)
+bool ZLBFAM::SetPos(PGLOBAL g, int pos __attribute__((unused)))
{
sprintf(g->Message, MSG(NO_SETPOS_YET), "ZIP");
return true;
@@ -1350,7 +1350,7 @@ bool ZLBFAM::WriteCompressedBuffer(PGLOBAL g)
/***********************************************************************/
/* Table file close routine for DOS access method. */
/***********************************************************************/
-void ZLBFAM::CloseTableFile(PGLOBAL g, bool abort)
+void ZLBFAM::CloseTableFile(PGLOBAL g, bool)
{
int rc = RC_OK;
diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp
index 949d49c2943..262d6b58a70 100644
--- a/storage/connect/filter.cpp
+++ b/storage/connect/filter.cpp
@@ -13,13 +13,13 @@
#include "sql_class.h"
//#include "sql_time.h"
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
diff --git a/storage/connect/filter.h b/storage/connect/filter.h
index 78e066d9ab7..15730e2cc44 100644
--- a/storage/connect/filter.h
+++ b/storage/connect/filter.h
@@ -1,7 +1,7 @@
/*************** Filter H Declares Source Code File (.H) ***************/
/* Name: FILTER.H Version 1.2 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2010-2012 */
+/* (C) Copyright to the author Olivier BERTRAND 2010-2015 */
/* */
/* This file contains the FILTER and derived classes declares. */
/***********************************************************************/
@@ -105,8 +105,8 @@ class FILTERX : public FILTER {
virtual bool Eval(PGLOBAL) = 0; // just to prevent direct FILTERX use
// Fake operator new used to change a filter into a derived filter
- void * operator new(size_t size, PFIL filp) {return filp;}
-#if defined(WIN32)
+ void * operator new(size_t, PFIL filp) {return filp;}
+#if defined(__WIN__)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, PFIL) {}
#else
diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c
index a72a2b9b31e..22c3a1e79ad 100644
--- a/storage/connect/fmdlex.c
+++ b/storage/connect/fmdlex.c
@@ -20,11 +20,12 @@
*/
#define FLEX_SCANNER
-#if WIN32
+#ifdef __WIN__
#define __STDC__ 1
+#define isatty _isatty
#endif
#include <stdio.h>
-#ifndef WIN32
+#ifndef __WIN__
#include <unistd.h>
#endif
diff --git a/storage/connect/global.h b/storage/connect/global.h
index 10564d09815..4d01a3ff05b 100644
--- a/storage/connect/global.h
+++ b/storage/connect/global.h
@@ -13,11 +13,11 @@
#include <time.h> /* time_t type declaration */
#include <setjmp.h> /* Long jump declarations */
-#if defined(WIN32) && !defined(NOEX)
+#if defined(__WIN__) && !defined(NOEX)
#define DllExport __declspec( dllexport )
-#else // !WIN32
+#else // !__WIN__
#define DllExport
-#endif // !WIN32
+#endif // !__WIN__
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT)
#define XML_SUPPORT 1
@@ -42,11 +42,11 @@
#define STEP(I) MSG_##I
#endif // !XMSG and !NEWMSG
-#if defined(WIN32)
+#if defined(__WIN__)
#define CRLF 2
-#else // !WIN32
+#else // !__WIN__
#define CRLF 1
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Define access to the thread based trace value. */
@@ -104,7 +104,7 @@
#define SYS_STAMP "DOSR"
#elif defined(WIN)
#define SYS_STAMP "WIN1"
-#elif defined(WIN32)
+#elif defined(__WIN__)
#define SYS_STAMP "WIN2"
#else
#define SYS_STAMP "XXXX"
@@ -248,9 +248,9 @@ DllExport char *PlugReadMessage(PGLOBAL, int, char *);
#elif defined(NEWMSG)
DllExport char *PlugGetMessage(PGLOBAL, int);
#endif // XMSG || NEWMSG
-#if defined(WIN32)
+#if defined(__WIN__)
DllExport short GetLineLength(PGLOBAL); // Console line length
-#endif // WIN32
+#endif // __WIN__
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization
DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 2c8e563ffdc..d3741349026 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -138,10 +138,10 @@
#include "reldef.h"
#include "tabcol.h"
#include "xindex.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include "tabwmi.h"
-#endif // WIN32
+#endif // __WIN__
#include "connect.h"
#include "user_connect.h"
#include "ha_connect.h"
@@ -153,6 +153,7 @@
#endif // LIBXML2_SUPPORT
#include "taboccur.h"
#include "tabpivot.h"
+#include "tabfix.h"
#define my_strupr(p) my_caseup_str(default_charset_info, (p));
#define my_strlwr(p) my_casedn_str(default_charset_info, (p));
@@ -168,13 +169,13 @@
#define JSONMAX 10 // JSON Default max grp size
extern "C" {
- char version[]= "Version 1.03.0007 April 30, 2015";
-#if defined(WIN32)
+ char version[]= "Version 1.03.0007 June 03, 2015";
+#if defined(__WIN__)
char compver[]= "Version 1.03.0007 " __DATE__ " " __TIME__;
char slash= '\\';
-#else // !WIN32
+#else // !__WIN__
char slash= '/';
-#endif // !WIN32
+#endif // !__WIN__
} // extern "C"
#if defined(XMAP)
@@ -193,10 +194,9 @@ extern "C" {
/* Utility functions. */
/***********************************************************************/
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
-PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info);
-PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
- int pretty, int lvl, int mxr, bool info);
-PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info);
+PQRYRES VirColumns(PGLOBAL g, bool info);
+PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info);
+PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info);
void PushWarning(PGLOBAL g, THD *thd, int level);
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host,
const char *db, char *tab, const char *src, int port);
@@ -349,7 +349,7 @@ int GetConvSize(void) {return THDVAR(current_thd, conv_size);}
TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);}
uint GetJsonGrpSize(void) {return THDVAR(current_thd, json_grp_size);}
uint GetWorkSize(void) {return THDVAR(current_thd, work_size);}
-void SetWorkSize(uint n)
+void SetWorkSize(uint)
{
// Changing the session variable value seems to be impossible here
// and should be done in a check function
@@ -629,11 +629,11 @@ static int connect_init_func(void *p)
}
#endif // 0 (LINUX)
-#if defined(WIN32)
+#if defined(__WIN__)
sql_print_information("CONNECT: %s", compver);
-#else // !WIN32
+#else // !__WIN__
sql_print_information("CONNECT: %s", version);
-#endif // !WIN32
+#endif // !__WIN__
#ifdef LIBXML2_SUPPORT
XmlInitParserLib();
@@ -656,6 +656,7 @@ static int connect_init_func(void *p)
sql_print_information("connect_init: hton=%p", p);
DTVAL::SetTimeShift(); // Initialize time zone shift once for all
+ BINCOL::SetEndian(); // Initialize host endian setting
DBUG_RETURN(0);
} // end of connect_init_func
@@ -664,7 +665,7 @@ static int connect_init_func(void *p)
@brief
Plugin clean up
*/
-static int connect_done_func(void *p)
+static int connect_done_func(void *)
{
int error= 0;
PCONNECT pc, pn;
@@ -674,9 +675,9 @@ static int connect_done_func(void *p)
XmlCleanupParserLib();
#endif // LIBXML2_SUPPORT
-#if !defined(WIN32)
+#if !defined(__WIN__)
//PROFILE_End(); Causes signal 11
-#endif // !WIN32
+#endif // !__WIN__
for (pc= user_connect::to_users; pc; pc= pn) {
if (pc->g)
@@ -743,11 +744,11 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
xp= (table) ? GetUser(ha_thd(), NULL) : NULL;
if (xp)
xp->SetHandler(this);
-#if defined(WIN32)
+#if defined(__WIN__)
datapath= ".\\";
-#else // !WIN32
+#else // !__WIN__
datapath= "./";
-#endif // !WIN32
+#endif // !__WIN__
tdbp= NULL;
sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
sdvalout= NULL;
@@ -822,8 +823,6 @@ ha_connect::~ha_connect(void)
/****************************************************************************/
static PCONNECT GetUser(THD *thd, PCONNECT xp)
{
- const char *dbn= NULL;
-
if (!thd)
return NULL;
@@ -835,7 +834,7 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp)
break;
if (!xp) {
- xp= new user_connect(thd, dbn);
+ xp= new user_connect(thd);
if (xp->user_init()) {
delete xp;
@@ -908,7 +907,8 @@ const char *ha_connect::index_type(uint inx)
If all_parts is set, MySQL wants to know the flags for the combined
index, up to and including 'part'.
*/
-ulong ha_connect::index_flags(uint inx, uint part, bool all_parts) const
+//ong ha_connect::index_flags(uint inx, uint part, bool all_parts) const
+ulong ha_connect::index_flags(uint, uint, bool) const
{
ulong flags= HA_READ_NEXT | HA_READ_RANGE |
HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR;
@@ -1017,6 +1017,117 @@ char *GetListOption(PGLOBAL g, const char *opname,
} // end of GetListOption
/****************************************************************************/
+/* Return the value of a string option or NULL if not specified. */
+/****************************************************************************/
+char *GetStringTableOption(PGLOBAL g, PTOS options, char *opname, char *sdef)
+{
+ const char *opval= NULL;
+
+ if (!options)
+ return sdef;
+ else if (!stricmp(opname, "Type"))
+ opval= options->type;
+ else if (!stricmp(opname, "Filename"))
+ opval= options->filename;
+ else if (!stricmp(opname, "Optname"))
+ opval= options->optname;
+ else if (!stricmp(opname, "Tabname"))
+ opval= options->tabname;
+ else if (!stricmp(opname, "Tablist"))
+ opval= options->tablist;
+ else if (!stricmp(opname, "Database") ||
+ !stricmp(opname, "DBname"))
+ opval= options->dbname;
+ else if (!stricmp(opname, "Separator"))
+ opval= options->separator;
+ else if (!stricmp(opname, "Qchar"))
+ opval= options->qchar;
+ else if (!stricmp(opname, "Module"))
+ opval= options->module;
+ else if (!stricmp(opname, "Subtype"))
+ opval= options->subtype;
+ else if (!stricmp(opname, "Catfunc"))
+ opval= options->catfunc;
+ else if (!stricmp(opname, "Srcdef"))
+ opval= options->srcdef;
+ else if (!stricmp(opname, "Colist"))
+ opval= options->colist;
+ else if (!stricmp(opname, "Data_charset"))
+ opval= options->data_charset;
+
+ if (!opval && options && options->oplist)
+ opval= GetListOption(g, opname, options->oplist);
+
+ return opval ? (char*)opval : sdef;
+} // end of GetStringTableOption
+
+/****************************************************************************/
+/* Return the value of a Boolean option or bdef if not specified. */
+/****************************************************************************/
+bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef)
+{
+ bool opval= bdef;
+ char *pv;
+
+ if (!options)
+ return bdef;
+ else if (!stricmp(opname, "Mapped"))
+ opval= options->mapped;
+ else if (!stricmp(opname, "Huge"))
+ opval= options->huge;
+ else if (!stricmp(opname, "Split"))
+ opval= options->split;
+ else if (!stricmp(opname, "Readonly"))
+ opval= options->readonly;
+ else if (!stricmp(opname, "SepIndex"))
+ opval= options->sepindex;
+ else if (!stricmp(opname, "Header"))
+ opval= (options->header != 0); // Is Boolean for some table types
+ else if (options->oplist)
+ if ((pv= GetListOption(g, opname, options->oplist)))
+ opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0);
+
+ return opval;
+} // end of GetBooleanTableOption
+
+/****************************************************************************/
+/* Return the value of an integer option or NO_IVAL if not specified. */
+/****************************************************************************/
+int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef)
+{
+ ulonglong opval= NO_IVAL;
+
+ if (!options)
+ return idef;
+ else if (!stricmp(opname, "Lrecl"))
+ opval= options->lrecl;
+ else if (!stricmp(opname, "Elements"))
+ opval= options->elements;
+ else if (!stricmp(opname, "Multiple"))
+ opval= options->multiple;
+ else if (!stricmp(opname, "Header"))
+ opval= options->header;
+ else if (!stricmp(opname, "Quoted"))
+ opval= options->quoted;
+ else if (!stricmp(opname, "Ending"))
+ opval= options->ending;
+ else if (!stricmp(opname, "Compressed"))
+ opval= (options->compressed);
+
+ if (opval == NO_IVAL) {
+ char *pv;
+
+ if ((pv= GetListOption(g, opname, options->oplist)))
+ opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true);
+ else
+ return idef;
+
+ } // endif opval
+
+ return (int)opval;
+} // end of GetIntegerTableOption
+
+/****************************************************************************/
/* Return the table option structure. */
/****************************************************************************/
PTOS ha_connect::GetTableOptionStruct(TABLE_SHARE *s)
@@ -1034,9 +1145,6 @@ char *ha_connect::GetRealString(const char *s)
char *sv;
if (IsPartitioned() && s) {
-// sv= (char*)PlugSubAlloc(xp->g, NULL, strlen(s) + strlen(partname));
- // With wrong string pattern, the size of the constructed string
- // can be more than strlen(s) + strlen(partname)
sv= (char*)PlugSubAlloc(xp->g, NULL, 0);
sprintf(sv, s, partname);
PlugSubAlloc(xp->g, NULL, strlen(sv) + 1);
@@ -1047,7 +1155,7 @@ char *ha_connect::GetRealString(const char *s)
} // end of GetRealString
/****************************************************************************/
-/* Return the value of a string option or NULL if not specified. */
+/* Return the value of a string option or sdef if not specified. */
/****************************************************************************/
char *ha_connect::GetStringOption(char *opname, char *sdef)
{
@@ -1065,37 +1173,6 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
opval= thd_query_string(table->in_use)->str;
else if (!stricmp(opname, "Partname"))
opval= partname;
- else if (!options)
- ;
- else if (!stricmp(opname, "Type"))
- opval= (char*)options->type;
- else if (!stricmp(opname, "Filename"))
- opval= GetRealString(options->filename);
- else if (!stricmp(opname, "Optname"))
- opval= (char*)options->optname;
- else if (!stricmp(opname, "Tabname"))
- opval= GetRealString(options->tabname);
- else if (!stricmp(opname, "Tablist"))
- opval= (char*)options->tablist;
- else if (!stricmp(opname, "Database") ||
- !stricmp(opname, "DBname"))
- opval= (char*)options->dbname;
- else if (!stricmp(opname, "Separator"))
- opval= (char*)options->separator;
- else if (!stricmp(opname, "Qchar"))
- opval= (char*)options->qchar;
- else if (!stricmp(opname, "Module"))
- opval= (char*)options->module;
- else if (!stricmp(opname, "Subtype"))
- opval= (char*)options->subtype;
- else if (!stricmp(opname, "Catfunc"))
- opval= (char*)options->catfunc;
- else if (!stricmp(opname, "Srcdef"))
- opval= (char*)options->srcdef;
- else if (!stricmp(opname, "Colist"))
- opval= (char*)options->colist;
- else if (!stricmp(opname, "Data_charset"))
- opval= (char*)options->data_charset;
else if (!stricmp(opname, "Table_charset")) {
const CHARSET_INFO *chif= (tshp) ? tshp->table_charset
: table->s->table_charset;
@@ -1103,17 +1180,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
if (chif)
opval= (char*)chif->csname;
- } // endif Table_charset
-
- if (!opval && options && options->oplist) {
- opval= GetListOption(xp->g, opname, options->oplist);
-
- if (opval && (!stricmp(opname, "connect")
- || !stricmp(opname, "tabname")
- || !stricmp(opname, "filename")))
- opval = GetRealString(opval);
+ } else
+ opval= GetStringTableOption(xp->g, options, opname, NULL);
- } // endif opval
+ if (opval && (!stricmp(opname, "connect")
+ || !stricmp(opname, "tabname")
+ || !stricmp(opname, "filename")))
+ opval = GetRealString(opval);
if (!opval) {
if (sdef && !strcmp(sdef, "*")) {
@@ -1144,31 +1217,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
/****************************************************************************/
bool ha_connect::GetBooleanOption(char *opname, bool bdef)
{
- bool opval= bdef;
- char *pv;
+ bool opval;
PTOS options= GetTableOptionStruct();
if (!stricmp(opname, "View"))
opval= (tshp) ? tshp->is_view : table_share->is_view;
- else if (!options)
- ;
- else if (!stricmp(opname, "Mapped"))
- opval= options->mapped;
- else if (!stricmp(opname, "Huge"))
- opval= options->huge;
-//else if (!stricmp(opname, "Compressed"))
-// opval= options->compressed;
- else if (!stricmp(opname, "Split"))
- opval= options->split;
- else if (!stricmp(opname, "Readonly"))
- opval= options->readonly;
- else if (!stricmp(opname, "SepIndex"))
- opval= options->sepindex;
- else if (!stricmp(opname, "Header"))
- opval= (options->header != 0); // Is Boolean for some table types
- else if (options->oplist)
- if ((pv= GetListOption(xp->g, opname, options->oplist)))
- opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0);
+ else
+ opval= GetBooleanTableOption(xp->g, options, opname, bdef);
return opval;
} // end of GetBooleanOption
@@ -1197,37 +1252,18 @@ bool ha_connect::SetBooleanOption(char *opname, bool b)
/****************************************************************************/
int ha_connect::GetIntegerOption(char *opname)
{
- ulonglong opval= NO_IVAL;
- char *pv;
+ int opval;
PTOS options= GetTableOptionStruct();
TABLE_SHARE *tsp= (tshp) ? tshp : table_share;
if (!stricmp(opname, "Avglen"))
- opval= (ulonglong)tsp->avg_row_length;
+ opval= (int)tsp->avg_row_length;
else if (!stricmp(opname, "Estimate"))
- opval= (ulonglong)tsp->max_rows;
- else if (!options)
- ;
- else if (!stricmp(opname, "Lrecl"))
- opval= options->lrecl;
- else if (!stricmp(opname, "Elements"))
- opval= options->elements;
- else if (!stricmp(opname, "Multiple"))
- opval= options->multiple;
- else if (!stricmp(opname, "Header"))
- opval= options->header;
- else if (!stricmp(opname, "Quoted"))
- opval= options->quoted;
- else if (!stricmp(opname, "Ending"))
- opval= options->ending;
- else if (!stricmp(opname, "Compressed"))
- opval= (options->compressed);
-
- if (opval == (ulonglong)NO_IVAL && options && options->oplist)
- if ((pv= GetListOption(xp->g, opname, options->oplist)))
- opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true);
+ opval= (int)tsp->max_rows;
+ else
+ opval= GetIntegerTableOption(xp->g, options, opname, NO_IVAL);
- return (int)opval;
+ return opval;
} // end of GetIntegerOption
/****************************************************************************/
@@ -2008,7 +2044,7 @@ int ha_connect::MakeRecord(char *buf)
/***********************************************************************/
/* Set row values from a MySQL pseudo record. Specific to MySQL. */
/***********************************************************************/
-int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
+int ha_connect::ScanRecord(PGLOBAL g, uchar *)
{
char attr_buffer[1024];
char data_buffer[1024];
@@ -2150,7 +2186,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
/* Check change in index column. Specific to MySQL. */
/* Should be elaborated to check for real changes. */
/***********************************************************************/
-int ha_connect::CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf)
+int ha_connect::CheckRecord(PGLOBAL g, const uchar *, uchar *newbuf)
{
return ScanRecord(g, newbuf);
} // end of dummy CheckRecord
@@ -2923,7 +2959,7 @@ bool ha_connect::get_error_message(int error, String* buf)
&dummy_errors);
if (trace)
- htrc("GEM(%u): %s\n", len, g->Message);
+ htrc("GEM(%d): len=%u %s\n", error, len, g->Message);
msg[len]= '\0';
buf->copy(msg, (uint)strlen(msg), system_charset_info);
@@ -3019,7 +3055,7 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked)
@brief
Make the indexes for this table
*/
-int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt)
+int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
{
int rc= 0;
PGLOBAL& g= xp->g;
@@ -3223,7 +3259,7 @@ int ha_connect::update_row(const uchar *old_data, uchar *new_data)
@see
sql_acl.cc, sql_udf.cc, sql_delete.cc, sql_insert.cc and sql_select.cc
*/
-int ha_connect::delete_row(const uchar *buf)
+int ha_connect::delete_row(const uchar *)
{
int rc= 0;
DBUG_ENTER("ha_connect::delete_row");
@@ -3501,7 +3537,8 @@ int ha_connect::index_last(uchar *buf)
/****************************************************************************/
/* This is called to get more rows having the same index value. */
/****************************************************************************/
-int ha_connect::index_next_same(uchar *buf, const uchar *key, uint keylen)
+//t ha_connect::index_next_same(uchar *buf, const uchar *key, uint keylen)
+int ha_connect::index_next_same(uchar *buf, const uchar *, uint)
{
int rc;
DBUG_ENTER("ha_connect::index_next_same");
@@ -3690,7 +3727,7 @@ int ha_connect::rnd_next(uchar *buf)
@see
filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc
*/
-void ha_connect::position(const uchar *record)
+void ha_connect::position(const uchar *)
{
DBUG_ENTER("ha_connect::position");
//if (((PTDBASE)tdbp)->GetDef()->Indexable())
@@ -3873,7 +3910,7 @@ int ha_connect::info(uint flag)
@see
ha_innodb.cc
*/
-int ha_connect::extra(enum ha_extra_function operation)
+int ha_connect::extra(enum ha_extra_function /*operation*/)
{
DBUG_ENTER("ha_connect::extra");
DBUG_RETURN(0);
@@ -3952,11 +3989,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)
@@ -4481,7 +4518,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
@see
get_lock_data() in lock.cc
*/
-THR_LOCK_DATA **ha_connect::store_lock(THD *thd,
+THR_LOCK_DATA **ha_connect::store_lock(THD *,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
@@ -4715,6 +4752,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
@@ -4898,7 +4938,7 @@ static int init_table_share(THD* thd,
oom|= sql->append(' ');
oom|= sql->append(opt->name);
oom|= sql->append('=');
- oom|= sql->append(vull ? "ON" : "OFF");
+ oom|= sql->append(vull ? "YES" : "NO");
} // endif vull
break;
@@ -4952,7 +4992,7 @@ static int init_table_share(THD* thd,
@note
this function is no more called in case of CREATE .. SELECT
*/
-static int connect_assisted_discovery(handlerton *hton, THD* thd,
+static int connect_assisted_discovery(handlerton *, THD* thd,
TABLE_SHARE *table_s,
HA_CREATE_INFO *create_info)
{
@@ -4960,12 +5000,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
const char *fncn= "?";
const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src;
const char *col, *ocl, *rnk, *pic, *fcl, *skc;
- char *tab, *dsn, *shm, *dpath, *objn;
-#if defined(WIN32)
+ char *tab, *dsn, *shm, *dpath;
+#if defined(__WIN__)
char *nsp= NULL, *cls= NULL;
-#endif // WIN32
- int port= 0, hdr= 0, mxr __attribute__((unused))= 0, mxe= 0, rc= 0;
- int cop __attribute__((unused))= 0, pty= 2, lrecl= 0, lvl= 0;
+#endif // __WIN__
+ int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0;
+ int cop __attribute__((unused))= 0, lrecl= 0;
#if defined(ODBC_SUPPORT)
POPARM sop = NULL;
char *ucnc = NULL;
@@ -4995,7 +5035,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
if (!g)
return HA_ERR_INTERNAL_ERROR;
- user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= objn= NULL;
+ user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= NULL;
// Get the useful create options
ttp= GetTypeID(topt->type);
@@ -5026,11 +5066,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
skc= GetListOption(g, "skipcol", topt->oplist, NULL);
rnk= GetListOption(g, "rankcol", topt->oplist, NULL);
pwd= GetListOption(g, "password", topt->oplist);
- objn= GetListOption(g, "Object", topt->oplist, NULL);
-#if defined(WIN32)
+#if defined(__WIN__)
nsp= GetListOption(g, "namespace", topt->oplist);
cls= GetListOption(g, "class", topt->oplist);
-#endif // WIN32
+#endif // __WIN__
port= atoi(GetListOption(g, "port", topt->oplist, "0"));
#if defined(ODBC_SUPPORT)
mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0"));
@@ -5044,8 +5083,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
#if defined(PROMPT_OK)
cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0"));
#endif // PROMPT_OK
- pty= atoi(GetListOption(g,"Pretty", topt->oplist, "2"));
- lvl= atoi(GetListOption(g,"Level", topt->oplist, "0"));
} else {
host= "localhost";
user= (ttp == TAB_ODBC ? NULL : "root");
@@ -5189,11 +5226,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
ok= false;
break;
-#if defined(WIN32)
+#if defined(__WIN__)
case TAB_WMI:
ok= true;
break;
-#endif // WIN32
+#endif // __WIN__
#if defined(PIVOT_SUPPORT)
case TAB_PIVOT:
supfnc= FNC_NO;
@@ -5306,11 +5343,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
case TAB_CSV:
qrp= CSVColumns(g, dpath, fn, spc, qch, hdr, mxe, fnc == FNC_COL);
break;
-#if defined(WIN32)
+#if defined(__WIN__)
case TAB_WMI:
qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL);
break;
-#endif // WIN32
+#endif // __WIN__
case TAB_PRX:
case TAB_TBL:
case TAB_XCL:
@@ -5334,10 +5371,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
break;
#endif // PIVOT_SUPPORT
case TAB_VIR:
- qrp= VirColumns(g, tab, (char*)db, fnc == FNC_COL);
+ qrp= VirColumns(g, fnc == FNC_COL);
break;
case TAB_JSON:
- qrp= JSONColumns(g, (char*)db, fn, objn, pty, lrecl, lvl, fnc == FNC_COL);
+ qrp= JSONColumns(g, (char*)db, topt, fnc == FNC_COL);
break;
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
case TAB_XML:
@@ -5486,10 +5523,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
#if defined(ODBC_SUPPORT)
if (ttp == TAB_ODBC) {
- int plgtyp;
+ int plgtyp;
+ bool w= false; // Wide character type
// typ must be PLG type, not SQL type
- if (!(plgtyp= TranslateSQLType(typ, dec, prec, v))) {
+ if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) {
if (GetTypeConv() == TPC_SKIP) {
// Skip this column
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
@@ -5506,6 +5544,13 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
typ= plgtyp;
switch (typ) {
+ case TYPE_STRING:
+ if (w) {
+ sprintf(g->Message, "Column %s is wide characters", cnm);
+ push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
+ } // endif w
+
+ break;
case TYPE_DOUBLE:
// Some data sources do not count dec in length (prec)
prec += (dec + 2); // To be safe
@@ -5764,11 +5809,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':
@@ -6115,11 +6160,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());
@@ -6461,8 +6506,7 @@ fin:
@note: This function is no more called by check_if_supported_inplace_alter
*/
-bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info,
- uint table_changes)
+bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *, uint)
{
DBUG_ENTER("ha_connect::check_if_incompatible_data");
// TO DO: really implement and check it.
@@ -6604,7 +6648,7 @@ maria_declare_plugin(connect)
0x0103, /* version number (1.03) */
NULL, /* status variables */
connect_system_variables, /* system variables */
- "1.03.0006", /* string version */
+ "1.03.0007", /* string version */
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
}
maria_declare_plugin_end;
diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp
index 1e597f751ca..3d03bea5d00 100644
--- a/storage/connect/json.cpp
+++ b/storage/connect/json.cpp
@@ -23,7 +23,7 @@
#define ARGS MY_MIN(24,len-i),s+MY_MAX(i-3,0)
-#if defined(WIN32)
+#if defined(__WIN__)
#define EL "\r\n"
#else
#define EL "\n"
diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp
index 1afd79bec05..ff4025ee0fb 100644
--- a/storage/connect/jsonudf.cpp
+++ b/storage/connect/jsonudf.cpp
@@ -296,7 +296,7 @@ my_bool Json_Value_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // end of Json_Value_init
char *Json_Value(UDF_INIT *initid, UDF_ARGS *args, char *result,
- unsigned long *res_length, char *is_null, char *error)
+ unsigned long *res_length, char *, char *)
{
char *str;
PJVAL jvp;
@@ -329,7 +329,7 @@ my_bool Json_Array_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // end of Json_Array_init
char *Json_Array(UDF_INIT *initid, UDF_ARGS *args, char *result,
- unsigned long *res_length, char *is_null, char *error)
+ unsigned long *res_length, char *, char *)
{
char *str;
uint i;
@@ -376,7 +376,7 @@ my_bool Json_Array_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // end of Json_Array_Add_init
char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result,
- unsigned long *res_length, char *is_null, char *error)
+ unsigned long *res_length, char *, char *)
{
char *str;
PJVAL jvp;
@@ -410,7 +410,7 @@ void Json_Array_Add_deinit(UDF_INIT* initid)
} // end of Json_Array_Add_deinit
/***********************************************************************/
-/* Add values to a Json array. */
+/* Delete a value from a Json array. */
/***********************************************************************/
my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
@@ -429,7 +429,7 @@ my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // end of Json_Array_Delete_init
char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
- unsigned long *res_length, char *is_null, char *error)
+ unsigned long *res_length, char *, char *)
{
char *str;
int n;
@@ -451,7 +451,7 @@ char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else {
n = *(int*)args->args[1];
arp = jvp->GetArray();
- arp->DeleteValue(n - 1);
+ arp->DeleteValue(n);
arp->InitArray(g);
if (!(str = Serialize(g, arp, NULL, 0))) {
@@ -482,7 +482,7 @@ my_bool Json_Object_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // end of Json_Object_init
char *Json_Object(UDF_INIT *initid, UDF_ARGS *args, char *result,
- unsigned long *res_length, char *is_null, char *error)
+ unsigned long *res_length, char *, char *)
{
char *str;
uint i;
@@ -520,7 +520,7 @@ my_bool Json_Object_Nonull_init(UDF_INIT *initid, UDF_ARGS *args,
} // end of Json_Object_Nonull_init
char *Json_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
- unsigned long *res_length, char *is_null, char *error)
+ unsigned long *res_length, char *, char *)
{
char *str;
uint i;
@@ -574,8 +574,7 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return false;
} // end of Json_Array_Grp_init
-void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args,
- char *is_null, char *error)
+void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
{
PGLOBAL g = (PGLOBAL)initid->ptr;
PJAR arp = (PJAR)g->Activityp;
@@ -585,8 +584,8 @@ void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args,
} // end of Json_Array_Grp_add
-char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result,
- unsigned long *res_length, char *is_null, char *error)
+char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *, char *result,
+ unsigned long *res_length, char *, char *)
{
char *str;
PGLOBAL g = (PGLOBAL)initid->ptr;
@@ -605,7 +604,7 @@ char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result,
return str;
} // end of Json_Array_Grp
-void Json_Array_Grp_clear(UDF_INIT *initid, char *is_null, char *error)
+void Json_Array_Grp_clear(UDF_INIT *initid, char*, char*)
{
PGLOBAL g = (PGLOBAL)initid->ptr;
@@ -646,8 +645,7 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return false;
} // end of Json_Object_Grp_init
-void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args,
- char *is_null, char *error)
+void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
{
PGLOBAL g = (PGLOBAL)initid->ptr;
PJOB objp = (PJOB)g->Activityp;
@@ -657,8 +655,8 @@ void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args,
} // end of Json_Object_Grp_add
-char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result,
- unsigned long *res_length, char *is_null, char *error)
+char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *, char *result,
+ unsigned long *res_length, char *, char *)
{
char *str;
PGLOBAL g = (PGLOBAL)initid->ptr;
@@ -675,7 +673,7 @@ char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result,
return str;
} // end of Json_Object_Grp
-void Json_Object_Grp_clear(UDF_INIT *initid, char *is_null, char *error)
+void Json_Object_Grp_clear(UDF_INIT *initid, char*, char*)
{
PGLOBAL g = (PGLOBAL)initid->ptr;
diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp
index 7d1d014c48b..c2882fc0d7c 100644
--- a/storage/connect/libdoc.cpp
+++ b/storage/connect/libdoc.cpp
@@ -533,8 +533,8 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn)
// This function does not crash (
if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) {
xmlErrorPtr err = xmlGetLastError();
-
strcpy(g->Message, (err) ? err->message : "Error saving XML doc");
+ xmlResetError(Xerr);
rc = -1;
} // endif Save
// rc = xmlDocDump(of, Docp);
@@ -569,6 +569,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0);
//if (xp && xp->Count == 1) {
+ if (xp) {
if (Nlist) {
xmlXPathFreeNodeSet(Nlist);
@@ -605,7 +606,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
Ctxp = NULL;
} // endif Ctxp
-// } // endif Count
+ } // endif xp
CloseXML2File(g, xp, false);
} // end of Close
diff --git a/storage/connect/macutil.cpp b/storage/connect/macutil.cpp
index 4d3022b91b6..f5d3bb11fe9 100644
--- a/storage/connect/macutil.cpp
+++ b/storage/connect/macutil.cpp
@@ -2,11 +2,11 @@
/* MACUTIL: Author Olivier Bertrand -- 2008-2012 */
/* From the article and sample code by Khalid Shaikh. */
/***********************************************************************/
-#if defined(WIN32)
+#if defined(__WIN__)
#include "my_global.h"
-#else // !WIN32
-#error This is WIN32 only DLL
-#endif // !WIN32
+#else // !__WIN__
+#error This is WINDOWS only DLL
+#endif // !__WIN__
#include "global.h"
#include "plgdbsem.h"
#include "macutil.h"
diff --git a/storage/connect/macutil.h b/storage/connect/macutil.h
index 8a3e97e12e1..c80bd58e20a 100644
--- a/storage/connect/macutil.h
+++ b/storage/connect/macutil.h
@@ -1,10 +1,10 @@
// MACUTIL.H Olivier Bertrand 2008-2012
// Get Mac Addresses via GetAdaptersInfo
-#if defined(WIN32)
+#if defined(__WIN__)
#include <iphlpapi.h>
-#else // !WIN32
-#error This is WIN32 only
-#endif // !WIN32
+#else // !__WIN__
+#error This is WINDOWS only
+#endif // !__WIN__
#include "block.h"
typedef class MACINFO *MACIP;
diff --git a/storage/connect/maputil.cpp b/storage/connect/maputil.cpp
index 97c638b4254..c4e016f1511 100644
--- a/storage/connect/maputil.cpp
+++ b/storage/connect/maputil.cpp
@@ -14,7 +14,7 @@
#include "plgdbsem.h"
#include "maputil.h"
-#ifdef WIN32
+#ifdef __WIN__
/***********************************************************************/
/* In Insert mode, just open the file for append. Otherwise */
/* create the mapping file object. The map handle can be released */
diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc
index b15c8fa2322..9c72e9cd665 100644
--- a/storage/connect/mycat.cc
+++ b/storage/connect/mycat.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) Olivier Bertrand 2004 - 2014
+/* Copyright (C) Olivier Bertrand 2004 - 2015
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
/* ------------- */
/* Version 1.4 */
/* */
-/* Author: Olivier Bertrand 2012 - 2014 */
+/* Author: Olivier Bertrand 2012 - 2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -30,7 +30,7 @@
/***********************************************************************/
#include <my_config.h>
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
//#include <sqlext.h>
#elif defined(UNIX)
@@ -66,10 +66,10 @@
#include "tabfmt.h"
#include "tabvct.h"
#include "tabsys.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include "tabmac.h"
#include "tabwmi.h"
-#endif // WIN32
+#endif // __WIN__
//#include "tabtbl.h"
#include "tabxcl.h"
#include "tabtbl.h"
@@ -93,13 +93,33 @@
/***********************************************************************/
/* Extern static variables. */
/***********************************************************************/
-#if defined(WIN32)
+#if defined(__WIN__)
extern "C" HINSTANCE s_hModule; // Saved module handle
-#endif // !WIN32
+#endif // !__WIN__
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
/***********************************************************************/
+/* Get the plugin directory. */
+/***********************************************************************/
+char *GetPluginDir(void)
+{
+ char *plugin_dir;
+
+#if defined(_WIN64)
+ plugin_dir = (char *)GetProcAddress(GetModuleHandle(NULL),
+ "?opt_plugin_dir@@3PADEA");
+#elif defined(_WIN32)
+ plugin_dir = (char*)GetProcAddress(GetModuleHandle(NULL),
+ "?opt_plugin_dir@@3PADA");
+#else
+ plugin_dir = opt_plugin_dir;
+#endif
+
+ return plugin_dir;
+} // end of GetPluginDir
+
+/***********************************************************************/
/* Get a unique enum table type ID. */
/***********************************************************************/
TABTYPE GetTypeID(const char *type)
@@ -122,7 +142,7 @@ TABTYPE GetTypeID(const char *type)
: (!stricmp(type, "MYSQL")) ? TAB_MYSQL
: (!stricmp(type, "MYPRX")) ? TAB_MYSQL
: (!stricmp(type, "DIR")) ? TAB_DIR
-#ifdef WIN32
+#ifdef __WIN__
: (!stricmp(type, "MAC")) ? TAB_MAC
: (!stricmp(type, "WMI")) ? TAB_WMI
#endif
@@ -328,12 +348,12 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
{
typedef PQRYRES (__stdcall *XCOLDEF) (PGLOBAL, void*, char*, char*, bool);
const char *module, *subtype;
- char c, getname[40] = "Col";
-#if defined(WIN32)
+ char c, soname[_MAX_PATH], getname[40] = "Col";
+#if defined(__WIN__)
HANDLE hdll; /* Handle to the external DLL */
-#else // !WIN32
+#else // !__WIN__
void *hdll; /* Handle for the loaded shared library */
-#endif // !WIN32
+#endif // !__WIN__
XCOLDEF coldef = NULL;
PQRYRES qrp = NULL;
@@ -343,6 +363,17 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
if (!module || !subtype)
return NULL;
+ /*********************************************************************/
+ /* Ensure that the .dll doesn't have a path. */
+ /* This is done to ensure that only approved dll from the system */
+ /* directories are used (to make this even remotely secure). */
+ /*********************************************************************/
+ if (check_valid_path(module, strlen(module))) {
+ strcpy(g->Message, "Module cannot contain a path");
+ return NULL;
+ } else
+ PlugSetPath(soname, module, GetPluginDir());
+
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = subtype[i];
@@ -350,13 +381,13 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
if (!c) break;
} // endfor i
-#if defined(WIN32)
+#if defined(__WIN__)
// Load the Dll implementing the table
- if (!(hdll = LoadLibrary(module))) {
+ if (!(hdll = LoadLibrary(soname))) {
char buf[256];
DWORD rc = GetLastError();
- sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, module);
+ sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
@@ -370,13 +401,13 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
FreeLibrary((HMODULE)hdll);
return NULL;
} // endif coldef
-#else // !WIN32
+#else // !__WIN__
const char *error = NULL;
// Load the desired shared library
- if (!(hdll = dlopen(module, RTLD_LAZY))) {
+ if (!(hdll = dlopen(soname, RTLD_LAZY))) {
error = dlerror();
- sprintf(g->Message, MSG(SHARED_LIB_ERR), module, SVP(error));
+ sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error));
return NULL;
} // endif Hdll
@@ -387,7 +418,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
dlclose(hdll);
return NULL;
} // endif coldef
-#endif // !WIN32
+#endif // !__WIN__
// Just in case the external Get function does not set error messages
sprintf(g->Message, "Error getting column info from %s", subtype);
@@ -395,11 +426,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
// Get the table column definition
qrp = coldef(g, topt, tab, db, info);
-#if defined(WIN32)
+#if defined(__WIN__)
FreeLibrary((HMODULE)hdll);
-#else // !WIN32
+#else // !__WIN__
dlclose(hdll);
-#endif // !WIN32
+#endif // !__WIN__
return qrp;
} // end of OEMColumns
@@ -411,11 +442,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
/***********************************************************************/
CATALOG::CATALOG(void)
{
-#if defined(WIN32)
+#if defined(__WIN__)
//DataPath= ".\\";
-#else // !WIN32
+#else // !__WIN__
//DataPath= "./";
-#endif // !WIN32
+#endif // !__WIN__
memset(&Ctb, 0, sizeof(CURTAB));
Cbuf= NULL;
Cblen= 0;
@@ -458,11 +489,11 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path)
}
if (*path != '.') {
-#if defined(WIN32)
+#if defined(__WIN__)
char *s= "\\";
-#else // !WIN32
+#else // !__WIN__
char *s= "/";
-#endif // !WIN32
+#endif // !__WIN__
strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
} else
strcpy(buf, path);
@@ -478,7 +509,7 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path)
/* Look for a table descriptor matching the name and type. */
/***********************************************************************/
PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
- LPCSTR type, PRELDEF *prp)
+ LPCSTR type, PRELDEF *)
{
if (trace)
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
@@ -523,10 +554,10 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
#if defined(ODBC_SUPPORT)
case TAB_ODBC: tdp= new(g) ODBCDEF; break;
#endif // ODBC_SUPPORT
-#if defined(WIN32)
+#if defined(__WIN__)
case TAB_MAC: tdp= new(g) MACDEF; break;
case TAB_WMI: tdp= new(g) WMIDEF; break;
-#endif // WIN32
+#endif // __WIN__
case TAB_OEM: tdp= new(g) OEMDEF; break;
case TAB_TBL: tdp= new(g) TBLDEF; break;
case TAB_XCL: tdp= new(g) XCLDEF; break;
@@ -589,7 +620,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
/***********************************************************************/
/* ClearDB: Terminates Database usage. */
/***********************************************************************/
-void MYCAT::ClearDB(PGLOBAL g)
+void MYCAT::ClearDB(PGLOBAL)
{
} // end of ClearDB
diff --git a/storage/connect/mycat.h b/storage/connect/mycat.h
index cdbe4e5bca9..d4024e6b6c3 100644
--- a/storage/connect/mycat.h
+++ b/storage/connect/mycat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) Olivier Bertrand 2004 - 2013
+/* Copyright (C) Olivier Bertrand 2004 - 2015
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
#include "block.h"
#include "catalog.h"
-typedef struct ha_table_option_struct TOS, *PTOS;
+//typedef struct ha_table_option_struct TOS, *PTOS;
/**
structure for CREATE TABLE options (table options)
@@ -98,7 +98,7 @@ class MYCAT : public CATALOG {
void Reset(void);
//void SetDataPath(PGLOBAL g, const char *path)
// {SetPath(g, &DataPath, path);}
- bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary
+ bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary
PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR type, PRELDEF *prp = NULL);
PTDB GetTable(PGLOBAL g, PTABLE tablep,
diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp
index 47d781d9ff6..ada0109a820 100644
--- a/storage/connect/myconn.cpp
+++ b/storage/connect/myconn.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2007-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2007-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -35,11 +35,11 @@
#include "my_sys.h"
#include "mysqld_error.h"
#endif // !MYSQL_PREPARED_STATEMENTS
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#include "osutil.h"
-#endif // !WIN32
+#endif // !__WIN__
#include "global.h"
#include "plgdbsem.h"
@@ -451,15 +451,15 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt);
//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...);
-#if defined(WIN32)
+#if defined(__WIN__)
if (!strcmp(host, ".")) {
mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL);
pipe = mysqld_unix_port;
} // endif host
-#else // !WIN32
+#else // !__WIN__
if (!strcmp(host, "localhost"))
pipe = mysqld_unix_port;
-#endif // !WIN32
+#endif // !__WIN__
#if 0
if (pwd && !strcmp(pwd, "*")) {
@@ -720,7 +720,7 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w)
/***********************************************************************/
/* Get table size by executing "select count(*) from table_name". */
/***********************************************************************/
-int MYSQLC::GetTableSize(PGLOBAL g, PSZ query)
+int MYSQLC::GetTableSize(PGLOBAL g __attribute__((unused)), PSZ query)
{
if (mysql_real_query(m_DB, query, strlen(query))) {
#if defined(_DEBUG)
diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h
index 79b8a43fe5a..fa34edd804c 100644
--- a/storage/connect/myconn.h
+++ b/storage/connect/myconn.h
@@ -7,24 +7,24 @@
/* DO NOT define DLL_EXPORT in your application so these items are */
/* declared are imported from the Myconn DLL. */
/***********************************************************************/
-#if defined(WIN32)
+#if defined(__WIN__)
#include <winsock.h>
-#else // !WIN32
+#else // !__WIN__
#include <sys/socket.h>
-#endif // !WIN32
+#endif // !__WIN__
#include <mysql.h>
#include <errmsg.h>
#include "myutil.h"
-#if defined(WIN32) && defined(MYCONN_EXPORTS)
+#if defined(__WIN__) && defined(MYCONN_EXPORTS)
#if defined(DLL_EXPORT)
#define DllItem _declspec(dllexport)
#else // !DLL_EXPORT
#define DllItem _declspec(dllimport)
#endif // !DLL_EXPORT
-#else // !WIN32 || !MYCONN_EXPORTS
+#else // !__WIN__ || !MYCONN_EXPORTS
#define DllItem
-#endif // !WIN32
+#endif // !__WIN__
#define MYSQL_ENABLED 0x00000001
#define MYSQL_LOGON 0x00000002
diff --git a/storage/connect/mysql-test/connect/r/bin.result b/storage/connect/mysql-test/connect/r/bin.result
index bbf5614b555..4ba353ac705 100644
--- a/storage/connect/mysql-test/connect/r/bin.result
+++ b/storage/connect/mysql-test/connect/r/bin.result
@@ -14,12 +14,12 @@ SET time_zone='+00:00';
CREATE TABLE t1
(
fig INT(4) NOT NULL FIELD_FORMAT='C',
-name CHAR(10) not null,
+name CHAR(10) NOT NULL,
birth DATE NOT NULL,
id CHAR(5) NOT NULL FIELD_FORMAT='S',
salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
dept INT(4) NOT NULL FIELD_FORMAT='S'
-) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat';
+) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
SELECT * FROM t1;
fig name birth id salary dept
5500 ARCHIBALD 1980-01-25 3789 4380.50 318
@@ -41,12 +41,12 @@ DROP TABLE t1;
CREATE TABLE t1
(
fig INT(4) NOT NULL FIELD_FORMAT='C',
-name CHAR(10) not null,
+name CHAR(10) NOT NULL,
birth DATE NOT NULL,
id CHAR(5) NOT NULL FIELD_FORMAT='S',
salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
dept INT(4) NOT NULL FIELD_FORMAT='S'
-) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat';
+) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
ERROR HY000: Table 't1' is read only
ALTER TABLE t1 READONLY=NO;
@@ -59,7 +59,7 @@ t1 CREATE TABLE `t1` (
`id` char(5) NOT NULL `FIELD_FORMAT`='S',
`salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F',
`dept` int(4) NOT NULL `FIELD_FORMAT`='S'
-) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `READONLY`=NO
+) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=NO
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
SELECT * FROM t1;
fig name birth id salary dept
@@ -78,7 +78,7 @@ t1 CREATE TABLE `t1` (
`id` char(5) NOT NULL `FIELD_FORMAT`='S',
`salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F',
`dept` int(4) NOT NULL `FIELD_FORMAT`='S'
-) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `READONLY`=YES
+) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=YES
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
ERROR HY000: Table 't1' is read only
DROP TABLE t1;
diff --git a/storage/connect/mysql-test/connect/r/json.result b/storage/connect/mysql-test/connect/r/json.result
index 80b0a2cbc18..acb74c38e26 100644
--- a/storage/connect/mysql-test/connect/r/json.result
+++ b/storage/connect/mysql-test/connect/r/json.result
@@ -97,7 +97,7 @@ ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher L
CREATE TABLE t2 (
FIRSTNAME CHAR(32),
LASTNAME CHAR(32))
-ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[2]:AUTHOR';
+ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[1]:AUTHOR';
SELECT * FROM t2;
FIRSTNAME LASTNAME
William J. Pardi
@@ -252,9 +252,9 @@ DROP TABLE t1;
#
CREATE TABLE t2 (
WHO CHAR(12),
-WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER',
-WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT',
-AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT')
+WEEK INT(2) FIELD_FORMAT='WEEK:[0]:NUMBER',
+WHAT CHAR(32) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:WHAT',
+AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:AMOUNT')
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
SELECT * FROM t2;
WHO WEEK WHAT AMOUNT
@@ -268,9 +268,9 @@ Janet 3 Food 18.00
Janet 3 Beer 18.00
CREATE TABLE t3 (
WHO CHAR(12),
-WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER',
-WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT',
-AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT')
+WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER',
+WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT',
+AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT')
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
SELECT * FROM t3;
WHO WEEK WHAT AMOUNT
@@ -284,9 +284,9 @@ Beth 4 Beer 15.00
Janet 4 Car 17.00
CREATE TABLE t4 (
WHO CHAR(12),
-WEEK INT(2) FIELD_FORMAT='WEEK:[3]:NUMBER',
-WHAT CHAR(32) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:WHAT',
-AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:AMOUNT')
+WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER',
+WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT',
+AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT')
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
SELECT * FROM t4;
WHO WEEK WHAT AMOUNT
diff --git a/storage/connect/mysql-test/connect/t/bin.test b/storage/connect/mysql-test/connect/t/bin.test
index 06d73529c00..1e45bcaf93a 100644
--- a/storage/connect/mysql-test/connect/t/bin.test
+++ b/storage/connect/mysql-test/connect/t/bin.test
@@ -19,12 +19,12 @@ SET time_zone='+00:00';
CREATE TABLE t1
(
fig INT(4) NOT NULL FIELD_FORMAT='C',
- name CHAR(10) not null,
+ name CHAR(10) NOT NULL,
birth DATE NOT NULL,
id CHAR(5) NOT NULL FIELD_FORMAT='S',
salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
dept INT(4) NOT NULL FIELD_FORMAT='S'
-) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat';
+) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
SELECT * FROM t1;
--error ER_GET_ERRMSG
@@ -40,12 +40,12 @@ DROP TABLE t1;
CREATE TABLE t1
(
fig INT(4) NOT NULL FIELD_FORMAT='C',
- name CHAR(10) not null,
+ name CHAR(10) NOT NULL,
birth DATE NOT NULL,
id CHAR(5) NOT NULL FIELD_FORMAT='S',
salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
dept INT(4) NOT NULL FIELD_FORMAT='S'
-) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat';
+) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
--error ER_OPEN_AS_READONLY
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
ALTER TABLE t1 READONLY=NO;
diff --git a/storage/connect/mysql-test/connect/t/json.test b/storage/connect/mysql-test/connect/t/json.test
index f89f58534e7..1cc2c054db4 100644
--- a/storage/connect/mysql-test/connect/t/json.test
+++ b/storage/connect/mysql-test/connect/t/json.test
@@ -97,7 +97,7 @@ SELECT * FROM t1 WHERE ISBN = '9782212090819';
CREATE TABLE t2 (
FIRSTNAME CHAR(32),
LASTNAME CHAR(32))
-ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[2]:AUTHOR';
+ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[1]:AUTHOR';
SELECT * FROM t2;
INSERT INTO t2 VALUES('Charles','Dickens');
SELECT * FROM t1;
@@ -162,25 +162,25 @@ DROP TABLE t1;
--echo #
CREATE TABLE t2 (
WHO CHAR(12),
-WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER',
-WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT',
-AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT')
+WEEK INT(2) FIELD_FORMAT='WEEK:[0]:NUMBER',
+WHAT CHAR(32) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:WHAT',
+AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:AMOUNT')
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
SELECT * FROM t2;
CREATE TABLE t3 (
WHO CHAR(12),
-WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER',
-WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT',
-AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT')
+WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER',
+WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT',
+AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT')
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
SELECT * FROM t3;
CREATE TABLE t4 (
WHO CHAR(12),
-WEEK INT(2) FIELD_FORMAT='WEEK:[3]:NUMBER',
-WHAT CHAR(32) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:WHAT',
-AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:AMOUNT')
+WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER',
+WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT',
+AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT')
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
SELECT * FROM t4;
diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp
index fe504bbe422..d4416e188c8 100644
--- a/storage/connect/myutil.cpp
+++ b/storage/connect/myutil.cpp
@@ -13,11 +13,11 @@
/************************************************************************/
#include "my_global.h"
#include <mysql.h>
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#include "osutil.h"
-#endif // !WIN32
+#endif // !__WIN__
#include "global.h"
#include "plgdbsem.h"
diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp
index 2f2f5f38c29..6aaa048de81 100644
--- a/storage/connect/odbconn.cpp
+++ b/storage/connect/odbconn.cpp
@@ -11,7 +11,7 @@
/***********************************************************************/
#include <my_global.h>
#include <m_string.h>
-#if defined(WIN32)
+#if defined(__WIN__)
//nclude <io.h>
//nclude <fcntl.h>
#include <direct.h> // for getcwd
@@ -45,13 +45,13 @@
#include "osutil.h"
-#if defined(WIN32)
+#if defined(__WIN__)
/***********************************************************************/
/* For dynamic load of ODBC32.DLL */
/***********************************************************************/
#pragma comment(lib, "odbc32.lib")
extern "C" HINSTANCE s_hModule; // Saved module handle
-#endif // WIN32
+#endif // __WIN__
int GetConvSize();
@@ -116,16 +116,24 @@ static int GetSQLCType(int type)
/***********************************************************************/
/* TranslateSQLType: translate a SQL Type to a PLG type. */
/***********************************************************************/
-int TranslateSQLType(int stp, int prec, int& len, char& v)
+int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w)
{
int type;
switch (stp) {
+ case SQL_WVARCHAR: // (-9)
+ w = true;
case SQL_VARCHAR: // 12
v = 'V';
+ type = TYPE_STRING;
+ break;
+ case SQL_WCHAR: // (-8)
+ w = true;
case SQL_CHAR: // 1
type = TYPE_STRING;
break;
+ case SQL_WLONGVARCHAR: // (-10)
+ w = true;
case SQL_LONGVARCHAR: // (-1)
v = 'V';
type = TYPE_STRING;
@@ -180,7 +188,6 @@ int TranslateSQLType(int stp, int prec, int& len, char& v)
case SQL_BINARY: // (-2)
case SQL_VARBINARY: // (-3)
case SQL_LONGVARBINARY: // (-4)
-// case SQL_BIT: // (-7)
case SQL_GUID: // (-11)
default:
type = TYPE_ERROR;
@@ -410,6 +417,7 @@ PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop)
PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info)
{
// int i, type, len, prec;
+ bool w = false;
// PCOLRES crp, crpt, crpl, crpp;
PQRYRES qrp;
ODBConn *ocp;
@@ -455,7 +463,7 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info)
type = crpt->Kdata->GetIntValue(i);
len = crpl->Kdata->GetIntValue(i);
prec = crpp->Kdata->GetIntValue(i);
- type = TranslateSQLType(type, prec, len);
+ type = TranslateSQLType(type, prec, len, w);
crpt->Kdata->SetValue(type, i);
// Some data sources do not count prec in length
@@ -1201,15 +1209,15 @@ bool ODBConn::DriverConnect(DWORD Options)
SWORD nResult;
PUCHAR ConnOut = (PUCHAR)PlugSubAlloc(m_G, NULL, MAX_CONNECT_LEN);
UWORD wConnectOption = SQL_DRIVER_COMPLETE;
-#if defined(WIN32)
+#if defined(__WIN__)
HWND hWndTop = GetForegroundWindow();
HWND hWnd = GetParent(hWndTop);
if (hWnd == NULL)
hWnd = GetDesktopWindow();
-#else // !WIN32
+#else // !__WIN__
HWND hWnd = (HWND)1;
-#endif // !WIN32
+#endif // !__WIN__
PGLOBAL& g = m_G;
PDBUSER dup = PlgGetUser(g);
@@ -1222,10 +1230,10 @@ bool ODBConn::DriverConnect(DWORD Options)
SQL_NTS, ConnOut, MAX_CONNECT_LEN,
&nResult, wConnectOption);
-#if defined(WIN32)
+#if defined(__WIN__)
if (hWndTop)
EnableWindow(hWndTop, true);
-#endif // WIN32
+#endif // __WIN__
// If user hit 'Cancel'
if (rc == SQL_NO_DATA_FOUND) {
diff --git a/storage/connect/odbconn.h b/storage/connect/odbconn.h
index 41cc2439354..6a24334f08c 100644
--- a/storage/connect/odbconn.h
+++ b/storage/connect/odbconn.h
@@ -29,9 +29,9 @@
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type
-#if !defined(WIN32)
+#if !defined(__WIN__)
typedef unsigned char *PUCHAR;
-#endif // !WIN32
+#endif // !__WIN__
// Field Flags, used to indicate status of fields
//efine SQL_FIELD_FLAG_DIRTY 0x1
diff --git a/storage/connect/os.h b/storage/connect/os.h
index 8f77a0ad39f..2dc603fdcda 100644
--- a/storage/connect/os.h
+++ b/storage/connect/os.h
@@ -15,16 +15,16 @@ typedef off_t off64_t;
#endif
#endif
-#if defined(WIN32)
+#if defined(__WIN__)
typedef __int64 BIGINT;
-#else // !WIN32
+#else // !__WIN__
typedef longlong BIGINT;
#define FILE_BEGIN SEEK_SET
#define FILE_CURRENT SEEK_CUR
#define FILE_END SEEK_END
-#endif // !WIN32
+#endif // !__WIN__
-#if !defined(WIN32)
+#if !defined(__WIN__)
typedef const void *LPCVOID;
typedef const char *LPCTSTR;
typedef const char *LPCSTR;
@@ -61,6 +61,6 @@ typedef int HANDLE;
#define _MAX_EXT FN_EXTLEN
#define INVALID_HANDLE_VALUE (-1)
#define __stdcall
-#endif /* !WIN32 */
+#endif /* !__WIN__ */
#endif /* _OS_H_INCLUDED */
diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c
index 66985847ce7..2e9e120b0c8 100644
--- a/storage/connect/osutil.c
+++ b/storage/connect/osutil.c
@@ -4,7 +4,7 @@
#include <stdio.h>
#include "osutil.h"
-#ifdef WIN32
+#ifdef __WIN__
my_bool CloseFileHandle(HANDLE h)
{
return !CloseHandle(h);
diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h
index 4dc8f293070..b57d9e20ceb 100644
--- a/storage/connect/plgdbsem.h
+++ b/storage/connect/plgdbsem.h
@@ -389,6 +389,7 @@ typedef struct _qryres *PQRYRES;
typedef struct _colres *PCOLRES;
typedef struct _datpar *PDTP;
typedef struct indx_used *PXUSED;
+typedef struct ha_table_option_struct TOS, *PTOS;
/***********************************************************************/
/* Utility blocks for file and storage. */
@@ -543,11 +544,11 @@ typedef struct _colres {
char Var; /* Type added information */
} COLRES;
-#if defined(WIN32) && !defined(NOEX)
+#if defined(__WIN__) && !defined(NOEX)
#define DllExport __declspec( dllexport )
-#else // !WIN32
+#else // !__WIN__
#define DllExport
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Utility routines. */
@@ -593,6 +594,9 @@ DllExport void NewPointer(PTABS, void *, void *);
DllExport void SetTrc(void);
DllExport char *GetListOption(PGLOBAL, const char *, const char *,
const char *def=NULL);
+DllExport char *GetStringTableOption(PGLOBAL, PTOS, char *, char *);
+DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, char *, bool);
+DllExport int GetIntegerTableOption(PGLOBAL, PTOS, char *, int);
#define MSGID_NONE 0
#define MSGID_CANNOT_OPEN 1
diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp
index 32f6d6f8366..9e236da2d93 100644
--- a/storage/connect/plgdbutl.cpp
+++ b/storage/connect/plgdbutl.cpp
@@ -38,12 +38,12 @@
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#include <errno.h>
#define BIGMEM 1048576 // 1 Megabyte
-#else // !WIN32
+#else // !__WIN__
#include <unistd.h>
#include <fcntl.h>
#if defined(THREAD)
@@ -51,7 +51,7 @@
#endif // THREAD
#include <stdarg.h>
#define BIGMEM 2147483647 // Max int value
-#endif // !WIN32
+#endif // !__WIN__
#include <locale.h>
/***********************************************************************/
@@ -73,11 +73,11 @@
/* Macro or external routine definition */
/***********************************************************************/
#if defined(THREAD)
-#if defined(WIN32)
+#if defined(__WIN__)
extern CRITICAL_SECTION parsec; // Used calling the Flex parser
-#else // !WIN32
+#else // !__WIN__
extern pthread_mutex_t parmut;
-#endif // !WIN32
+#endif // !__WIN__
#endif // THREAD
/***********************************************************************/
@@ -403,11 +403,11 @@ char *SetPath(PGLOBAL g, const char *path)
} // endif path
if (*path != '.') {
-#if defined(WIN32)
+#if defined(__WIN__)
char *s= "\\";
-#else // !WIN32
+#else // !__WIN__
char *s= "/";
-#endif // !WIN32
+#endif // !__WIN__
strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
} else
strcpy(buf, path);
@@ -426,7 +426,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL;
switch (op) { // Determine which part to extract
-#if !defined(UNIX)
+#if defined(__WIN__)
case OP_FDISK: drive = pBuff; break;
#endif // !UNIX
case OP_FPATH: direc = pBuff; break;
@@ -702,19 +702,19 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
/* instruction is included in an Enter/LeaveCriticalSection bracket. */
/*********************************************************************/
#if defined(THREAD)
-#if defined(WIN32)
+#if defined(__WIN__)
EnterCriticalSection((LPCRITICAL_SECTION)&parsec);
-#else // !WIN32
+#else // !__WIN__
pthread_mutex_lock(&parmut);
-#endif // !WIN32
+#endif // !__WIN__
#endif // THREAD
/*int rc =*/ fmdflex(pdp);
#if defined(THREAD)
-#if defined(WIN32)
+#if defined(__WIN__)
LeaveCriticalSection((LPCRITICAL_SECTION)&parsec);
-#else // !WIN32
+#else // !__WIN__
pthread_mutex_unlock(&parmut);
-#endif // !WIN32
+#endif // !__WIN__
#endif // THREAD
if (trace)
@@ -888,7 +888,7 @@ FILE *PlugReopenFile(PGLOBAL g, PFBLOCK fp, LPCSTR md)
/* Close file routine: the purpose of this routine is to avoid */
/* double closing that freeze the system on some Unix platforms. */
/***********************************************************************/
-int PlugCloseFile(PGLOBAL g, PFBLOCK fp, bool all)
+int PlugCloseFile(PGLOBAL g __attribute__((unused)), PFBLOCK fp, bool all)
{
int rc = 0;
@@ -1109,7 +1109,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp)
return amn;
} // end of GetAmName
-#if defined(WIN32) && !defined(NOCATCH)
+#if defined(__WIN__) && !defined(NOCATCH)
/***********************************************************************/
/* GetExceptionDesc: return the description of an exception code. */
/***********************************************************************/
@@ -1197,7 +1197,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e)
return p;
} // end of GetExceptionDesc
-#endif // WIN32 && !NOCATCH
+#endif // __WIN__ && !NOCATCH
/***********************************************************************/
/* PlgDBalloc: allocates or suballocates memory conditionally. */
@@ -1239,7 +1239,7 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp)
if (!mp.Sub) {
// For allocations greater than one fourth of remaining storage
// in the area, do allocate from virtual storage.
-#if defined(WIN32)
+#if defined(__WIN__)
if (mp.Size >= BIGMEM)
mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT, PAGE_READWRITE);
else
@@ -1336,7 +1336,7 @@ void PlgDBfree(MBLOCK& mp)
htrc("PlgDBfree: %p sub=%d size=%d\n", mp.Memp, mp.Sub, mp.Size);
if (!mp.Sub && mp.Memp)
-#if defined(WIN32)
+#if defined(__WIN__)
if (mp.Size >= BIGMEM)
VirtualFree(mp.Memp, 0, MEM_RELEASE);
else
@@ -1532,11 +1532,11 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
bp[0] = buff1; bp[1] = buff2;
for (i = 0; i < 2; i++) {
-#if defined(WIN32)
+#if defined(__WIN__)
h[i]= global_open(g, MSGID_NONE, fn[i], _O_RDONLY | _O_BINARY);
-#else // !WIN32
+#else // !__WIN__
h[i]= global_open(g, MSGOD_NONE, fn[i], O_RDONLY);
-#endif // !WIN32
+#endif // !__WIN__
if (h[i] == -1) {
// if (errno != ENOENT) {
diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c
index 36d115e0096..c0e249adf12 100644
--- a/storage/connect/plugutil.c
+++ b/storage/connect/plugutil.c
@@ -44,7 +44,7 @@
/* */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
#else
#if defined(UNIX) || defined(UNIV_LINUX)
@@ -80,9 +80,9 @@
#include "rcmsg.h"
#endif // NEWMSG
-#if defined(WIN32)
+#if defined(__WIN__)
extern HINSTANCE s_hModule; /* Saved module handle */
-#endif // WIN32
+#endif // __WIN__
#if defined(XMSG)
extern char *msg_path;
@@ -192,7 +192,7 @@ int PlugExit(PGLOBAL g)
/***********************************************************************/
LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
{
-#if !defined(UNIX) && !defined(UNIV_LINUX)
+#if defined(__WIN__)
char drive[_MAX_DRIVE];
#else
char *drive = NULL;
@@ -220,7 +220,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
BOOL PlugIsAbsolutePath(LPCSTR path)
{
-#if defined(WIN32)
+#if defined(__WIN__)
return ((path[0] >= 'a' && path[0] <= 'z') ||
(path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':';
#else
@@ -238,7 +238,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
char direc[_MAX_DIR], defdir[_MAX_DIR], tmpdir[_MAX_DIR];
char fname[_MAX_FNAME];
char ftype[_MAX_EXT];
-#if !defined(UNIX) && !defined(UNIV_LINUX)
+#if defined(__WIN__)
char drive[_MAX_DRIVE], defdrv[_MAX_DRIVE];
#else
char *drive = NULL, *defdrv = NULL;
@@ -255,7 +255,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
return pBuff;
} // endif
-#if !defined(WIN32)
+#if !defined(__WIN__)
if (*FileName == '~') {
if (_fullpath(pBuff, FileName, _MAX_PATH)) {
if (trace > 1)
@@ -266,7 +266,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
return FileName; // Error, return unchanged name
} // endif FileName
-#endif // !WIN32
+#endif // !__WIN__
if (prefix && strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath))
{
@@ -295,11 +295,11 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
if (trace > 1) {
htrc("after _splitpath: FileName=%s\n", FileName);
-#if defined(UNIX) || defined(UNIV_LINUX)
- htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype);
-#else
+#if defined(__WIN__)
htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype);
htrc("defdrv=%s defdir=%s\n", defdrv, defdir);
+#else
+ htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype);
#endif
} // endif trace
@@ -427,7 +427,7 @@ char *PlugGetMessage(PGLOBAL g, int mid)
} // end of PlugGetMessage
#endif // NEWMSG
-#if defined(WIN32)
+#if defined(__WIN__)
/***********************************************************************/
/* Return the line length of the console screen buffer. */
/***********************************************************************/
@@ -439,7 +439,7 @@ short GetLineLength(PGLOBAL g)
return (b) ? coninfo.dwSize.X : 0;
} // end of GetLineLength
-#endif // WIN32
+#endif // __WIN__
/***********************************************************************/
/* Program for memory allocation of work and language areas. */
@@ -502,7 +502,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */
pph = (PPOOLHEADER)memp;
- if (trace > 2)
+ if (trace > 3)
htrc("SubAlloc in %p size=%d used=%d free=%d\n",
memp, size, pph->To_Free, pph->FreeBlk);
@@ -526,7 +526,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
pph->To_Free += size; /* New offset of pool free block */
pph->FreeBlk -= size; /* New size of pool free block */
- if (trace > 2)
+ if (trace > 3)
htrc("Done memp=%p used=%d free=%d\n",
memp, pph->To_Free, pph->FreeBlk);
diff --git a/storage/connect/rcmsg.c b/storage/connect/rcmsg.c
index eafcbdcd81b..75759e03314 100644
--- a/storage/connect/rcmsg.c
+++ b/storage/connect/rcmsg.c
@@ -21,9 +21,9 @@
#include "msgid.h"
#endif // NEWMSG
-#if !defined(WIN32)
+#if !defined(__WIN__)
#define stricmp strcasecmp
-#endif // !WIN32
+#endif // !__WIN__
char *msglang(void);
diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp
index 47f825e965d..60d515a61ca 100644
--- a/storage/connect/reldef.cpp
+++ b/storage/connect/reldef.cpp
@@ -17,7 +17,7 @@
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <sqlext.h>
#else
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
@@ -48,14 +48,15 @@
#include "tabmul.h"
#include "ha_connect.h"
-#if !defined(WIN32)
+#if !defined(__WIN__)
extern handlerton *connect_hton;
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* External function. */
/***********************************************************************/
USETEMP UseTemp(void);
+char *GetPluginDir(void);
/* --------------------------- Class RELDEF -------------------------- */
@@ -246,7 +247,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
/***********************************************************************/
PSZ TABDEF::GetPath(void)
{
- return (Database) ? (PSZ)Database : Hc->GetDataPath();
+ return (Database) ? (PSZ)Database : (Hc) ? Hc->GetDataPath() : NULL;
} // end of GetPath
/***********************************************************************/
@@ -255,7 +256,8 @@ PSZ TABDEF::GetPath(void)
int TABDEF::GetColCatInfo(PGLOBAL g)
{
char *type= GetStringCatInfo(g, "Type", "*");
- int i, loff, poff, nof, nlg;
+ char c, fty, eds;
+ int i, n, loff, poff, nof, nlg;
void *field= NULL;
TABTYPE tc;
PCOLDEF cdp, lcdp= NULL, tocols= NULL;
@@ -322,7 +324,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0)
return -1; // Error, probably unhandled type
- else if (nof)
+ else
loff= cdp->GetOffset();
switch (tc) {
@@ -330,20 +332,52 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
cdp->SetOffset(0); // Not to have shift
case TAB_BIN:
// BIN/VEC are packed by default
- if (nof)
+ if (nof) {
// Field width is the internal representation width
// that can also depend on the column format
- switch (cdp->Fmt ? *cdp->Fmt : 'X') {
- case 'C': break;
+ fty = cdp->Decode ? 'C' : 'X';
+ eds = 0;
+ n = 0;
+
+ if (cdp->Fmt && !cdp->Decode) {
+ for (i = 0; cdp->Fmt[i]; i++) {
+ c = toupper(cdp->Fmt[i]);
+
+ if (isdigit(c))
+ n = (n * 10 + (c - '0'));
+ else if (c == 'L' || c == 'B' || c == 'H')
+ eds = c;
+ else
+ fty = c;
+
+ } // endfor i
+
+ } // endif Fmt
+
+ if (n)
+ nof = n;
+ else switch (fty) {
+ case 'X':
+ if (eds && IsTypeChar(cdp->Buf_Type))
+ nof = sizeof(longlong);
+ else
+ nof= cdp->Clen;
+
+ break;
+ case 'C': break;
case 'R':
- case 'F':
- case 'L':
- case 'I': nof= 4; break;
- case 'D': nof= 8; break;
- case 'S': nof= 2; break;
- case 'T': nof= 1; break;
- default: nof= cdp->Clen;
- } // endswitch Fmt
+ case 'F': nof = sizeof(float); break;
+ case 'I': nof = sizeof(int); break;
+ case 'D': nof = sizeof(double); break;
+ case 'S': nof = sizeof(short); break;
+ case 'T': nof = sizeof(char); break;
+ case 'G': nof = sizeof(longlong); break;
+ default: /* Wrong format */
+ sprintf(g->Message, "Invalid format %c", fty);
+ return -1;
+ } // endswitch fty
+
+ } // endif nof
default:
break;
@@ -369,20 +403,16 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
// not specified (for instance if quoted is specified)
// if ((ending= Hc->GetIntegerOption("Ending")) < 0) {
if ((ending= Hc->GetIntegerOption("Ending")) <= 0) {
-#if defined(WIN32)
- ending= 2;
-#else
- ending= 1;
-#endif
+ ending= (tc == TAB_BIN || tc == TAB_VEC) ? 0 : CRLF;
Hc->SetIntegerOption("Ending", ending);
} // endif ending
// Calculate the default record size
switch (tc) {
case TAB_FIX:
+ case TAB_BIN:
recln= nlg + ending; // + length of line ending
break;
- case TAB_BIN:
case TAB_VEC:
recln= nlg;
@@ -433,20 +463,31 @@ void TABDEF::SetIndexInfo(void)
PTABDEF OEMDEF::GetXdef(PGLOBAL g)
{
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *);
- char c, getname[40] = "Get";
+ char c, soname[_MAX_PATH], getname[40] = "Get";
PTABDEF xdefp;
XGETDEF getdef = NULL;
PCATLG cat = Cat;
-#if defined(WIN32)
+ /*********************************************************************/
+ /* Ensure that the .dll doesn't have a path. */
+ /* This is done to ensure that only approved dll from the system */
+ /* directories are used (to make this even remotely secure). */
+ /*********************************************************************/
+ if (check_valid_path(Module, strlen(Module))) {
+ strcpy(g->Message, "Module cannot contain a path");
+ return NULL;
+ } else
+ PlugSetPath(soname, Module, GetPluginDir());
+
+#if defined(__WIN__)
// Is the DLL already loaded?
- if (!Hdll && !(Hdll = GetModuleHandle(Module)))
+ if (!Hdll && !(Hdll = GetModuleHandle(soname)))
// No, load the Dll implementing the function
- if (!(Hdll = LoadLibrary(Module))) {
+ if (!(Hdll = LoadLibrary(soname))) {
char buf[256];
DWORD rc = GetLastError();
- sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module);
+ sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
@@ -467,10 +508,11 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
FreeLibrary((HMODULE)Hdll);
return NULL;
} // endif getdef
-#else // !WIN32
+#else // !__WIN__
const char *error = NULL;
Dl_info dl_info;
-
+
+#if 0 // Don't know what all this stuff does
// The OEM lib must retrieve exported CONNECT variables
if (dladdr(&connect_hton, &dl_info)) {
if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) {
@@ -484,15 +526,16 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
sprintf(g->Message, "dladdr failed: %s, OEM not supported", SVP(error));
return NULL;
} // endif dladdr
+#endif // 0
// Is the library already loaded?
-// if (!Hdll && !(Hdll = ???))
- // Load the desired shared library
- if (!(Hdll = dlopen(Module, RTLD_LAZY))) {
- error = dlerror();
- sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error));
- return NULL;
- } // endif Hdll
+ if (!Hdll && !(Hdll = dlopen(soname, RTLD_NOLOAD)))
+ // Load the desired shared library
+ if (!(Hdll = dlopen(soname, RTLD_LAZY))) {
+ error = dlerror();
+ sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error));
+ return NULL;
+ } // endif Hdll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
@@ -508,7 +551,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
dlclose(Hdll);
return NULL;
} // endif getdef
-#endif // !WIN32
+#endif // !__WIN__
// Just in case the external Get function does not set error messages
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
@@ -548,7 +591,7 @@ bool OEMDEF::DeleteTableFile(PGLOBAL g)
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
-bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR, int)
{
Module = GetStringCatInfo(g, "Module", "");
Subtype = GetStringCatInfo(g, "Subtype", Module);
@@ -715,7 +758,7 @@ COLDEF::COLDEF(void) : COLCRT()
/***********************************************************************/
/* Define: initialize a column definition from a COLINFO structure. */
/***********************************************************************/
-int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
+int COLDEF::Define(PGLOBAL g, void *, PCOLINFO cfp, int poff)
{
Name = (PSZ)PlugDup(g, cfp->Name);
@@ -745,7 +788,8 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
if (cfp->Datefmt)
Decode = (PSZ)PlugDup(g, cfp->Datefmt);
- } // endif special
+ } else
+ Offset = poff;
if (cfp->Fieldfmt)
Fmt = (PSZ)PlugDup(g, cfp->Fieldfmt);
diff --git a/storage/connect/reldef.h b/storage/connect/reldef.h
index 13bd392b706..4aa29037dfc 100644
--- a/storage/connect/reldef.h
+++ b/storage/connect/reldef.h
@@ -1,7 +1,7 @@
/*************** RelDef H Declares Source Code File (.H) ***************/
/* Name: RELDEF.H Version 1.5 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
/* */
/* This file contains the DEF classes definitions. */
/***********************************************************************/
@@ -89,7 +89,7 @@ class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
bool IsReadOnly(void) {return Read_Only;}
virtual AMT GetDefType(void) {return TYPE_AM_TAB;}
virtual PIXDEF GetIndx(void) {return NULL;}
- virtual void SetIndx(PIXDEF xp) {}
+ virtual void SetIndx(PIXDEF) {}
virtual bool IsHuge(void) {return false;}
const CHARSET_INFO *data_charset() {return m_data_charset;}
@@ -139,11 +139,11 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */
PTABDEF GetXdef(PGLOBAL g);
// Members
-#if defined(WIN32)
+#if defined(__WIN__)
HANDLE Hdll; /* Handle to the external DLL */
-#else // !WIN32
+#else // !__WIN__
void *Hdll; /* Handle for the loaded shared library */
-#endif // !WIN32
+#endif // !__WIN__
PTABDEF Pxdef; /* Pointer to the external TABDEF class */
char *Module; /* Path/Name of the DLL implenting it */
char *Subtype; /* The name of the OEM table sub type */
diff --git a/storage/connect/tabcol.cpp b/storage/connect/tabcol.cpp
index 8f350c6f074..662c0b514cf 100644
--- a/storage/connect/tabcol.cpp
+++ b/storage/connect/tabcol.cpp
@@ -1,7 +1,7 @@
/************* TabCol C++ Functions Source Code File (.CPP) ************/
/* Name: TABCOL.CPP Version 2.7 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */
+/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */
/* This file contains the PlugDB++ XTAB, COLUMN and XORDER methods. */
/***********************************************************************/
@@ -91,7 +91,7 @@ void XTAB::Print(PGLOBAL g, FILE *f, uint n)
/***********************************************************************/
/* Make string output of XTAB contents. */
/***********************************************************************/
-void XTAB::Print(PGLOBAL g, char *ps, uint z)
+void XTAB::Print(PGLOBAL, char *ps, uint z)
{
char buf[128];
int i, n = (int)z - 1;
@@ -125,7 +125,7 @@ COLUMN::COLUMN(LPCSTR name) : Name(name)
/***********************************************************************/
/* COLUMN SetFormat: should never be called. */
/***********************************************************************/
-bool COLUMN::SetFormat(PGLOBAL g, FORMAT& fmt)
+bool COLUMN::SetFormat(PGLOBAL g, FORMAT&)
{
strcpy(g->Message, MSG(NO_FORMAT_COL));
return true;
@@ -154,7 +154,7 @@ void COLUMN::Print(PGLOBAL g, FILE *f, uint n)
/***********************************************************************/
/* Make string output of COLUMN contents. */
/***********************************************************************/
-void COLUMN::Print(PGLOBAL g, char *ps, uint z)
+void COLUMN::Print(PGLOBAL, char *ps, uint z)
{
char buf[80];
diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp
index ba22da52998..a1e58ab3344 100644
--- a/storage/connect/tabdos.cpp
+++ b/storage/connect/tabdos.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -17,7 +17,7 @@
/* Include relevant sections of the System header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <sys\timeb.h> // For testing only
#include <fcntl.h>
@@ -26,7 +26,7 @@
#define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <errno.h>
#include <unistd.h>
@@ -34,7 +34,7 @@
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -112,12 +112,13 @@ DOSDEF::DOSDEF(void)
Maxerr = 0;
ReadMode = 0;
Ending = 0;
+ Teds = 0;
} // end of DOSDEF constructor
/***********************************************************************/
/* DefineAM: define specific AM block values from XDB file. */
/***********************************************************************/
-bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
{
char buf[8];
bool map = (am && (*am == 'M' || *am == 'm'));
@@ -146,6 +147,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Padded = GetBoolCatInfo("Padded", false);
Blksize = GetIntCatInfo("Blksize", 0);
Eof = (GetIntCatInfo("EOF", 0) != 0);
+ Teds = toupper(*GetStringCatInfo(g, "Endian", ""));
} else if (Recfm == RECFM_DBF) {
Maxerr = GetIntCatInfo("Maxerr", 0);
Accept = GetBoolCatInfo("Accept", false);
@@ -206,11 +208,11 @@ void DOSDEF::RemoveOptValues(PGLOBAL g)
// Delete any eventually ill formed non matching optimization file
if (!GetOptFileName(g, filename))
-#if defined(WIN32)
+#if defined(__WIN__)
DeleteFile(filename);
#else // UNIX
remove(filename);
-#endif // WIN32
+#endif // __WIN__
Optimized = 0;
} // end of RemoveOptValues
@@ -251,7 +253,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
/*********************************************************************/
if (sep) {
// Indexes are save in separate files
-#if !defined(UNIX)
+#if defined(__WIN__)
char drive[_MAX_DRIVE];
#else
char *drive = NULL;
@@ -268,7 +270,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
strcat(strcat(fname, "_"), pxdf->GetName());
_makepath(filename, drive, direc, fname, ftype);
PlugSetPath(filename, filename, GetPath());
-#if defined(WIN32)
+#if defined(__WIN__)
if (!DeleteFile(filename))
rc |= (GetLastError() != ERROR_FILE_NOT_FOUND);
#else // UNIX
@@ -285,7 +287,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
// Drop all indexes, delete the common file
PlugSetPath(filename, Ofn, GetPath());
strcat(PlugRemoveType(filename, filename), ftype);
-#if defined(WIN32)
+#if defined(__WIN__)
if (!DeleteFile(filename))
rc = (GetLastError() != ERROR_FILE_NOT_FOUND);
#else // UNIX
@@ -303,7 +305,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
/***********************************************************************/
/* InvalidateIndex: mark all indexes as invalid. */
/***********************************************************************/
-bool DOSDEF::InvalidateIndex(PGLOBAL g)
+bool DOSDEF::InvalidateIndex(PGLOBAL)
{
if (To_Indx)
for (PIXDEF xp = To_Indx; xp; xp = xp->Next)
@@ -954,7 +956,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
#if 0
if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS)
return false;
-#endif // WIN32
+#endif // __WIN__
if (defp->Optimized)
return false; // Already done or to be redone
@@ -1736,15 +1738,16 @@ err:
/***********************************************************************/
/* Make a dynamic index. */
/***********************************************************************/
-bool TDBDOS::InitialyzeIndex(PGLOBAL g, PIXDEF xdp, bool sorted)
+bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
{
int k, rc;
- bool brc, dynamic;
+ volatile bool dynamic;
+ bool brc;
PCOL colp;
PCOLDEF cdp;
PVAL valp;
PXLOAD pxp;
- PKXBASE kxp;
+ volatile PKXBASE kxp;
PKPDEF kdp;
if (!xdp && !(xdp = To_Xdp)) {
@@ -1864,7 +1867,7 @@ int TDBDOS::GetProgCur(void)
/***********************************************************************/
/* RowNumber: return the ordinal number of the current row. */
/***********************************************************************/
-int TDBDOS::RowNumber(PGLOBAL g, bool b)
+int TDBDOS::RowNumber(PGLOBAL g, bool)
{
if (To_Kindex) {
/*******************************************************************/
@@ -1944,7 +1947,7 @@ int TDBDOS::Cardinality(PGLOBAL g)
rec = ((PDOSDEF)To_Def)->Ending;
if (AvgLen <= 0) // No given average estimate
- rec += EstimatedLength(g);
+ rec += EstimatedLength();
else // An estimate was given for the average record length
rec += AvgLen;
@@ -1988,7 +1991,7 @@ int TDBDOS::GetMaxSize(PGLOBAL g)
/* Estimate the number of lines in the table (if not known) by */
/* dividing the file length by minimum record length. */
/*****************************************************************/
- rec = EstimatedLength(g) + ((PDOSDEF)To_Def)->Ending;
+ rec = EstimatedLength() + ((PDOSDEF)To_Def)->Ending;
MaxSize = (len + rec - 1) / rec;
if (trace)
@@ -2005,7 +2008,7 @@ int TDBDOS::GetMaxSize(PGLOBAL g)
/***********************************************************************/
/* DOS EstimatedLength. Returns an estimated minimum line length. */
/***********************************************************************/
-int TDBDOS::EstimatedLength(PGLOBAL g)
+int TDBDOS::EstimatedLength(void)
{
int dep = 0;
PCOLDEF cdp = To_Def->GetCols();
@@ -2023,7 +2026,7 @@ int TDBDOS::EstimatedLength(PGLOBAL g)
/***********************************************************************/
/* DOS tables favor the use temporary files for Update. */
/***********************************************************************/
-bool TDBDOS::IsUsingTemp(PGLOBAL g)
+bool TDBDOS::IsUsingTemp(PGLOBAL)
{
USETEMP utp = UseTemp();
@@ -2183,7 +2186,7 @@ int TDBDOS::ReadDB(PGLOBAL g)
/***********************************************************************/
/* PrepareWriting: Prepare the line to write. */
/***********************************************************************/
-bool TDBDOS::PrepareWriting(PGLOBAL g)
+bool TDBDOS::PrepareWriting(PGLOBAL)
{
if (!Ftype && (Mode == MODE_INSERT || Txfp->GetUseTemp())) {
char *p;
diff --git a/storage/connect/tabdos.h b/storage/connect/tabdos.h
index b7150294e9b..c098886f14b 100644
--- a/storage/connect/tabdos.h
+++ b/storage/connect/tabdos.h
@@ -1,7 +1,7 @@
/*************** TabDos H Declares Source Code File (.H) ***************/
/* Name: TABDOS.H Version 3.3 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */
/* */
/* This file contains the DOS classes declares. */
/***********************************************************************/
@@ -91,6 +91,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
int Maxerr; /* Maximum number of bad records (DBF) */
int ReadMode; /* Specific to DBF */
int Ending; /* Length of end of lines */
+ int Teds; /* Binary table default endian setting */
}; // end of DOSDEF
/***********************************************************************/
@@ -123,11 +124,11 @@ class DllExport TDBDOS : public TDBASE {
// Implementation
virtual AMT GetAmType(void) {return Txfp->GetAmType();}
- virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;}
- virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;}
+ virtual PSZ GetFile(PGLOBAL) {return Txfp->To_File;}
+ virtual void SetFile(PGLOBAL, PSZ fn) {Txfp->To_File = fn;}
virtual void SetAbort(bool b) {Abort = b;}
virtual RECFM GetFtype(void) {return Ftype;}
- virtual bool SkipHeader(PGLOBAL g) {return false;}
+ virtual bool SkipHeader(PGLOBAL) {return false;}
virtual void RestoreNrec(void) {Txfp->SetNrec(1);}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBDOS(g, this);}
@@ -149,7 +150,7 @@ class DllExport TDBDOS : public TDBASE {
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
- virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;}
+ virtual char *GetOpenMode(PGLOBAL, char*) {return NULL;}
virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);}
virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void);
@@ -168,7 +169,7 @@ class DllExport TDBDOS : public TDBASE {
virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);}
// Specific routine
- virtual int EstimatedLength(PGLOBAL g);
+ virtual int EstimatedLength(void);
// Optimization routines
virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp
index 77e47e6f8dd..acd548c86ab 100644
--- a/storage/connect/tabfix.cpp
+++ b/storage/connect/tabfix.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -17,7 +17,7 @@
/* Include relevant section of system dependant header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#include <errno.h>
@@ -25,7 +25,7 @@
#define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <sys/types.h>
#include <sys/stat.h>
@@ -35,7 +35,7 @@
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -54,6 +54,7 @@
extern int num_read, num_there, num_eq[2]; // Statistics
static const longlong M2G = 0x80000000;
static const longlong M4G = (longlong)2 * M2G;
+char BINCOL::Endian = 'H';
/***********************************************************************/
/* External function. */
@@ -67,10 +68,12 @@ USETEMP UseTemp(void);
/***********************************************************************/
TDBFIX::TDBFIX(PDOSDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
{
+ Teds = tdp->Teds; // For BIN tables
} // end of TDBFIX standard constructor
TDBFIX::TDBFIX(PGLOBAL g, PTDBFIX tdbp) : TDBDOS(g, tdbp)
{
+ Teds = tdbp->Teds;
} // end of TDBFIX copy constructor
// Method
@@ -271,7 +274,7 @@ int TDBFIX::RowNumber(PGLOBAL g, bool b)
/***********************************************************************/
/* FIX tables don't use temporary files except if specified as do it. */
/***********************************************************************/
-bool TDBFIX::IsUsingTemp(PGLOBAL g)
+bool TDBFIX::IsUsingTemp(PGLOBAL)
{
// Not ready yet to handle using a temporary file with mapping
// or while deleting from DBF files.
@@ -373,19 +376,94 @@ int TDBFIX::WriteDB(PGLOBAL g)
BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
: DOSCOL(g, cdp, tp, cp, i, am)
{
- Fmt = (cdp->GetFmt()) ? toupper(*cdp->GetFmt()) : 'X';
+ char c, *fmt = cdp->GetFmt();
+
+ Fmt = GetDomain() ? 'C' : 'X';
+ Buff = NULL;
+ Eds = ((PTDBFIX)tp)->Teds;
+ N = 0;
+ M = GetTypeSize(Buf_Type, sizeof(longlong));
+ Lim = 0;
+
+ if (fmt) {
+ for (N = 0, i = 0; fmt[i]; i++) {
+ c = toupper(fmt[i]);
+
+ if (isdigit(c))
+ N = (N * 10 + (c - '0'));
+ else if (c == 'L' || c == 'B' || c == 'H')
+ Eds = c;
+ else
+ Fmt = c;
+
+ } // endfor i
+
+ // M is the size of the source value
+ switch (Fmt) {
+ case 'C': Eds = 0; break;
+ case 'X': break;
+ case 'S': M = sizeof(short); break;
+ case 'T': M = sizeof(char); break;
+ case 'I': M = sizeof(int); break;
+ case 'G': M = sizeof(longlong); break;
+ case 'R': // Real
+ case 'F': M = sizeof(float); break;
+ case 'D': M = sizeof(double); break;
+ default:
+ sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
+ longjmp(g->jumper[g->jump_level], 11);
+ } // endswitch Fmt
+
+ } else if (IsTypeChar(Buf_Type))
+ Eds = 0;
+
+ if (Eds) {
+ // This is a byte order specification
+ if (!N)
+ N = M;
+
+ if (Eds != 'L' && Eds != 'B')
+ Eds = Endian;
+
+ if (N != M || Eds != Endian || IsTypeChar(Buf_Type)) {
+ Buff = (char*)PlugSubAlloc(g, NULL, M);
+ memset(Buff, 0, M);
+ Lim = MY_MIN(N, M);
+ } else
+ Eds = 0; // New format is a no op
+
+ } // endif Eds
+
} // end of BINCOL constructor
/***********************************************************************/
-/* FIXCOL constructor used for copying columns. */
+/* BINCOL constructor used for copying columns. */
/* tdbp is the pointer to the new table descriptor. */
/***********************************************************************/
BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
{
+ Eds = col1->Eds;
Fmt = col1->Fmt;
+ N = col1->N;
+ M = col1->M;
+ Lim = col1->Lim;
} // end of BINCOL copy constructor
/***********************************************************************/
+/* Set Endian according to the host setting. */
+/***********************************************************************/
+void BINCOL::SetEndian(void)
+ {
+ union {
+ short S;
+ char C[sizeof(short)];
+ };
+
+ S = 1;
+ Endian = (C[0] == 1) ? 'L' : 'B';
+ } // end of SetEndian
+
+/***********************************************************************/
/* ReadColumn: what this routine does is to access the last line */
/* read from the corresponding table and extract from it the field */
/* corresponding to this column. */
@@ -416,22 +494,40 @@ void BINCOL::ReadColumn(PGLOBAL g)
/*********************************************************************/
/* Set Value from the line field. */
/*********************************************************************/
+ if (Eds) {
+ for (int i = 0; i < Lim; i++)
+ if (Eds == 'B' && Endian == 'L')
+ Buff[i] = p[N - i - 1];
+ else if (Eds == 'L' && Endian == 'B')
+ Buff[M - i - 1] = p[i];
+ else if (Endian == 'B')
+ Buff[M - i - 1] = p[N - i - 1];
+ else
+ Buff[i] = p[i];
+
+ p = Buff;
+ } // endif Eds
+
switch (Fmt) {
case 'X': // Standard not converted values
- Value->SetBinValue(p);
+ if (Eds && IsTypeChar(Buf_Type))
+ Value->SetValue(*(longlong*)p);
+ else
+ Value->SetBinValue(p);
+
break;
case 'S': // Short integer
- Value->SetValue((int)*(short*)p);
+ Value->SetValue(*(short*)p);
break;
case 'T': // Tiny integer
- Value->SetValue((int)*p);
+ Value->SetValue(*p);
break;
- case 'L': // Long Integer
- strcpy(g->Message, "Format L is deprecated, use I");
- longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer
Value->SetValue(*(int*)p);
break;
+ case 'G': // Large (great) integer
+ Value->SetValue(*(longlong*)p);
+ break;
case 'F': // Float
case 'R': // Real
Value->SetValue((double)*(float*)p);
@@ -483,7 +579,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value
- p = tdbp->To_Line + Deplac;
+ p = (Eds) ? Buff : tdbp->To_Line + Deplac;
/*********************************************************************/
/* Check whether updating is Ok, meaning col value is not too long. */
@@ -493,11 +589,13 @@ void BINCOL::WriteColumn(PGLOBAL g)
switch (Fmt) {
case 'X':
// Standard not converted values
- if (Value->GetBinValue(p, Long, Status)) {
+ if (Eds && IsTypeChar(Buf_Type))
+ *(longlong *)p = Value->GetBigintValue();
+ else if (Value->GetBinValue(p, Long, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), Long);
longjmp(g->jumper[g->jump_level], 31);
- } // endif Fmt
+ } // endif p
break;
case 'S': // Short integer
@@ -520,9 +618,6 @@ void BINCOL::WriteColumn(PGLOBAL g)
*p = (char)n;
break;
- case 'L': // Long Integer
- strcpy(g->Message, "Format L is deprecated, use I");
- longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer
n = Value->GetBigintValue();
@@ -533,9 +628,9 @@ void BINCOL::WriteColumn(PGLOBAL g)
*(int *)p = Value->GetIntValue();
break;
- case 'B': // Large (big) integer
+ case 'G': // Large (great) integer
if (Status)
- *(longlong *)p = (longlong)Value->GetBigintValue();
+ *(longlong *)p = Value->GetBigintValue();
break;
case 'F': // Float
@@ -567,6 +662,21 @@ void BINCOL::WriteColumn(PGLOBAL g)
longjmp(g->jumper[g->jump_level], 11);
} // endswitch Fmt
+ if (Eds && Status) {
+ p = tdbp->To_Line + Deplac;
+
+ for (int i = 0; i < Lim; i++)
+ if (Eds == 'B' && Endian == 'L')
+ p[N - i - 1] = Buff[i];
+ else if (Eds == 'L' && Endian == 'B')
+ p[i] = Buff[M - i - 1];
+ else if (Endian == 'B')
+ p[N - i - 1] = Buff[M - i - 1];
+ else
+ p[i] = Buff[i];
+
+ } // endif Eds
+
} // end of WriteColumn
/* ------------------------ End of TabFix ---------------------------- */
diff --git a/storage/connect/tabfix.h b/storage/connect/tabfix.h
index 7d5b964da2a..49956ba0711 100644
--- a/storage/connect/tabfix.h
+++ b/storage/connect/tabfix.h
@@ -1,7 +1,7 @@
/*************** TabDos H Declares Source Code File (.H) ***************/
-/* Name: TABFIX.H Version 2.3 */
+/* Name: TABFIX.H Version 2.4 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
+/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */
/* */
/* This file contains the TDBFIX and (FIX/BIN)COL classes declares. */
/***********************************************************************/
@@ -12,7 +12,7 @@
typedef class FIXCOL *PFIXCOL;
typedef class BINCOL *PBINCOL;
-typedef class TXTFAM *PTXF;
+typedef class TXTFAM *PTXF;
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
@@ -53,7 +53,8 @@ class DllExport TDBFIX : public TDBDOS {
protected:
virtual bool PrepareWriting(PGLOBAL g) {return false;}
- // Members are inherited from TDBDOS
+ // Members
+ char Teds; /* Binary table default endian setting */
}; // end of class TDBFIX
/***********************************************************************/
@@ -68,17 +69,29 @@ class DllExport BINCOL : public DOSCOL {
BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
- virtual int GetAmType(void) {return TYPE_AM_BIN;}
+ virtual int GetAmType(void) {return TYPE_AM_BIN;}
+ int GetDeplac(void) {return Deplac;}
+ int GetFileSize(void)
+ {return N ? N : GetTypeSize(Buf_Type, Long);}
// Methods
- virtual void ReadColumn(PGLOBAL g);
- virtual void WriteColumn(PGLOBAL g);
+ virtual void ReadColumn(PGLOBAL g);
+ virtual void WriteColumn(PGLOBAL g);
+
+ // Static
+ static void SetEndian(void);
protected:
BINCOL(void) {} // Default constructor not to be used
// Members
- char Fmt; // The column numeric format
+ static char Endian; // The host endian setting (L or B)
+ char *Buff; // Utility buffer
+ char Eds; // The file endian setting
+ char Fmt; // The converted value format
+ int N; // The number of bytes in the file
+ int M; // The buffer type size
+ int Lim; // Min(N,M)
}; // end of class BINCOL
/***********************************************************************/
diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp
index d5f8dc50a89..015f8d93b15 100644
--- a/storage/connect/tabfmt.cpp
+++ b/storage/connect/tabfmt.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2001 - 2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2001 - 2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -20,7 +20,7 @@
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#include <errno.h>
@@ -102,14 +102,14 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
} // endif info
// num_max = atoi(p+1); // Max num of record to test
-#if defined(WIN32)
+#if defined(__WIN__)
if (sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6))
dechar = '.';
else
dechar = ',';
-#else // !WIN32
+#else // !__WIN__
dechar = '.';
-#endif // !WIN32
+#endif // !__WIN__
if (trace)
htrc("File %s sep=%c q=%c hdr=%d mxr=%d\n",
@@ -147,7 +147,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
if (fgets(buf, sizeof(buf), infile)) {
n = strlen(buf) + 1;
buf[n - 2] = '\0';
-#if defined(UNIX)
+#if !defined(__WIN__)
// The file can be imported from Windows
if (buf[n - 3] == '\r')
buf[n - 3] = 0;
@@ -204,7 +204,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
if (fgets(buf, sizeof(buf), infile)) {
n = strlen(buf);
buf[n - 1] = '\0';
-#if defined(UNIX)
+#if !defined(__WIN__)
// The file can be imported from Windows
if (buf[n - 2] == '\r')
buf[n - 2] = 0;
@@ -625,7 +625,7 @@ bool TDBCSV::CheckErr(void)
/***********************************************************************/
/* CSV EstimatedLength. Returns an estimated minimum line length. */
/***********************************************************************/
-int TDBCSV::EstimatedLength(PGLOBAL g)
+int TDBCSV::EstimatedLength(void)
{
int n = 0;
PCOLDEF cdp;
@@ -1118,7 +1118,7 @@ PCOL TDBFMT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/* FMT EstimatedLength. Returns an estimated minimum line length. */
/* The big problem here is how can we astimated that minimum ? */
/***********************************************************************/
-int TDBFMT::EstimatedLength(PGLOBAL g)
+int TDBFMT::EstimatedLength(void)
{
// This is rather stupid !!!
return ((PDOSDEF)To_Def)->GetEnding() + (int)((Lrecl / 10) + 1);
diff --git a/storage/connect/tabfmt.h b/storage/connect/tabfmt.h
index 8a1e1f17561..ce80a276cdc 100644
--- a/storage/connect/tabfmt.h
+++ b/storage/connect/tabfmt.h
@@ -75,7 +75,7 @@ class TDBCSV : public TDBDOS {
virtual int ReadBuffer(PGLOBAL g); // Physical file read
// Specific routines
- virtual int EstimatedLength(PGLOBAL g);
+ virtual int EstimatedLength(void);
virtual bool SkipHeader(PGLOBAL g);
virtual bool CheckErr(void);
@@ -157,7 +157,7 @@ class TDBFMT : public TDBCSV {
virtual int ReadBuffer(PGLOBAL g); // Physical file read
// Specific routines
- virtual int EstimatedLength(PGLOBAL g);
+ virtual int EstimatedLength(void);
protected:
virtual bool PrepareWriting(PGLOBAL g)
diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp
index 0231b369fc1..fafba6228b9 100644
--- a/storage/connect/tabjson.cpp
+++ b/storage/connect/tabjson.cpp
@@ -59,16 +59,15 @@ typedef struct _jncol {
/* JSONColumns: construct the result blocks containing the description */
/* of all the columns of a table contained inside a JSON file. */
/***********************************************************************/
-PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
- int pretty, int lrecl, int lvl, bool info)
+PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
{
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING};
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT};
static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0};
- char filename[_MAX_PATH], colname[65], fmt[129];
- int i, j, n = 0;
+ char *fn, colname[65], fmt[129];
+ int i, j, lvl, n = 0;
int ncol = sizeof(buftyp) / sizeof(int);
PVAL valp;
JCOL jcol;
@@ -78,37 +77,42 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
PJVAL jvp;
PJOB row;
PJDEF tdp;
- TDBJSN *tjnp;
- PJTDB tjsp;
+ TDBJSN *tjnp = NULL;
+ PJTDB tjsp = NULL;
PQRYRES qrp;
PCOLRES crp;
+ jcol.Name = jcol.Fmt = NULL;
+
if (info) {
length[0] = 128;
length[7] = 256;
goto skipit;
} // endif info
- if (trace)
- htrc("File %s pretty=%d lvl=%d lrecl=%d\n",
- SVP(fn), pretty, lvl, lrecl);
-
/*********************************************************************/
/* Open the input file. */
/*********************************************************************/
- if (!fn) {
+ if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) {
strcpy(g->Message, MSG(MISSING_FNAME));
return NULL;
- } else
- PlugSetPath(filename, fn, dp);
+ } else {
+ lvl = GetIntegerTableOption(g, topt, "Level", 0);
+ lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl;
+ } // endif fn
tdp = new(g) JSONDEF;
- tdp->Database = dp;
- tdp->Fn = filename;
- tdp->Objname = objn;
- tdp->Pretty = pretty;
+ tdp->Fn = fn;
+ tdp->Database = SetPath(g, db);
+ tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
+ tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
+ tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
+
+ if (trace)
+ htrc("File %s objname=%s pretty=%d lvl=%d\n",
+ tdp->Fn, tdp->Objname, tdp->Pretty, lvl);
- if (pretty == 2) {
+ if (tdp->Pretty == 2) {
tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp));
if (tjsp->MakeDocument(g))
@@ -116,13 +120,12 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL;
} else {
- if (!lrecl) {
- sprintf(g->Message, "LRECL must be specified for pretty=%d", pretty);
+ if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) {
+ sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty);
return NULL;
} // endif lrecl
- tdp->Lrecl = lrecl;
- tdp->Ending = CRLF;
+ tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF);
tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp));
tjnp->SetMode(MODE_READ);
@@ -263,7 +266,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
jcp->Found = false;
} // endfor jcp
- if (pretty != 2) {
+ if (tdp->Pretty != 2) {
// Read next record
switch (tjnp->ReadDB(g)) {
case RC_EF:
@@ -283,7 +286,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
} // endor i
- if (pretty != 2)
+ if (tdp->Pretty != 2)
tjnp->CloseDB(g);
skipit:
@@ -339,7 +342,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
return qrp;
err:
- if (pretty != 2)
+ if (tdp->Pretty != 2)
tjnp->CloseDB(g);
return NULL;
@@ -354,22 +357,21 @@ JSONDEF::JSONDEF(void)
Xcol = NULL;
Pretty = 2;
Limit = 1;
- Level = 0;
- ReadMode = 0;
+ Base = 0;
Strict = false;
} // end of JSONDEF constructor
/***********************************************************************/
/* DefineAM: define specific AM block values. */
/***********************************************************************/
-bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
{
Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT);
Objname = GetStringCatInfo(g, "Object", NULL);
Xcol = GetStringCatInfo(g, "Expand", NULL);
Pretty = GetIntCatInfo("Pretty", 2);
- Level = GetIntCatInfo("Level", 0);
Limit = GetIntCatInfo("Limit", 10);
+ Base = GetIntCatInfo("Base", 0) ? 1 : 0;
return DOSDEF::DefineAM(g, "DOS", poff);
} // end of DefineAM
@@ -438,6 +440,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
Xcol = tdp->Xcol;
Limit = tdp->Limit;
Pretty = tdp->Pretty;
+ B = tdp->Base ? 1 : 0;
Strict = tdp->Strict;
} else {
Jmode = MODE_OBJECT;
@@ -445,11 +448,12 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
Xcol = NULL;
Limit = 1;
Pretty = 0;
+ B = 0;
Strict = false;
} // endif tdp
Fpos = -1;
- N = 0;
+ N = M = 0;
NextSame = 0;
SameRow = 0;
Xval = -1;
@@ -467,10 +471,12 @@ TDBJSN::TDBJSN(TDBJSN *tdbp) : TDBDOS(NULL, tdbp)
Xcol = tdbp->Xcol;
Fpos = tdbp->Fpos;
N = tdbp->N;
+ M = tdbp->M;
Limit = tdbp->Limit;
NextSame = tdbp->NextSame;
SameRow = tdbp->SameRow;
Xval = tdbp->Xval;
+ B = tdbp->B;
Pretty = tdbp->Pretty;
Strict = tdbp->Strict;
Comma = tdbp->Comma;
@@ -506,7 +512,7 @@ PCOL TDBJSN::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/
/* InsertSpecialColumn: Put a special column ahead of the column list.*/
/***********************************************************************/
-PCOL TDBJSN::InsertSpecialColumn(PGLOBAL g, PCOL colp)
+PCOL TDBJSN::InsertSpecialColumn(PCOL colp)
{
if (!colp->IsSpecial())
return NULL;
@@ -561,7 +567,7 @@ PJSON TDBJSN::FindRow(PGLOBAL g)
jsp->GetObject()->GetValue(objpath) : NULL;
} else if (objpath[strlen(objpath)-1] == ']') {
val = (jsp->GetType() == TYPE_JAR) ?
- jsp->GetArray()->GetValue(atoi(objpath+1) - 1) : NULL;
+ jsp->GetArray()->GetValue(atoi(objpath+1) - B) : NULL;
} else
val = NULL;
@@ -617,11 +623,11 @@ bool TDBJSN::SkipHeader(PGLOBAL g)
return true;
#endif // _DEBUG
-#if defined(WIN32)
+#if defined(__WIN__)
#define Ending 2
-#else // !WIN32
+#else // !__WIN__
#define Ending 1
-#endif // !WIN32
+#endif // !__WIN__
if (Pretty == 1) {
if (Mode == MODE_INSERT || Mode == MODE_DELETE) {
@@ -647,6 +653,7 @@ int TDBJSN::ReadDB(PGLOBAL g)
if (NextSame) {
SameRow = NextSame;
NextSame = 0;
+ M++;
return RC_OK;
} else if ((rc = TDBDOS::ReadDB(g)) == RC_OK)
if (!IsRead() && ((rc = ReadBuffer(g)) != RC_OK)) {
@@ -658,6 +665,7 @@ int TDBJSN::ReadDB(PGLOBAL g)
Row = FindRow(g);
SameRow = 0;
Fpos++;
+ M = 1;
rc = RC_OK;
} // endif's
@@ -706,7 +714,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
val->SetValue(arp);
val = new(g) JVALUE;
- i = atoi(objpath+1) - 1;
+ i = atoi(objpath+1) - B;
arp->SetValue(g, val, i);
arp->InitArray(g);
} else {
@@ -854,8 +862,8 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
return true;
else if (jnp->Op != OP_EXP) {
if (b) {
- // Return 1st value
- jnp->Rank = 1;
+ // Return 1st value (B is the index base)
+ jnp->Rank = Tjp->B;
jnp->Op = OP_EQ;
} else if (!Value->IsTypeNum()) {
jnp->CncVal = AllocateValue(g, (void*)", ", TYPE_STRING);
@@ -866,13 +874,9 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
} // endif OP
} else if (dg) {
- if (atoi(p) > 0) {
- // Return nth value
- jnp->Rank = atoi(p);
- jnp->Op = OP_EQ;
- } else // Ignore array
- jnp->Op = OP_NULL;
-
+ // Return nth value
+ jnp->Rank = atoi(p) - Tjp->B;
+ jnp->Op = OP_EQ;
} else if (n == 1) {
// Set the Op value;
switch (*p) {
@@ -1116,16 +1120,12 @@ PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i)
arp = (PJAR)row;
if (!Nodes[i].Key) {
- if (Nodes[i].Op != OP_NULL) {
- if (Nodes[i].Rank) {
- val = arp->GetValue(Nodes[i].Rank - 1);
- } else if (Nodes[i].Op == OP_EXP) {
- return ExpandArray(g, arp, i);
- } else
- return CalculateArray(g, arp, i);
-
- } else
- val = NULL;
+ if (Nodes[i].Op == OP_EQ)
+ val = arp->GetValue(Nodes[i].Rank);
+ else if (Nodes[i].Op == OP_EXP)
+ return ExpandArray(g, arp, i);
+ else
+ return CalculateArray(g, arp, i);
} else if (i < Nod-1) {
strcpy(g->Message, "Unexpected array");
@@ -1287,16 +1287,12 @@ PJSON JSONCOL::GetRow(PGLOBAL g)
break;
case TYPE_JAR:
if (!Nodes[i].Key) {
- if (Nodes[i].Op != OP_NULL) {
- arp = (PJAR)row;
-
- if (Nodes[i].Rank)
- val = arp->GetValue(Nodes[i].Rank - 1);
- else
- val = arp->GetValue(Nodes[i].Rx);
+ arp = (PJAR)row;
- } else
- val = NULL;
+ if (Nodes[i].Op == OP_EQ)
+ val = arp->GetValue(Nodes[i].Rank);
+ else
+ val = arp->GetValue(Nodes[i].Rx);
} else {
strcpy(g->Message, "Unexpected array");
@@ -1388,8 +1384,8 @@ void JSONCOL::WriteColumn(PGLOBAL g)
} // endif jsp
if (arp) {
- if (Nod > 1 && Nodes[Nod-2].Rank)
- arp->SetValue(g, new(g) JVALUE(jsp), Nodes[Nod-2].Rank-1);
+ if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
+ arp->SetValue(g, new(g) JVALUE(jsp), Nodes[Nod-2].Rank);
else
arp->AddValue(g, new(g) JVALUE(jsp));
@@ -1409,8 +1405,8 @@ void JSONCOL::WriteColumn(PGLOBAL g)
case TYPE_INT:
case TYPE_DOUBLE:
if (arp) {
- if (Nodes[Nod-1].Rank)
- arp->SetValue(g, new(g) JVALUE(g, Value), Nodes[Nod-1].Rank-1);
+ if (Nodes[Nod-1].Op == OP_EQ)
+ arp->SetValue(g, new(g) JVALUE(g, Value), Nodes[Nod-1].Rank);
else
arp->AddValue(g, new(g) JVALUE(g, Value));
@@ -1486,7 +1482,7 @@ int TDBJSON::MakeNewDoc(PGLOBAL g)
/***********************************************************************/
int TDBJSON::MakeDocument(PGLOBAL g)
{
- char *p, *memory, *objpath, *key;
+ char *p, *memory, *objpath, *key = NULL;
int len, i = 0;
MODE mode = Mode;
PJSON jsp;
@@ -1560,7 +1556,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
arp = jsp->GetArray();
objp = NULL;
- i = atoi(objpath+1) - 1;
+ i = atoi(objpath+1) - B;
val = arp->GetValue(i);
if (!val) {
@@ -1646,7 +1642,7 @@ void TDBJSON::ResetSize(void)
/***********************************************************************/
/* TDBJSON is not indexable. */
/***********************************************************************/
-int TDBJSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
+int TDBJSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool)
{
if (pxdf) {
strcpy(g->Message, "JSON not indexable when pretty = 2");
@@ -1677,7 +1673,7 @@ int TDBJSON::GetRecpos(void)
/***********************************************************************/
/* Set the position in the table. */
/***********************************************************************/
-bool TDBJSON::SetRecpos(PGLOBAL g, int recpos)
+bool TDBJSON::SetRecpos(PGLOBAL, int recpos)
{
#if 0
union {
@@ -1739,7 +1735,7 @@ bool TDBJSON::OpenDB(PGLOBAL g)
/***********************************************************************/
/* ReadDB: Data Base read routine for JSON access method. */
/***********************************************************************/
-int TDBJSON::ReadDB(PGLOBAL g)
+int TDBJSON::ReadDB(PGLOBAL)
{
int rc;
@@ -1748,6 +1744,7 @@ int TDBJSON::ReadDB(PGLOBAL g)
if (NextSame) {
SameRow = NextSame;
NextSame = false;
+ M++;
rc = RC_OK;
} else if (++Fpos < (signed)Doc->size()) {
Row = Doc->GetValue(Fpos);
@@ -1756,6 +1753,7 @@ int TDBJSON::ReadDB(PGLOBAL g)
Row = ((PJVAL)Row)->GetJson();
SameRow = 0;
+ M = 1;
rc = RC_OK;
} else
rc = RC_EF;
@@ -1857,11 +1855,8 @@ void TDBJSON::CloseDB(PGLOBAL g)
/***********************************************************************/
TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
{
- Fn = tdp->GetFn();
- Objn = tdp->Objname;
- Pretty = tdp->Pretty;
- Lrecl = tdp->Lrecl;
- lvl = tdp->Level;
+ Topt = tdp->GetTopt();
+ Db = (char*)tdp->GetDB();
} // end of TDBJCL constructor
/***********************************************************************/
@@ -1869,8 +1864,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
/***********************************************************************/
PQRYRES TDBJCL::GetResult(PGLOBAL g)
{
- return JSONColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, Objn,
- Pretty, Lrecl, lvl, false);
+ return JSONColumns(g, Db, Topt, false);
} // end of GetResult
/* --------------------------- End of json --------------------------- */
diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h
index 10b9a9a9cc3..4505d30a21c 100644
--- a/storage/connect/tabjson.h
+++ b/storage/connect/tabjson.h
@@ -36,8 +36,7 @@ class JSONDEF : public DOSDEF { /* Table description */
friend class TDBJSON;
friend class TDBJSN;
friend class TDBJCL;
- friend PQRYRES JSONColumns(PGLOBAL, char *, const char *, char *,
- int, int, int, bool);
+ friend PQRYRES JSONColumns(PGLOBAL, char*, PTOS, bool);
public:
// Constructor
JSONDEF(void);
@@ -57,6 +56,7 @@ class JSONDEF : public DOSDEF { /* Table description */
int Limit; /* Limit of multiple values */
int Pretty; /* Depends on file structure */
int Level; /* Used for catalog table */
+ int Base; /* Tne array index base */
bool Strict; /* Strict syntax checking */
}; // end of JSONDEF
@@ -82,9 +82,9 @@ class TDBJSN : public TDBDOS {
// Methods
virtual PTDB CopyOne(PTABS t);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
- virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp);
+ virtual PCOL InsertSpecialColumn(PCOL colp);
virtual int RowNumber(PGLOBAL g, bool b = FALSE)
- {return (b) ? N : Fpos + 1;}
+ {return (b) ? M : N;}
// Database routines
virtual int Cardinality(PGLOBAL g);
@@ -106,13 +106,14 @@ class TDBJSN : public TDBDOS {
char *Objname; // The table object name
char *Xcol; // Name of expandable column
int Fpos; // The current row index
-//int Spos; // DELETE start index
int N; // The current Rownum
+ int M; // Index of multiple value
int Limit; // Limit of multiple values
int Pretty; // Depends on file structure
int NextSame; // Same next row
int SameRow; // Same row nb
int Xval; // Index of expandable array
+ int B; // Array index base
bool Strict; // Strict syntax checking
bool Comma; // Row has final comma
}; // end of class TDBJSN
@@ -224,11 +225,6 @@ class TDBJCL : public TDBCAT {
virtual PQRYRES GetResult(PGLOBAL g);
// Members
-//char *Dp;
- const char *Fn;
- char *Objn;
- int Pretty;
- int Lrecl;
- int lvl;
+ PTOS Topt;
+ char *Db;
}; // end of class TDBJCL
-
diff --git a/storage/connect/table.cpp b/storage/connect/table.cpp
index d163c443cd5..933e072c1bb 100644
--- a/storage/connect/table.cpp
+++ b/storage/connect/table.cpp
@@ -1,7 +1,7 @@
/************** Table C++ Functions Source Code File (.CPP) ************/
/* Name: TABLE.CPP Version 2.7 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */
/* */
/* This file contains the TBX, TDB and OPJOIN classes functions. */
/***********************************************************************/
@@ -74,7 +74,7 @@ TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum)
/***********************************************************************/
/* RowNumber: returns the current row ordinal number. */
/***********************************************************************/
-int TDB::RowNumber(PGLOBAL g, bool b)
+int TDB::RowNumber(PGLOBAL g, bool)
{
sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType()));
return 0;
@@ -122,7 +122,7 @@ void TDB::Print(PGLOBAL g, FILE *f, uint n)
} // end of Print
-void TDB::Print(PGLOBAL g, char *ps, uint z)
+void TDB::Print(PGLOBAL, char *ps, uint)
{
sprintf(ps, "R%d.%s", Tdb_No, Name);
} // end of Print
@@ -263,7 +263,7 @@ PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num)
/***********************************************************************/
/* InsertSpecialColumn: Put a special column ahead of the column list.*/
/***********************************************************************/
-PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp)
+PCOL TDBASE::InsertSpecialColumn(PCOL colp)
{
if (!colp->IsSpecial())
return NULL;
@@ -327,7 +327,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
return NULL;
} // endif's name
- if (!(colp = InsertSpecialColumn(g, colp))) {
+ if (!(colp = InsertSpecialColumn(colp))) {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
return NULL;
} // endif Insert
@@ -338,7 +338,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
/***********************************************************************/
/* ResetTableOpt: Wrong for this table type. */
/***********************************************************************/
-int TDBASE::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
+int TDBASE::ResetTableOpt(PGLOBAL g, bool, bool)
{
strcpy(g->Message, "This table is not indexable");
return RC_INFO;
@@ -365,7 +365,7 @@ void TDBASE::ResetKindex(PGLOBAL g, PKXBASE kxp)
/***********************************************************************/
/* SetRecpos: Replace the table at the specified position. */
/***********************************************************************/
-bool TDBASE::SetRecpos(PGLOBAL g, int recpos)
+bool TDBASE::SetRecpos(PGLOBAL g, int)
{
strcpy(g->Message, MSG(SETRECPOS_NIY));
return true;
@@ -386,7 +386,7 @@ void TDBASE::PrintAM(FILE *f, char *m)
/* Two questions here: exact meaning of U_J_INT ? */
/* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */
/***********************************************************************/
-void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2)
+void TDBASE::MarkDB(PGLOBAL, PTDB tdb2)
{
if (trace)
htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2);
@@ -453,7 +453,7 @@ bool TDBCAT::Initialize(PGLOBAL g)
/***********************************************************************/
/* CAT: Get the number of properties. */
/***********************************************************************/
-int TDBCAT::GetMaxSize(PGLOBAL g)
+int TDBCAT::GetMaxSize(PGLOBAL g __attribute__((unused)))
{
if (MaxSize < 0) {
// if (Initialize(g))
@@ -528,7 +528,7 @@ bool TDBCAT::InitCol(PGLOBAL g)
/***********************************************************************/
/* SetRecpos: Replace the table at the specified position. */
/***********************************************************************/
-bool TDBCAT::SetRecpos(PGLOBAL g, int recpos)
+bool TDBCAT::SetRecpos(PGLOBAL, int recpos)
{
N = recpos - 1;
return false;
@@ -537,7 +537,7 @@ bool TDBCAT::SetRecpos(PGLOBAL g, int recpos)
/***********************************************************************/
/* Data Base read routine for CAT access method. */
/***********************************************************************/
-int TDBCAT::ReadDB(PGLOBAL g)
+int TDBCAT::ReadDB(PGLOBAL)
{
return (++N < Qrp->Nblin) ? RC_OK : RC_EF;
} // end of ReadDB
@@ -554,7 +554,7 @@ int TDBCAT::WriteDB(PGLOBAL g)
/***********************************************************************/
/* Data Base delete line routine for CAT access methods. */
/***********************************************************************/
-int TDBCAT::DeleteDB(PGLOBAL g, int irc)
+int TDBCAT::DeleteDB(PGLOBAL g, int)
{
strcpy(g->Message, "Delete not enabled for CAT tables");
return RC_FX;
@@ -563,7 +563,7 @@ int TDBCAT::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/
/* Data Base close routine for WMI access method. */
/***********************************************************************/
-void TDBCAT::CloseDB(PGLOBAL g)
+void TDBCAT::CloseDB(PGLOBAL)
{
// Nothing to do
} // end of CloseDB
@@ -584,7 +584,7 @@ CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n)
/***********************************************************************/
/* Read the next Data Source elements. */
/***********************************************************************/
-void CATCOL::ReadColumn(PGLOBAL g)
+void CATCOL::ReadColumn(PGLOBAL)
{
// Get the value of the Name or Description property
if (Crp->Kdata)
diff --git a/storage/connect/tabmac.cpp b/storage/connect/tabmac.cpp
index f072465ced5..e6e2abb54e2 100644
--- a/storage/connect/tabmac.cpp
+++ b/storage/connect/tabmac.cpp
@@ -3,12 +3,12 @@
/* From the article and sample code by Khalid Shaikh. */
/* TABMAC: virtual table to get the list of MAC addresses. */
/***********************************************************************/
-#if defined(WIN32)
+#if defined(__WIN__)
#include "my_global.h"
//#include <iphlpapi.h>
-#else // !WIN32
-#error This is a WIN32 only table type
-#endif // !WIN32
+#else // !__WIN__
+#error This is a WINDOWS only table type
+#endif // !__WIN__
#include "global.h"
#include "plgdbsem.h"
//#include "catalog.h"
diff --git a/storage/connect/tabmac.h b/storage/connect/tabmac.h
index 5e6c98d68fb..f9a66e82eaa 100644
--- a/storage/connect/tabmac.h
+++ b/storage/connect/tabmac.h
@@ -1,11 +1,11 @@
// TABMAC.H Olivier Bertrand 2011-2012
// MAC: virtual table to Get Mac Addresses via GetAdaptersInfo
-#if defined(WIN32)
+#if defined(__WIN__)
#include <windows.h>
#include <iphlpapi.h>
-#else // !WIN32
-#error This is a WIN32 only table TYPE
-#endif // !WIN32
+#else // !__WIN__
+#error This is a WINDOWS only table TYPE
+#endif // !__WIN__
/***********************************************************************/
/* Definitions. */
diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp
index 94950584c9b..3008ca1b8ca 100644
--- a/storage/connect/tabmul.cpp
+++ b/storage/connect/tabmul.cpp
@@ -37,7 +37,7 @@
/* Include relevant section of system dependant header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <stdlib.h>
#include <stdio.h>
#if defined(__BORLANDC__)
@@ -145,7 +145,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
/*******************************************************************/
/* To_File is a multiple name with special characters */
/*******************************************************************/
-#if defined(WIN32)
+#if defined(__WIN__)
char drive[_MAX_DRIVE], direc[_MAX_DIR];
WIN32_FIND_DATA FileData;
HANDLE hSearch;
@@ -196,7 +196,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
return true;
} // endif FindClose
-#else // !WIN32
+#else // !__WIN__
struct stat fileinfo;
char fn[FN_REFLEN], direc[FN_REFLEN], pattern[FN_HEADLEN], ftype[FN_EXTLEN];
DIR *dir;
@@ -249,7 +249,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
// Close the dir handle.
closedir(dir);
-#endif // !WIN32
+#endif // !__WIN__
} else {
/*******************************************************************/
@@ -269,7 +269,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
p = filename + strlen(filename) - 1;
-#if defined(UNIX)
+#if !defined(__WIN__)
// Data files can be imported from Windows (having CRLF)
if (*p == '\n' || *p == '\r') {
// is this enough for Unix ???
@@ -297,7 +297,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
} // endif Mul
-#if defined(WIN32)
+#if defined(__WIN__)
suite:
#endif
@@ -561,7 +561,7 @@ int TDBMUL::WriteDB(PGLOBAL g)
/***********************************************************************/
/* Data Base delete line routine for MUL access method. */
/***********************************************************************/
-int TDBMUL::DeleteDB(PGLOBAL g, int irc)
+int TDBMUL::DeleteDB(PGLOBAL g, int)
{
// When implementing DELETE_MODE InitFileNames must be updated to
// eliminate CRLF under Windows if the file is read in binary.
@@ -586,7 +586,7 @@ void TDBMUL::CloseDB(PGLOBAL g)
/***********************************************************************/
/* DefineAM: define specific AM block values from XDB file. */
/***********************************************************************/
-bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR, int)
{
Desc = Fn = GetStringCatInfo(g, "Filename", NULL);
Incl = (GetIntCatInfo("Subdir", 0) != 0);
@@ -597,7 +597,7 @@ bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
-PTDB DIRDEF::GetTable(PGLOBAL g, MODE m)
+PTDB DIRDEF::GetTable(PGLOBAL g, MODE)
{
#if 0
if (Huge)
@@ -620,17 +620,17 @@ TDBDIR::TDBDIR(PDIRDEF tdp) : TDBASE(tdp)
{
To_File = tdp->Fn;
iFile = 0;
-#if defined(WIN32)
+#if defined(__WIN__)
memset(&FileData, 0, sizeof(_finddata_t));
Hsearch = -1;
*Drive = '\0';
-#else // !WIN32
+#else // !__WIN__
memset(&Fileinfo, 0, sizeof(struct stat));
Entry = NULL;
Dir = NULL;
Done = false;
*Pattern = '\0';
-#endif // !WIN32
+#endif // !__WIN__
*Fpath = '\0';
*Direc = '\0';
*Fname = '\0';
@@ -641,17 +641,17 @@ TDBDIR::TDBDIR(PTDBDIR tdbp) : TDBASE(tdbp)
{
To_File = tdbp->To_File;
iFile = tdbp->iFile;
-#if defined(WIN32)
+#if defined(__WIN__)
FileData = tdbp->FileData;
Hsearch = tdbp->Hsearch;
strcpy(Drive, tdbp->Drive);
-#else // !WIN32
+#else // !__WIN__
Fileinfo = tdbp->Fileinfo;
Entry = tdbp->Entry;
Dir = tdbp->Dir;
Done = tdbp->Done;
strcpy(Pattern, tdbp->Pattern);
-#endif // !WIN32
+#endif // !__WIN__
strcpy(Direc, tdbp->Direc);
strcpy(Fname, tdbp->Fname);
strcpy(Ftype, tdbp->Ftype);
@@ -675,7 +675,7 @@ char* TDBDIR::Path(PGLOBAL g)
{
PCATLG cat = PlgGetCatalog(g);
-#if defined(WIN32)
+#if defined(__WIN__)
if (!*Drive) {
PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath());
_splitpath(Fpath, Drive, Direc, Fname, Ftype);
@@ -683,7 +683,7 @@ char* TDBDIR::Path(PGLOBAL g)
_makepath(Fpath, Drive, Direc, Fname, Ftype); // Usefull ???
return Fpath;
-#else // !WIN32
+#else // !__WIN__
if (!Done) {
PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath());
_splitpath(Fpath, NULL, Direc, Fname, Ftype);
@@ -692,7 +692,7 @@ char* TDBDIR::Path(PGLOBAL g)
} // endif Done
return Pattern;
-#endif // !WIN32
+#endif // !__WIN__
} // end of Path
/***********************************************************************/
@@ -710,7 +710,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
{
if (MaxSize < 0) {
int n = -1;
-#if defined(WIN32)
+#if defined(__WIN__)
int h;
// Start searching files in the target directory.
@@ -726,7 +726,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
} else
n = 0;
-#else // !WIN32
+#else // !__WIN__
Path(g);
// Start searching files in the target directory.
@@ -750,7 +750,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
// Close the DIR handle.
closedir(Dir);
-#endif // !WIN32
+#endif // !__WIN__
MaxSize = n;
} // endif MaxSize
@@ -776,10 +776,10 @@ bool TDBDIR::OpenDB(PGLOBAL g)
} // endif use
Use = USE_OPEN;
-#if !defined(WIN32)
+#if !defined(__WIN__)
Path(g); // Be sure it is done
Dir = NULL; // For ReadDB
-#endif // !WIN32
+#endif // !__WIN__
return false;
} // end of OpenDB
@@ -790,7 +790,7 @@ int TDBDIR::ReadDB(PGLOBAL g)
{
int rc = RC_OK;
-#if defined(WIN32)
+#if defined(__WIN__)
if (Hsearch == -1) {
/*******************************************************************/
/* Start searching files in the target directory. The use of the */
@@ -848,7 +848,7 @@ int TDBDIR::ReadDB(PGLOBAL g)
rc = RC_EF;
} // endif Entry
-#endif // !WIN32
+#endif // !__WIN__
return rc;
} // end of ReadDB
@@ -865,7 +865,7 @@ int TDBDIR::WriteDB(PGLOBAL g)
/***********************************************************************/
/* Data Base delete line routine for DIR access method. */
/***********************************************************************/
-int TDBDIR::DeleteDB(PGLOBAL g, int irc)
+int TDBDIR::DeleteDB(PGLOBAL g, int)
{
strcpy(g->Message, MSG(TABDIR_READONLY));
return RC_FX; // NIY
@@ -874,19 +874,19 @@ int TDBDIR::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/
/* Data Base close routine for MUL access method. */
/***********************************************************************/
-void TDBDIR::CloseDB(PGLOBAL g)
+void TDBDIR::CloseDB(PGLOBAL)
{
-#if defined(WIN32)
+#if defined(__WIN__)
// Close the search handle.
_findclose(Hsearch);
Hsearch = -1;
-#else // !WIN32
+#else // !__WIN__
// Close the DIR handle
if (Dir) {
closedir(Dir);
Dir = NULL;
} // endif dir
-#endif // !WIN32
+#endif // !__WIN__
iFile = 0;
} // end of CloseDB
@@ -895,7 +895,7 @@ void TDBDIR::CloseDB(PGLOBAL g)
/***********************************************************************/
/* DIRCOL public constructor. */
/***********************************************************************/
-DIRCOL::DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
+DIRCOL::DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ)
: COLBLK(cdp, tdbp, i)
{
if (cprec) {
@@ -935,19 +935,19 @@ void DIRCOL::ReadColumn(PGLOBAL g)
/* Retrieve the information corresponding to the column number. */
/*********************************************************************/
switch (N) {
-#if defined(WIN32)
+#if defined(__WIN__)
case 0: Value->SetValue_psz(tdbp->Drive); break;
-#endif // WIN32
+#endif // __WIN__
case 1: Value->SetValue_psz(tdbp->Direc); break;
case 2: Value->SetValue_psz(tdbp->Fname); break;
case 3: Value->SetValue_psz(tdbp->Ftype); break;
-#if defined(WIN32)
+#if defined(__WIN__)
case 4: Value->SetValue((int)tdbp->FileData.attrib); break;
case 5: Value->SetValue((int)tdbp->FileData.size); break;
case 6: Value->SetValue((int)tdbp->FileData.time_write); break;
case 7: Value->SetValue((int)tdbp->FileData.time_create); break;
case 8: Value->SetValue((int)tdbp->FileData.time_access); break;
-#else // !WIN32
+#else // !__WIN__
case 4: Value->SetValue((int)tdbp->Fileinfo.st_mode); break;
case 5: Value->SetValue((int)tdbp->Fileinfo.st_size); break;
case 6: Value->SetValue((int)tdbp->Fileinfo.st_mtime); break;
@@ -955,7 +955,7 @@ void DIRCOL::ReadColumn(PGLOBAL g)
case 8: Value->SetValue((int)tdbp->Fileinfo.st_atime); break;
case 9: Value->SetValue((int)tdbp->Fileinfo.st_uid); break;
case 10: Value->SetValue((int)tdbp->Fileinfo.st_gid); break;
-#endif // !WIN32
+#endif // !__WIN__
default:
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
longjmp(g->jumper[g->jump_level], GetAmType());
@@ -1006,7 +1006,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
size_t m = strlen(Direc);
// Start searching files in the target directory.
-#if defined(WIN32)
+#if defined(__WIN__)
int h = _findfirst(Path(g), &FileData);
if (h != -1) {
@@ -1039,7 +1039,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
// Close the search handle.
_findclose(h);
} // endif h
-#else // !WIN32
+#else // !__WIN__
int k;
DIR *dir = opendir(Direc);
@@ -1073,7 +1073,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
// Close the DIR handle.
closedir(dir);
-#endif // !WIN32
+#endif // !__WIN__
return n;
} // end of FindInDir
@@ -1089,13 +1089,13 @@ bool TDBSDR::OpenDB(PGLOBAL g)
Sub = (PSUBDIR)PlugSubAlloc(g, NULL, sizeof(SUBDIR));
Sub->Next = NULL;
Sub->Prev = NULL;
-#if defined(WIN32)
+#if defined(__WIN__)
Sub->H = -1;
Sub->Len = strlen(Direc);
-#else // !WIN32
+#else // !__WIN__
Sub->D = NULL;
Sub->Len = 0;
-#endif // !WIN32
+#endif // !__WIN__
} // endif To_Sub
return TDBDIR::OpenDB(g);
@@ -1108,7 +1108,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
{
int rc;
-#if defined(WIN32)
+#if defined(__WIN__)
again:
rc = TDBDIR::ReadDB(g);
@@ -1160,7 +1160,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
} // endif H
} // endif rc
-#else // !WIN32
+#else // !__WIN__
rc = RC_NF;
again:
@@ -1217,7 +1217,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
} // endif Entry
-#endif // !WIN32
+#endif // !__WIN__
return rc;
} // end of ReadDB
diff --git a/storage/connect/tabmul.h b/storage/connect/tabmul.h
index 379e8f88e93..433cc3a2ee3 100644
--- a/storage/connect/tabmul.h
+++ b/storage/connect/tabmul.h
@@ -6,14 +6,14 @@
/* */
/* This file contains the TDBMUL and TDBDIR classes declares. */
/***********************************************************************/
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
-#else // !WIN32
+#else // !__WIN__
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
-#endif // !WIN32
+#endif // !__WIN__
//#include "osutil.h"
#include "block.h"
@@ -132,17 +132,17 @@ class TDBDIR : public TDBASE {
// Members
PSZ To_File; // Points to file search pathname
int iFile; // Index of currently retrieved file
-#if defined(WIN32)
+#if defined(__WIN__)
_finddata_t FileData; // Find data structure
int Hsearch; // Search handle
char Drive[_MAX_DRIVE]; // Drive name
-#else // !WIN32
+#else // !__WIN__
struct stat Fileinfo; // File info structure
struct dirent *Entry; // Point to directory entry structure
DIR *Dir; // To searched directory structure
bool Done; // true when _splipath is done
char Pattern[_MAX_FNAME+_MAX_EXT];
-#endif // !WIN32
+#endif // !__WIN__
char Fpath[_MAX_PATH]; // Absolute file search pattern
char Direc[_MAX_DIR]; // Search path
char Fname[_MAX_FNAME]; // File name
@@ -183,11 +183,11 @@ class TDBSDR : public TDBDIR {
typedef struct _Sub_Dir {
struct _Sub_Dir *Next;
struct _Sub_Dir *Prev;
-#if defined(WIN32)
+#if defined(__WIN__)
int H; // Search handle
-#else // !WIN32
+#else // !__WIN__
DIR *D;
-#endif // !WIN32
+#endif // !__WIN__
size_t Len; // Initial directory name length
} SUBDIR, *PSUBDIR;
diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp
index b18e4da2ec4..19a5dfd758f 100644
--- a/storage/connect/tabmysql.cpp
+++ b/storage/connect/tabmysql.cpp
@@ -5,7 +5,7 @@
/* */
/* AUTHOR: */
/* ------- */
-/* Olivier BERTRAND 2007-2014 */
+/* Olivier BERTRAND 2007-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -35,9 +35,9 @@
#include "my_global.h"
#include "sql_class.h"
#include "sql_servers.h"
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
//#include <fnmatch.h>
//#include <errno.h>
#include <stdlib.h>
@@ -46,7 +46,7 @@
#include "osutil.h"
//#include <io.h>
//#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -307,7 +307,7 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
/***********************************************************************/
/* DefineAM: define specific AM block values from XCV file. */
/***********************************************************************/
-bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
{
char *url;
@@ -380,7 +380,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
-PTDB MYSQLDEF::GetTable(PGLOBAL g, MODE m)
+PTDB MYSQLDEF::GetTable(PGLOBAL g, MODE)
{
if (Xsrc)
return new(g) TDBMYEXC(this);
@@ -438,7 +438,7 @@ TDBMYSQL::TDBMYSQL(PMYDEF tdp) : TDBASE(tdp)
Nparm = 0;
} // end of TDBMYSQL constructor
-TDBMYSQL::TDBMYSQL(PGLOBAL g, PTDBMY tdbp) : TDBASE(tdbp)
+TDBMYSQL::TDBMYSQL(PTDBMY tdbp) : TDBASE(tdbp)
{
Host = tdbp->Host;
Database = tdbp->Database;
@@ -468,7 +468,7 @@ PTDB TDBMYSQL::CopyOne(PTABS t)
PCOL cp1, cp2;
PGLOBAL g = t->G;
- tp = new(g) TDBMYSQL(g, this);
+ tp = new(g) TDBMYSQL(this);
for (cp1 = Columns; cp1; cp1 = cp1->GetNext()) {
cp2 = new(g) MYSQLCOL((PMYCOL)cp1, tp);
@@ -816,7 +816,7 @@ int TDBMYSQL::GetMaxSize(PGLOBAL g)
/***********************************************************************/
/* This a fake routine as ROWID does not exist in MySQL. */
/***********************************************************************/
-int TDBMYSQL::RowNumber(PGLOBAL g, bool b)
+int TDBMYSQL::RowNumber(PGLOBAL, bool)
{
return N + 1;
} // end of RowNumber
@@ -832,7 +832,7 @@ int TDBMYSQL::GetProgMax(PGLOBAL g)
/***********************************************************************/
/* MySQL Bind Parameter function. */
/***********************************************************************/
-int TDBMYSQL::BindColumns(PGLOBAL g)
+int TDBMYSQL::BindColumns(PGLOBAL g __attribute__((unused)))
{
#if defined(MYSQL_PREPARED_STATEMENTS)
if (Prep) {
@@ -1425,7 +1425,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/
/* WriteColumn: make sure the bind buffer is updated. */
/***********************************************************************/
-void MYSQLCOL::WriteColumn(PGLOBAL g)
+void MYSQLCOL::WriteColumn(PGLOBAL)
{
/*********************************************************************/
/* Do convert the column value if necessary. */
@@ -1463,7 +1463,7 @@ TDBMYEXC::TDBMYEXC(PMYDEF tdp) : TDBMYSQL(tdp)
Nerr = 0;
} // end of TDBMYEXC constructor
-TDBMYEXC::TDBMYEXC(PGLOBAL g, PTDBMYX tdbp) : TDBMYSQL(g, tdbp)
+TDBMYEXC::TDBMYEXC(PTDBMYX tdbp) : TDBMYSQL(tdbp)
{
Cmdlist = tdbp->Cmdlist;
Cmdcol = tdbp->Cmdcol;
@@ -1481,7 +1481,7 @@ PTDB TDBMYEXC::CopyOne(PTABS t)
PCOL cp1, cp2;
PGLOBAL g = t->G;
- tp = new(g) TDBMYEXC(g, this);
+ tp = new(g) TDBMYEXC(this);
for (cp1 = Columns; cp1; cp1 = cp1->GetNext()) {
cp2 = new(g) MYXCOL((PMYXCOL)cp1, tp);
@@ -1534,7 +1534,7 @@ PCMD TDBMYEXC::MakeCMD(PGLOBAL g)
/***********************************************************************/
/* EXC GetMaxSize: returns the maximum number of rows in the table. */
/***********************************************************************/
-int TDBMYEXC::GetMaxSize(PGLOBAL g)
+int TDBMYEXC::GetMaxSize(PGLOBAL)
{
if (MaxSize < 0) {
MaxSize = 10; // a guess
@@ -1711,7 +1711,7 @@ void MYXCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/
/* WriteColumn: should never be called. */
/***********************************************************************/
-void MYXCOL::WriteColumn(PGLOBAL g)
+void MYXCOL::WriteColumn(PGLOBAL)
{
assert(false);
} // end of WriteColumn
diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h
index 99930d43a57..17d7b190340 100644
--- a/storage/connect/tabmysql.h
+++ b/storage/connect/tabmysql.h
@@ -73,11 +73,11 @@ class TDBMYSQL : public TDBASE {
public:
// Constructor
TDBMYSQL(PMYDEF tdp);
- TDBMYSQL(PGLOBAL g, PTDBMY tdbp);
+ TDBMYSQL(PTDBMY tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MYSQL;}
- virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(g, this);}
+ virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
@@ -180,11 +180,11 @@ class TDBMYEXC : public TDBMYSQL {
public:
// Constructors
TDBMYEXC(PMYDEF tdp);
- TDBMYEXC(PGLOBAL g, PTDBMYX tdbp);
+ TDBMYEXC(PTDBMYX tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MYX;}
- virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYEXC(g, this);}
+ virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYEXC(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp
index 7f7b1c5d50c..07e260154e0 100644
--- a/storage/connect/taboccur.cpp
+++ b/storage/connect/taboccur.cpp
@@ -13,7 +13,7 @@
/***********************************************************************/
#include "my_global.h"
#include "table.h" // MySQL table definitions
-#if defined(WIN32)
+#if defined(__WIN__)
#include <stdlib.h>
#include <stdio.h>
#if defined(__BORLANDC__)
@@ -266,7 +266,7 @@ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
-PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m)
+PTDB OCCURDEF::GetTable(PGLOBAL g, MODE)
{
if (Catfunc != FNC_COL)
return new(g) TDBOCCUR(this);
@@ -432,7 +432,7 @@ int TDBOCCUR::GetMaxSize(PGLOBAL g)
/* In this sample, ROWID will be the (virtual) row number, */
/* while ROWNUM will be the occurence rank in the multiple column. */
/***********************************************************************/
-int TDBOCCUR::RowNumber(PGLOBAL g, bool b)
+int TDBOCCUR::RowNumber(PGLOBAL, bool b)
{
return (b) ? M : N;
} // end of RowNumber
@@ -567,7 +567,7 @@ void OCCURCOL::ReadColumn(PGLOBAL g)
/* ReadColumn: what this routine does is to access the Mth columns of */
/* list, extract its name and set to it the rank column value. */
/***********************************************************************/
-void RANKCOL::ReadColumn(PGLOBAL g)
+void RANKCOL::ReadColumn(PGLOBAL)
{
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
PCOL *col = tdbp->Col;
diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp
index 3bf1238cebc..307509848f4 100644
--- a/storage/connect/tabodbc.cpp
+++ b/storage/connect/tabodbc.cpp
@@ -35,7 +35,7 @@
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#if defined(__BORLANDC__)
@@ -1268,6 +1268,10 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
} // endif Buf_Type
+ // Handle null values
+ if (Value->IsZero())
+ Value->SetNull(Nullable);
+
if (trace) {
char buf[64];
@@ -1393,7 +1397,7 @@ void ODBCCOL::WriteColumn(PGLOBAL g)
/* -------------------------- Class TDBXDBC -------------------------- */
/***********************************************************************/
-/* Implementation of the TDBODBC class. */
+/* Implementation of the TDBXDBC class. */
/***********************************************************************/
TDBXDBC::TDBXDBC(PODEF tdp) : TDBODBC(tdp)
{
diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp
index 401ffa3780e..b628e26d3c7 100644
--- a/storage/connect/tabpivot.cpp
+++ b/storage/connect/tabpivot.cpp
@@ -17,7 +17,7 @@
/***********************************************************************/
#include "my_global.h"
#include "table.h" // MySQL table definitions
-#if defined(WIN32)
+#if defined(__WIN__)
#if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro
#endif
@@ -376,7 +376,7 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
-PTDB PIVOTDEF::GetTable(PGLOBAL g, MODE m)
+PTDB PIVOTDEF::GetTable(PGLOBAL g, MODE)
{
return new(g) TDBPIVOT(this);
} // end of GetTable
@@ -634,7 +634,7 @@ bool TDBPIVOT::MakeViewColumns(PGLOBAL g)
/***********************************************************************/
/* PIVOT GetMaxSize: returns the maximum number of rows in the table. */
/***********************************************************************/
-int TDBPIVOT::GetMaxSize(PGLOBAL g)
+int TDBPIVOT::GetMaxSize(PGLOBAL g __attribute__((unused)))
{
#if 0
if (MaxSize < 0)
@@ -649,7 +649,7 @@ int TDBPIVOT::GetMaxSize(PGLOBAL g)
/* In this sample, ROWID will be the (virtual) row number, */
/* while ROWNUM will be the occurence rank in the multiple column. */
/***********************************************************************/
-int TDBPIVOT::RowNumber(PGLOBAL g, bool b)
+int TDBPIVOT::RowNumber(PGLOBAL, bool b)
{
return (b) ? M : N;
} // end of RowNumber
@@ -806,7 +806,7 @@ int TDBPIVOT::WriteDB(PGLOBAL g)
/***********************************************************************/
/* Data Base delete line routine for PIVOT access methods. */
/***********************************************************************/
-int TDBPIVOT::DeleteDB(PGLOBAL g, int irc)
+int TDBPIVOT::DeleteDB(PGLOBAL g, int)
{
sprintf(g->Message, MSG(NO_TABLE_DEL), "PIVOT");
return RC_FX;
diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp
index 3ed182c5e33..76890e84429 100644
--- a/storage/connect/tabsys.cpp
+++ b/storage/connect/tabsys.cpp
@@ -3,7 +3,7 @@
/* ------------- */
/* Version 2.3 */
/* */
-/* Author Olivier BERTRAND 2004-2014 */
+/* Author Olivier BERTRAND 2004-2015 */
/* */
/* This program are the INI/CFG tables classes. */
/***********************************************************************/
@@ -12,12 +12,12 @@
/* Include relevant sections of the System header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <errno.h>
#include <unistd.h>
@@ -25,7 +25,7 @@
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -36,9 +36,9 @@
#include "global.h"
#include "plgdbsem.h"
#include "reldef.h"
-#if !defined(WIN32)
+#if !defined(__WIN__)
#include "osutil.h"
-#endif // !WIN32
+#endif // !__WIN__
#include "filamtxt.h"
#include "tabdos.h"
#include "tabsys.h"
@@ -48,10 +48,10 @@
#define CSZ 36 // Column section name length
#define CDZ 256 // Column definition length
-#if !defined(WIN32)
+#if !defined(__WIN__)
#define GetPrivateProfileSectionNames(S,L,I) \
GetPrivateProfileString(NULL,NULL,"",S,L,I)
-#endif // !WIN32
+#endif // !__WIN__
/* -------------- Implementation of the INI classes ------------------ */
@@ -70,7 +70,7 @@ INIDEF::INIDEF(void)
/***********************************************************************/
/* DefineAM: define specific AM block values from XDB file. */
/***********************************************************************/
-bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool INIDEF::DefineAM(PGLOBAL g, LPCSTR, int)
{
char buf[8];
@@ -96,7 +96,7 @@ bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
-PTDB INIDEF::GetTable(PGLOBAL g, MODE m)
+PTDB INIDEF::GetTable(PGLOBAL g, MODE)
{
PTDBASE tdbp;
@@ -123,7 +123,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g)
// Delete the INI table file if not protected
if (!IsReadOnly()) {
PlugSetPath(filename, Fn, GetPath());
-#if defined(WIN32)
+#if defined(__WIN__)
rc = !DeleteFile(filename);
#else // UNIX
rc = remove(filename);
@@ -277,49 +277,27 @@ bool TDBINI::OpenDB(PGLOBAL g)
/***********************************************************************/
/* Data Base read routine for INI access method. */
/***********************************************************************/
-int TDBINI::ReadDB(PGLOBAL g)
+int TDBINI::ReadDB(PGLOBAL)
{
/*********************************************************************/
/* Now start the pseudo reading process. */
/*********************************************************************/
-#if 0 // INI tables are not indexable
- if (To_Kindex) {
- /*******************************************************************/
- /* Reading is by an index table. */
- /*******************************************************************/
- int recpos = To_Kindex->Fetch(g);
-
- switch (recpos) {
- case -1: // End of file reached
- return RC_EF;
- case -2: // No match for join
- return RC_NF;
- case -3: // Same record as last non null one
- return RC_OK;
- default:
- Section = (char*)recpos; // No good on 64 bit machines
- } // endswitch recpos
-
- } else {
-#endif // 0
- if (!Section)
- Section = Seclist;
- else
- Section += (strlen(Section) + 1);
-
- if (trace > 1)
- htrc("INI ReadDB: section=%s N=%d\n", Section, N);
+ if (!Section)
+ Section = Seclist;
+ else
+ Section += (strlen(Section) + 1);
- N++;
-//} // endif To_Kindex
+ if (trace > 1)
+ htrc("INI ReadDB: section=%s N=%d\n", Section, N);
+ N++;
return (*Section) ? RC_OK : RC_EF;
} // end of ReadDB
/***********************************************************************/
/* WriteDB: Data Base write routine for INI access methods. */
/***********************************************************************/
-int TDBINI::WriteDB(PGLOBAL g)
+int TDBINI::WriteDB(PGLOBAL)
{
// This is to check that section name was given when inserting
if (Mode == MODE_INSERT)
@@ -365,11 +343,11 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/
/* Data Base close routine for INI access methods. */
/***********************************************************************/
-void TDBINI::CloseDB(PGLOBAL g)
+void TDBINI::CloseDB(PGLOBAL)
{
-#if !defined(WIN32)
+#if !defined(__WIN__)
PROFILE_Close(Ifile);
-#endif // !WIN32
+#endif // !__WIN__
} // end of CloseDB
// ------------------------ INICOL functions ----------------------------
@@ -377,7 +355,7 @@ void TDBINI::CloseDB(PGLOBAL g)
/***********************************************************************/
/* INICOL public constructor. */
/***********************************************************************/
-INICOL::INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
+INICOL::INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ)
: COLBLK(cdp, tdbp, i)
{
if (cprec) {
@@ -471,7 +449,7 @@ bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
/* from the corresponding section, extract from it the key value */
/* corresponding to this column name and convert it to buffer type. */
/***********************************************************************/
-void INICOL::ReadColumn(PGLOBAL g)
+void INICOL::ReadColumn(PGLOBAL)
{
PTDBINI tdbp = (PTDBINI)To_Tdb;
@@ -747,7 +725,7 @@ int TDBXIN::ReadDB(PGLOBAL g)
/***********************************************************************/
/* WriteDB: Data Base write routine for XIN access methods. */
/***********************************************************************/
-int TDBXIN::WriteDB(PGLOBAL g)
+int TDBXIN::WriteDB(PGLOBAL)
{
// To check that section and key names were given when inserting
if (Mode == MODE_INSERT) {
@@ -809,7 +787,7 @@ XINCOL::XINCOL(XINCOL *col1, PTDB tdbp) : INICOL(col1, tdbp)
/* from the corresponding section, extract from it the key value */
/* corresponding to this column name and convert it to buffer type. */
/***********************************************************************/
-void XINCOL::ReadColumn(PGLOBAL g)
+void XINCOL::ReadColumn(PGLOBAL)
{
PTDBXIN tdbp = (PTDBXIN)To_Tdb;
diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp
index 2bf26a5f183..7f979eaf4be 100644
--- a/storage/connect/tabtbl.cpp
+++ b/storage/connect/tabtbl.cpp
@@ -39,7 +39,7 @@
//#include "sql_base.h"
#include "my_global.h"
#include "table.h" // MySQL table definitions
-#if defined(WIN32)
+#if defined(__WIN__)
#include <stdlib.h>
#include <stdio.h>
#if defined(__BORLANDC__)
@@ -73,15 +73,15 @@
#include "tabmysql.h"
#include "ha_connect.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#if defined(__BORLANDC__)
#define SYSEXIT void _USERENTRY
#else
#define SYSEXIT void
#endif
-#else // !WIN32
+#else // !__WIN__
#define SYSEXIT void *
-#endif // !WIN32
+#endif // !__WIN__
/* ---------------------------- Class TBLDEF ---------------------------- */
@@ -101,7 +101,7 @@ TBLDEF::TBLDEF(void)
/**************************************************************************/
/* DefineAM: define specific AM block values from XDB file. */
/**************************************************************************/
-bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR, int)
{
char *tablist, *dbname, *def = NULL;
@@ -161,7 +161,7 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
-PTDB TBLDEF::GetTable(PGLOBAL g, MODE m)
+PTDB TBLDEF::GetTable(PGLOBAL g, MODE)
{
if (Catfunc == FNC_COL)
return new(g) TDBTBC(this);
@@ -202,7 +202,7 @@ PCOL TDBTBL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/
/* InsertSpecialColumn: Put a special column ahead of the column list.*/
/***********************************************************************/
-PCOL TDBTBL::InsertSpecialColumn(PGLOBAL g, PCOL scp)
+PCOL TDBTBL::InsertSpecialColumn(PCOL scp)
{
PCOL colp;
@@ -548,7 +548,7 @@ int TDBTBL::ReadDB(PGLOBAL g)
/***********************************************************************/
/* ReadColumn: */
/***********************************************************************/
-void TBTBLK::ReadColumn(PGLOBAL g)
+void TBTBLK::ReadColumn(PGLOBAL)
{
if (trace)
htrc("TBT ReadColumn: name=%s\n", Name);
diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h
index 8bf440985ea..9d3f297f9e7 100644
--- a/storage/connect/tabtbl.h
+++ b/storage/connect/tabtbl.h
@@ -81,7 +81,7 @@ class DllExport TDBTBL : public TDBPRX {
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
- virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp);
+ virtual PCOL InsertSpecialColumn(PCOL scp);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp
index c26d766af01..331a7f45d4d 100644
--- a/storage/connect/tabutil.cpp
+++ b/storage/connect/tabutil.cpp
@@ -14,7 +14,7 @@
#include "sql_class.h"
#include "table.h"
#include "field.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <stdlib.h>
#include <stdio.h>
#if defined(__BORLANDC__)
@@ -292,7 +292,7 @@ PRXDEF::PRXDEF(void)
/***********************************************************************/
/* DefineAM: define specific AM block values from XCOL file. */
/***********************************************************************/
-bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR, int)
{
char *pn, *db, *tab, *def = NULL;
@@ -322,7 +322,7 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
-PTDB PRXDEF::GetTable(PGLOBAL g, MODE mode)
+PTDB PRXDEF::GetTable(PGLOBAL g, MODE)
{
if (Catfunc == FNC_COL)
return new(g) TDBTBC(this);
@@ -341,7 +341,7 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp)
Tdbp = NULL; // The object table
} // end of TDBPRX constructor
-TDBPRX::TDBPRX(PGLOBAL g, PTDBPRX tdbp) : TDBASE(tdbp)
+TDBPRX::TDBPRX(PTDBPRX tdbp) : TDBASE(tdbp)
{
Tdbp = tdbp->Tdbp;
} // end of TDBPRX copy constructor
@@ -353,7 +353,7 @@ PTDB TDBPRX::CopyOne(PTABS t)
PPRXCOL cp1, cp2;
PGLOBAL g = t->G;
- tp = new(g) TDBPRX(g, this);
+ tp = new(g) TDBPRX(this);
for (cp1 = (PPRXCOL)Columns; cp1; cp1 = (PPRXCOL)cp1->GetNext()) {
cp2 = new(g) PRXCOL(cp1, tp); // Make a copy
diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h
index c5935d72184..b320d169b36 100644
--- a/storage/connect/tabutil.h
+++ b/storage/connect/tabutil.h
@@ -59,12 +59,12 @@ class DllExport TDBPRX : public TDBASE {
public:
// Constructors
TDBPRX(PPRXDEF tdp);
- TDBPRX(PGLOBAL g, PTDBPRX tdbp);
+ TDBPRX(PTDBPRX tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_PRX;}
virtual PTDB Duplicate(PGLOBAL g)
- {return (PTDB)new(g) TDBPRX(g, this);}
+ {return (PTDB)new(g) TDBPRX(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp
index 3ed40540395..e788529075f 100644
--- a/storage/connect/tabvct.cpp
+++ b/storage/connect/tabvct.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -35,7 +35,7 @@
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#if defined(__BORLANDC__)
@@ -94,7 +94,7 @@ PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int,
/***********************************************************************/
/* DefineAM: define specific AM block values from XDB file. */
/***********************************************************************/
-bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
{
DOSDEF::DefineAM(g, "BIN", poff);
@@ -146,7 +146,7 @@ bool VCTDEF::Erase(char *filename)
for (i = 1, cdp = To_Cols; cdp; i++, cdp = cdp->GetNext()) {
sprintf(filename, fpat, i);
-//#if defined(WIN32)
+//#if defined(__WIN__)
// rc |= !DeleteFile(filename);
//#else // UNIX
rc |= remove(filename);
@@ -175,7 +175,7 @@ bool VCTDEF::Erase(char *filename)
int VCTDEF::MakeFnPattern(char *fpat)
{
char pat[8];
-#if !defined(UNIX)
+#if defined(__WIN__)
char drive[_MAX_DRIVE];
#else
char *drive = NULL;
@@ -290,7 +290,7 @@ PCOL TDBVCT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/
/* VEC tables are not ready yet to use temporary files. */
/***********************************************************************/
-bool TDBVCT::IsUsingTemp(PGLOBAL g)
+bool TDBVCT::IsUsingTemp(PGLOBAL)
{
// For developpers
return (UseTemp() == TMP_TEST);
@@ -570,7 +570,7 @@ void VCTCOL::ReadColumn(PGLOBAL g)
/* On each change of block the buffer is written back to file and */
/* in mode Insert the buffer is filled with the block to update. */
/***********************************************************************/
-void VCTCOL::WriteColumn(PGLOBAL g)
+void VCTCOL::WriteColumn(PGLOBAL)
{
PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;;
diff --git a/storage/connect/tabvir.cpp b/storage/connect/tabvir.cpp
index b4c76f5ad56..356fc981357 100644
--- a/storage/connect/tabvir.cpp
+++ b/storage/connect/tabvir.cpp
@@ -29,7 +29,7 @@
/***********************************************************************/
/* Return the unique column definition to MariaDB. */
/***********************************************************************/
-PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info)
+PQRYRES VirColumns(PGLOBAL g, bool info)
{
int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_STRING, TYPE_STRING};
@@ -95,7 +95,7 @@ PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info)
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
-PTDB VIRDEF::GetTable(PGLOBAL g, MODE m)
+PTDB VIRDEF::GetTable(PGLOBAL g, MODE)
{
// Column blocks will be allocated only when needed.
if (Catfunc == FNC_COL)
@@ -241,7 +241,7 @@ bool TDBVIR::OpenDB(PGLOBAL g)
/***********************************************************************/
/* Data Base read routine for the VIR access method. */
/***********************************************************************/
-int TDBVIR::ReadDB(PGLOBAL g)
+int TDBVIR::ReadDB(PGLOBAL)
{
return (++N >= Size) ? RC_EF : RC_OK;
} // end of ReadDB
@@ -258,7 +258,7 @@ int TDBVIR::WriteDB(PGLOBAL g)
/***********************************************************************/
/* Data Base delete line routine for the VIR access methods. */
/***********************************************************************/
-int TDBVIR::DeleteDB(PGLOBAL g, int irc)
+int TDBVIR::DeleteDB(PGLOBAL g, int)
{
sprintf(g->Message, MSG(VIR_NO_DELETE), To_Def->GetType());
return RC_FX;
@@ -269,7 +269,7 @@ int TDBVIR::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/
/* VIRCOL public constructor. */
/***********************************************************************/
-VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
+VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ)
: COLBLK(cdp, tdbp, i)
{
if (cprec) {
@@ -299,7 +299,7 @@ void VIRCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/
PQRYRES TDBVICL::GetResult(PGLOBAL g)
{
- return VirColumns(g, NULL, NULL, false);
+ return VirColumns(g, false);
} // end of GetResult
/* ------------------------- End of Virtual -------------------------- */
diff --git a/storage/connect/tabvir.h b/storage/connect/tabvir.h
index 8d0caa257e7..a53aceaeceb 100644
--- a/storage/connect/tabvir.h
+++ b/storage/connect/tabvir.h
@@ -11,7 +11,7 @@ typedef class TDBVIR *PTDBVIR;
/***********************************************************************/
/* Return the unique column definition to MariaDB. */
/***********************************************************************/
-PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info);
+PQRYRES VirColumns(PGLOBAL g, bool info);
/* --------------------------- VIR classes --------------------------- */
diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp
index 7c69426a066..98a44b9d635 100644
--- a/storage/connect/tabwmi.cpp
+++ b/storage/connect/tabwmi.cpp
@@ -2,9 +2,9 @@
/* TABWMI: Author Olivier Bertrand -- PlugDB -- 2012 - 2013 */
/* TABWMI: Virtual table to get WMI information. */
/***********************************************************************/
-#if !defined(WIN32)
-#error This is a WIN32 only table type
-#endif // !WIN32
+#if !defined(__WIN__)
+#error This is a WINDOWS only table type
+#endif // !__WIN__
#include "my_global.h"
#include <stdio.h>
diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp
index dffbaf6e187..add61431493 100644
--- a/storage/connect/tabxcl.cpp
+++ b/storage/connect/tabxcl.cpp
@@ -17,7 +17,7 @@
/***********************************************************************/
#include "my_global.h"
#include "table.h" // MySQL table definitions
-#if defined(WIN32)
+#if defined(__WIN__)
#include <stdlib.h>
#include <stdio.h>
#if defined(__BORLANDC__)
@@ -83,7 +83,7 @@ bool XCLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
-PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode)
+PTDB XCLDEF::GetTable(PGLOBAL g, MODE)
{
if (Catfunc == FNC_COL)
return new(g) TDBTBC(this);
@@ -117,7 +117,7 @@ PCOL TDBXCL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
PCOL colp;
if (!stricmp(cdp->GetName(), Xcolumn)) {
- Xcolp = new(g) XCLCOL(g, cdp, this, cprec, n);
+ Xcolp = new(g) XCLCOL(cdp, this, cprec, n);
colp = Xcolp;
} else
colp = new(g) PRXCOL(cdp, this, cprec, n);
@@ -144,7 +144,7 @@ int TDBXCL::GetMaxSize(PGLOBAL g)
/* For this table type, ROWID is the (virtual) row number, */
/* while ROWNUM is be the occurence rank in the multiple column. */
/***********************************************************************/
-int TDBXCL::RowNumber(PGLOBAL g, bool b)
+int TDBXCL::RowNumber(PGLOBAL, bool b)
{
return (b) ? M : N;
} // end of RowNumber
@@ -232,7 +232,7 @@ int TDBXCL::ReadDB(PGLOBAL g)
/***********************************************************************/
/* XCLCOL public constructor. */
/***********************************************************************/
-XCLCOL::XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
+XCLCOL::XCLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
: PRXCOL(cdp, tdbp, cprec, i, "XCL")
{
// Set additional XXL access method information for column.
diff --git a/storage/connect/tabxcl.h b/storage/connect/tabxcl.h
index ed15a67b629..291f0b4263a 100644
--- a/storage/connect/tabxcl.h
+++ b/storage/connect/tabxcl.h
@@ -85,7 +85,7 @@ class XCLCOL : public PRXCOL {
friend class TDBXCL;
public:
// Constructors
- XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
+ XCLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
// Methods
using PRXCOL::Init;
diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp
index 6fba8382aaa..49fa9a1c554 100644
--- a/storage/connect/tabxml.cpp
+++ b/storage/connect/tabxml.cpp
@@ -15,12 +15,12 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <winsock2.h>
//#include <windows.h>
#include <comdef.h>
-#else // !WIN32
+#else // !__WIN__
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -28,7 +28,7 @@
//#include <ctype.h>
#include "osutil.h"
#define _O_RDONLY O_RDONLY
-#endif // !WIN32
+#endif // !__WIN__
#include "resource.h" // for IDS_COLUMNS
#define INCLUDE_TDBXML
@@ -53,11 +53,11 @@
extern "C" char version[];
-#if defined(WIN32) && defined(DOMDOC_SUPPORT)
+#if defined(__WIN__) && defined(DOMDOC_SUPPORT)
#define XMLSUP "MS-DOM"
-#else // !WIN32
+#else // !__WIN__
#define XMLSUP "libxml2"
-#endif // !WIN32
+#endif // !__WIN__
#define TYPE_UNKNOWN 12 /* Must be greater than other types */
@@ -110,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,33 +138,35 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info)
/*********************************************************************/
/* Open the input file. */
/*********************************************************************/
- if (!topt->filename) {
+ if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) {
strcpy(g->Message, MSG(MISSING_FNAME));
return NULL;
- } else
- lvl = atoi(GetListOption(g, "Level", topt->oplist, "0"));
+ } else {
+ lvl = GetIntegerTableOption(g, topt, "Level", 0);
+ lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl;
+ } // endif fn
if (trace)
htrc("File %s lvl=%d\n", topt->filename, lvl);
tdp = new(g) XMLDEF;
- tdp->Database = dp;
- tdp->Fn = (char*)topt->filename;
+ tdp->Fn = fn;
+ tdp->Database = SetPath(g, db);
tdp->Tabname = tab;
- if (!(op = GetListOption(g, "Xmlsup", topt->oplist, NULL)))
-#if defined(WIN32)
+ if (!(op = GetStringTableOption(g, topt, "Xmlsup", NULL)))
+#if defined(__WIN__)
tdp->Usedom = true;
-#else // !WIN32
+#else // !__WIN__
tdp->Usedom = false;
-#endif // !WIN32
+#endif // !__WIN__
else
tdp->Usedom = (toupper(*op) == 'M' || toupper(*op) == 'D');
txmp = new(g) TDBXML(tdp);
if (txmp->Initialize(g))
- return NULL;
+ goto err;
xcol = new(g) XMCOL;
colname[64] = 0;
@@ -224,8 +226,16 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info)
if (vp->atp) {
strncpy(colname, vp->atp->GetName(g), sizeof(colname));
strncat(xcol->Name, colname, 64);
- vp->atp->GetText(g, buf, sizeof(buf));
- strncat(fmt, "@", sizeof(fmt));
+
+ switch (vp->atp->GetText(g, buf, sizeof(buf))) {
+ case RC_INFO:
+ PushWarning(g, txmp);
+ case RC_OK:
+ strncat(fmt, "@", sizeof(fmt));
+ break;
+ default:
+ goto err;
+ } // enswitch rc
if (j)
strncat(fmt, colname, sizeof(fmt));
@@ -273,7 +283,15 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info)
} else
ok = true;
- node->GetContent(g, buf, sizeof(buf));
+ switch (node->GetContent(g, buf, sizeof(buf))) {
+ case RC_INFO:
+ PushWarning(g, txmp);
+ case RC_OK:
+ break;
+ default:
+ goto err;
+ } // enswitch rc
+
} // endif atp;
xcol->Len = strlen(buf);
@@ -313,10 +331,6 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info)
pxcp = xcp;
-// for (j = lvl - 1; j >= 0; j--)
-// if (jrp[j] && (jrp[j] = jrp[j]->GetNext()))
-// goto more;
-
if (vp->atp)
vp->atp = vp->atp->GetNext(g);
@@ -420,9 +434,7 @@ XMLDEF::XMLDEF(void)
/***********************************************************************/
bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
- char *defrow, *defcol, buf[10];
-//void *memp = Cat->GetDescp();
-//PSZ dbfile = Cat->GetDescFile();
+ char *defrow, *defcol, buf[10];
Fn = GetStringCatInfo(g, "Filename", NULL);
Encoding = GetStringCatInfo(g, "Encoding", "UTF-8");
@@ -437,7 +449,7 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return true;
} // endif flag
- defrow = defcol = "";
+ defrow = defcol = NULL;
GetCharCatInfo("Coltype", "", buf, sizeof(buf));
switch (toupper(*buf)) {
@@ -470,36 +482,29 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Tabname = GetStringCatInfo(g, "Tabname", Tabname);
Rowname = GetStringCatInfo(g, "Rownode", defrow);
Colname = GetStringCatInfo(g, "Colnode", defcol);
- Mulnode = GetStringCatInfo(g, "Mulnode", "");
- XmlDB = GetStringCatInfo(g, "XmlDB", "");
- Nslist = GetStringCatInfo(g, "Nslist", "");
- DefNs = GetStringCatInfo(g, "DefNs", "");
+ Mulnode = GetStringCatInfo(g, "Mulnode", NULL);
+ XmlDB = GetStringCatInfo(g, "XmlDB", NULL);
+ Nslist = GetStringCatInfo(g, "Nslist", NULL);
+ DefNs = GetStringCatInfo(g, "DefNs", NULL);
Limit = GetIntCatInfo("Limit", 10);
- Xpand = (GetIntCatInfo("Expand", 0) != 0);
+ Xpand = GetBoolCatInfo("Expand", false);
Header = GetIntCatInfo("Header", 0);
GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf));
-//if (*buf == '*') // Try the old (deprecated) option
-// GetCharCatInfo("Method", "*", buf, sizeof(buf));
-
-//if (*buf == '*') // Is there a default for the database?
-// GetCharCatInfo("Defxml", XMLSUP, buf, sizeof(buf));
-
// Note that if no support is specified, the default is MS-DOM
// on Windows and libxml2 otherwise
if (*buf == '*')
-#if defined(WIN32)
+#if defined(__WIN__)
Usedom = true;
-#else // !WIN32
+#else // !__WIN__
Usedom = false;
-#endif // !WIN32
+#endif // !__WIN__
else
Usedom = (toupper(*buf) == 'M' || toupper(*buf) == 'D');
// Get eventual table node attribute
- Attrib = GetStringCatInfo(g, "Attribute", "");
- Hdattr = GetStringCatInfo(g, "HeadAttr", "");
-
+ Attrib = GetStringCatInfo(g, "Attribute", NULL);
+ Hdattr = GetStringCatInfo(g, "HeadAttr", NULL);
return false;
} // end of DefineAM
@@ -519,30 +524,6 @@ PTDB XMLDEF::GetTable(PGLOBAL g, MODE m)
return tdbp;
} // end of GetTable
-#if 0
-/***********************************************************************/
-/* DeleteTableFile: Delete XML table files using platform API. */
-/***********************************************************************/
-bool XMLDEF::DeleteTableFile(PGLOBAL g)
- {
- char filename[_MAX_PATH];
- bool rc;
-
- // Delete the XML table file if not protected
- if (!IsReadOnly()) {
- PlugSetPath(filename, Fn, GetPath());
-#if defined(WIN32)
- rc = !DeleteFile(filename);
-#else // UNIX
- rc = remove(filename);
-#endif // UNIX
- } else
- rc =true;
-
- return rc; // Return true if error
- } // end of DeleteTableFile
-#endif // 0
-
/* ------------------------- TDBXML Class ---------------------------- */
/***********************************************************************/
@@ -564,14 +545,14 @@ TDBXML::TDBXML(PXMLDEF tdp) : TDBASE(tdp)
Xfile = tdp->Fn;
Enc = tdp->Encoding;
Tabname = tdp->Tabname;
- Rowname = (tdp->Rowname && *tdp->Rowname) ? tdp->Rowname : NULL;
- Colname = (tdp->Colname && *tdp->Colname) ? tdp->Colname : NULL;
- Mulnode = (tdp->Mulnode && *tdp->Mulnode) ? tdp->Mulnode : NULL;
- XmlDB = (tdp->XmlDB && *tdp->XmlDB) ? tdp->XmlDB : NULL;
- Nslist = (tdp->Nslist && *tdp->Nslist) ? tdp->Nslist : NULL;
- DefNs = (tdp->DefNs && *tdp->DefNs) ? tdp->DefNs : NULL;
- Attrib = (tdp->Attrib && *tdp->Attrib) ? tdp->Attrib : NULL;
- Hdattr = (tdp->Hdattr && *tdp->Hdattr) ? tdp->Hdattr : NULL;
+ Rowname = (tdp->Rowname) ? tdp->Rowname : NULL;
+ Colname = (tdp->Colname) ? tdp->Colname : NULL;
+ Mulnode = (tdp->Mulnode) ? tdp->Mulnode : NULL;
+ XmlDB = (tdp->XmlDB) ? tdp->XmlDB : NULL;
+ Nslist = (tdp->Nslist) ? tdp->Nslist : NULL;
+ DefNs = (tdp->DefNs) ? tdp->DefNs : NULL;
+ Attrib = (tdp->Attrib) ? tdp->Attrib : NULL;
+ Hdattr = (tdp->Hdattr) ? tdp->Hdattr : NULL;
Coltype = tdp->Coltype;
Limit = tdp->Limit;
Xpand = tdp->Xpand;
@@ -667,7 +648,7 @@ PCOL TDBXML::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/
/* InsertSpecialColumn: Put a special column ahead of the column list.*/
/***********************************************************************/
-PCOL TDBXML::InsertSpecialColumn(PGLOBAL g, PCOL colp)
+PCOL TDBXML::InsertSpecialColumn(PCOL colp)
{
if (!colp->IsSpecial())
return NULL;
@@ -854,7 +835,6 @@ bool TDBXML::Initialize(PGLOBAL g)
To_Xb = Docp->LinkXblock(g, Mode, rc, filename);
// Add a CONNECT comment node
-// sprintf(buf, " Created by CONNECT %s ", version);
strcpy(buf, " Created by the MariaDB CONNECT Storage Engine");
Docp->AddComment(g, buf);
@@ -898,7 +878,7 @@ bool TDBXML::Initialize(PGLOBAL g)
Nlist = TabNode->GetChildElements(g);
Docp->SetNofree(true); // For libxml2
-#if defined(WIN32)
+#if defined(__WIN__)
} catch(_com_error e) {
// We come here if a DOM command threw an error
char buf[128];
@@ -912,7 +892,7 @@ bool TDBXML::Initialize(PGLOBAL g)
sprintf(g->Message, "%s hr=%p", MSG(COM_ERROR), e.Error());
goto error;
-#endif // WIN32
+#endif // __WIN__
#if !defined(UNIX)
} catch(...) {
// Other errors
@@ -1037,7 +1017,7 @@ int TDBXML::GetMaxSize(PGLOBAL g)
else
MaxSize = 10;
- } // endif MaxSize
+ } // endif MaxSize
return MaxSize;
} // end of GetMaxSize
@@ -1278,8 +1258,7 @@ void TDBXML::CloseDB(PGLOBAL g)
{
if (Docp) {
if (Changed) {
- char filename[_MAX_PATH];
-// PDBUSER dup = (PDBUSER)g->Activityp->Aptr;
+ char filename[_MAX_PATH];
// We used the file name relative to recorded datapath
PlugSetPath(filename, Xfile, GetPath());
@@ -1321,7 +1300,6 @@ void TDBXML::CloseDB(PGLOBAL g)
NewRow = false;
Hasnod = false;
Write = false;
-// Bufdone = false;
Nodedone = false;
Void = false;
Nrow = -1;
@@ -1413,8 +1391,6 @@ bool XMLCOL::AllocBuf(PGLOBAL g, bool mode)
if (Valbuf)
return false; // Already done
-//Valbuf = (char*)PlugSubAlloc(g, NULL, Long + 1);
-//Valbuf[Long] = '\0';
return ParseXpath(g, mode);
} // end of AllocBuf
@@ -1506,8 +1482,6 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode)
// HTML like table, columns are retrieved by position
new(this) XPOSCOL(Value); // Change the class of this column
Inod = -1;
-// Tdbp->Hasnod = true;
-// return false;
} else if (Type == 0 && !mode) {
strcat(strcat(pbuf, "@"), Name);
} else { // Type == 1
@@ -1657,7 +1631,6 @@ void XMLCOL::WriteColumn(PGLOBAL g)
int done = 0;
int i, n, k = 0;
PXNODE TopNode = NULL;
-//PXATTR AttNode = NULL;
if (trace > 1)
htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n",
@@ -1689,7 +1662,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
/*********************************************************************/
/* Null values are represented by no node. */
/*********************************************************************/
- if (Value->IsNull())
+ if (Value->IsNull())
return;
/*********************************************************************/
@@ -1892,7 +1865,6 @@ void XMULCOL::WriteColumn(PGLOBAL g)
int done = 0;
int i, n, len, k = 0;
PXNODE TopNode = NULL;
-//PXATTR AttNode = NULL;
if (trace)
htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n",
@@ -2190,7 +2162,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp)
{
Topt = tdp->GetTopt();
- Dp = tdp->GetPath();
+ Db = (char*)tdp->GetDB();
Tabn = tdp->Tabname;
} // end of TDBXCT constructor
@@ -2199,7 +2171,7 @@ TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp)
/***********************************************************************/
PQRYRES TDBXCT::GetResult(PGLOBAL g)
{
- return XMLColumns(g, Dp, Tabn, Topt, false);
+ return XMLColumns(g, Db, Tabn, Topt, false);
} // end of GetResult
/* ------------------------ End of Tabxml ---------------------------- */
diff --git a/storage/connect/tabxml.h b/storage/connect/tabxml.h
index f6cfd3fb510..7ba3166881d 100644
--- a/storage/connect/tabxml.h
+++ b/storage/connect/tabxml.h
@@ -1,7 +1,7 @@
/*************** Tabxml H Declares Source Code File (.H) ***************/
/* Name: TABXML.H Version 1.6 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */
+/* (C) Copyright to the author Olivier BERTRAND 2007-2015 */
/* */
/* This file contains the XML table classes declares. */
/***********************************************************************/
@@ -84,7 +84,7 @@ class DllExport TDBXML : public TDBASE {
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
- virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp);
+ virtual PCOL InsertSpecialColumn(PCOL colp);
//virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;}
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
@@ -255,8 +255,7 @@ class TDBXCT : public TDBCAT {
// Members
PTOS Topt;
- char *Dp;
-//const char *Fn;
+ char *Db;
char *Tabn;
}; // end of class TDBXCT
diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc
index 4affe447b00..34d192361a5 100644
--- a/storage/connect/user_connect.cc
+++ b/storage/connect/user_connect.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) Olivier Bertrand 2004 - 2014
+/* Copyright (C) Olivier Bertrand 2004 - 2015
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
*/
/****************************************************************************/
-/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2014 */
+/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2015 */
/****************************************************************************/
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
@@ -63,7 +63,7 @@ void SetWorkSize(uint);
/****************************************************************************/
/* Constructor. */
/****************************************************************************/
-user_connect::user_connect(THD *thd, const char *dbn)
+user_connect::user_connect(THD *thd)
{
thdp= thd;
next= NULL;
diff --git a/storage/connect/user_connect.h b/storage/connect/user_connect.h
index 44e4e94fa8a..7f37973f378 100644
--- a/storage/connect/user_connect.h
+++ b/storage/connect/user_connect.h
@@ -45,7 +45,7 @@ class user_connect
friend int connect_done_func(void *);
public:
// Constructor
- user_connect(THD *thd, const char *dbn);
+ user_connect(THD *thd);
// Destructor
virtual ~user_connect();
diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp
index e731ad156d9..5fefcba5856 100644
--- a/storage/connect/valblk.cpp
+++ b/storage/connect/valblk.cpp
@@ -23,7 +23,7 @@
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
#else
#include "osutil.h"
@@ -132,7 +132,7 @@ VALBLK::VALBLK(void *mp, int type, int nval, bool un)
/***********************************************************************/
/* Raise error for numeric types. */
/***********************************************************************/
-PSZ VALBLK::GetCharValue(int n)
+PSZ VALBLK::GetCharValue(int)
{
PGLOBAL& g = Global;
@@ -145,7 +145,7 @@ PSZ VALBLK::GetCharValue(int n)
/***********************************************************************/
/* Set format so formatted dates can be converted on input. */
/***********************************************************************/
-bool VALBLK::SetFormat(PGLOBAL g, PSZ fmt, int len, int year)
+bool VALBLK::SetFormat(PGLOBAL g, PSZ, int, int)
{
sprintf(g->Message, MSG(NO_DATE_FMT), Type);
return true;
@@ -752,7 +752,7 @@ double CHRBLK::GetFloatValue(int n)
/***********************************************************************/
/* STRING GetCharString: get string representation of a char value. */
/***********************************************************************/
-char *CHRBLK::GetCharString(char *p, int n)
+char *CHRBLK::GetCharString(char *, int n)
{
return (char *)GetValPtrEx(n);
} // end of GetCharString
diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h
index 5a98257f98f..f6eb7258a77 100644
--- a/storage/connect/valblk.h
+++ b/storage/connect/valblk.h
@@ -95,17 +95,17 @@ class VALBLK : public BLOCK {
virtual bool IsCi(void) {return false;}
// Methods
- virtual void SetValue(short sval, int n) {assert(false);}
- virtual void SetValue(ushort sval, int n) {assert(false);}
- virtual void SetValue(int lval, int n) {assert(false);}
- virtual void SetValue(uint lval, int n) {assert(false);}
- virtual void SetValue(longlong lval, int n) {assert(false);}
- virtual void SetValue(ulonglong lval, int n) {assert(false);}
- virtual void SetValue(double fval, int n) {assert(false);}
- virtual void SetValue(char cval, int n) {assert(false);}
- virtual void SetValue(uchar cval, int n) {assert(false);}
- virtual void SetValue(PSZ sp, int n) {assert(false);}
- virtual void SetValue(char *sp, uint len, int n) {assert(false);}
+ virtual void SetValue(short, int) {assert(false);}
+ virtual void SetValue(ushort, int) {assert(false);}
+ virtual void SetValue(int, int) {assert(false);}
+ virtual void SetValue(uint, int) {assert(false);}
+ virtual void SetValue(longlong, int) {assert(false);}
+ virtual void SetValue(ulonglong, int) {assert(false);}
+ virtual void SetValue(double, int) {assert(false);}
+ virtual void SetValue(char, int) {assert(false);}
+ virtual void SetValue(uchar, int) {assert(false);}
+ virtual void SetValue(PSZ, int) {assert(false);}
+ virtual void SetValue(char *, uint, int) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0;
virtual void SetValue(PVBLK pv, int n1, int n2) = 0;
virtual void SetMin(PVAL valp, int n) = 0;
@@ -271,7 +271,7 @@ class STRBLK : public VALBLK {
// Implementation
virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}}
virtual bool IsNull(int n) {return Strp[n] == NULL;}
- virtual void SetNullable(bool b) {} // Always nullable
+ virtual void SetNullable(bool) {} // Always nullable
virtual bool Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(PSZ);}
virtual PSZ GetCharValue(int n) {return Strp[n];}
@@ -284,7 +284,7 @@ class STRBLK : public VALBLK {
virtual longlong GetBigintValue(int n);
virtual ulonglong GetUBigintValue(int n);
virtual double GetFloatValue(int n) {return atof(Strp[n]);}
- virtual char *GetCharString(char *p, int n) {return Strp[n];}
+ virtual char *GetCharString(char *, int n) {return Strp[n];}
virtual void Reset(int n) {Strp[n] = NULL;}
// Methods
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp
index d14fc367cc7..03ec0eb8e40 100644
--- a/storage/connect/value.cpp
+++ b/storage/connect/value.cpp
@@ -30,11 +30,11 @@
#include "sql_class.h"
#include "sql_time.h"
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#include <string.h>
-#endif // !WIN32
+#endif // !__WIN__
#include <math.h>
@@ -77,12 +77,12 @@ int DTVAL::Shift = 0;
/***********************************************************************/
bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool);
-#if !defined(WIN32)
+#if !defined(__WIN__)
extern "C" {
PSZ strupr(PSZ s);
PSZ strlwr(PSZ s);
}
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Get a long long number from its character representation. */
@@ -475,7 +475,7 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
break;
case TYPE_DATE:
- vp = new(g) DTVAL(g, valp->GetIntValue());
+ vp = new(g) DTVAL(valp->GetIntValue());
break;
case TYPE_DOUBLE:
vp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_DOUBLE,
@@ -551,7 +551,7 @@ BYTE VALUE::TestValue(PVAL vp)
/***********************************************************************/
/* Compute a function on a string. */
/***********************************************************************/
-bool VALUE::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
+bool VALUE::Compute(PGLOBAL g, PVAL *, int, OPVAL)
{
strcpy(g->Message, "Compute not implemented for this value type");
return true;
@@ -976,7 +976,7 @@ ulonglong TYPVAL<ulonglong>::MinMaxVal(bool b)
{return (b) ? 0xFFFFFFFFFFFFFFFFLL : 0;}
template <>
-double TYPVAL<double>::MinMaxVal(bool b)
+double TYPVAL<double>::MinMaxVal(bool)
{assert(false); return 0.0;}
template <>
@@ -1566,7 +1566,7 @@ bool TYPVAL<PSZ>::GetBinValue(void *buf, int buflen, bool go)
/***********************************************************************/
/* STRING ShowValue: get string representation of a char value. */
/***********************************************************************/
-char *TYPVAL<PSZ>::ShowValue(char *buf, int len)
+char *TYPVAL<PSZ>::ShowValue(char *, int)
{
return Strp;
} // end of ShowValue
@@ -1574,7 +1574,7 @@ char *TYPVAL<PSZ>::ShowValue(char *buf, int len)
/***********************************************************************/
/* STRING GetCharString: get string representation of a char value. */
/***********************************************************************/
-char *TYPVAL<PSZ>::GetCharString(char *p)
+char *TYPVAL<PSZ>::GetCharString(char *)
{
return Strp;
} // end of GetCharString
@@ -1618,10 +1618,10 @@ int TYPVAL<PSZ>::CompareValue(PVAL vp)
else
n = strcmp(Strp, vp->GetCharValue());
-#if defined(WIN32)
+#if defined(__WIN__)
if (n == _NLSCMPERROR)
return n; // Here we should raise an error
-#endif // WIN32
+#endif // __WIN__
return (n > 0) ? 1 : (n < 0) ? -1 : 0;
} // end of CompareValue
@@ -1681,7 +1681,7 @@ bool TYPVAL<PSZ>::FormatValue(PVAL vp, char *fmt)
/***********************************************************************/
/* STRING SetFormat function (used to set SELECT output format). */
/***********************************************************************/
-bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL g, FORMAT& fmt)
+bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL, FORMAT& fmt)
{
fmt.Type[0] = 'C';
fmt.Length = Len;
@@ -2300,7 +2300,7 @@ char *BINVAL::ShowValue(char *buf, int len)
/***********************************************************************/
/* BINVAL GetCharString: get string representation of a binary value. */
/***********************************************************************/
-char *BINVAL::GetCharString(char *p)
+char *BINVAL::GetCharString(char *)
{
if (!Chrp)
Chrp = (char*)PlugSubAlloc(Global, NULL, Clen * 2 + 1);
@@ -2349,7 +2349,7 @@ bool BINVAL::FormatValue(PVAL vp, char *fmt)
/***********************************************************************/
/* BINVAL SetFormat function (used to set SELECT output format). */
/***********************************************************************/
-bool BINVAL::SetConstFormat(PGLOBAL g, FORMAT& fmt)
+bool BINVAL::SetConstFormat(PGLOBAL, FORMAT& fmt)
{
fmt.Type[0] = 'B';
fmt.Length = Clen;
@@ -2379,7 +2379,7 @@ DTVAL::DTVAL(PGLOBAL g, int n, int prec, PSZ fmt)
/***********************************************************************/
/* DTVAL public constructor from int. */
/***********************************************************************/
-DTVAL::DTVAL(PGLOBAL g, int n) : TYPVAL<int>(n, TYPE_DATE)
+DTVAL::DTVAL(int n) : TYPVAL<int>(n, TYPE_DATE)
{
Pdtp = NULL;
Len = 19;
diff --git a/storage/connect/value.h b/storage/connect/value.h
index c5aeb5c2a2f..780917c9962 100644
--- a/storage/connect/value.h
+++ b/storage/connect/value.h
@@ -36,8 +36,9 @@ typedef struct _datpar *PDTP; // For DTVAL
DllExport PSZ GetTypeName(int);
DllExport int GetTypeSize(int, int);
#ifdef ODBC_SUPPORT
-/* This function is exported for use in EOM table type DLLs */
-DllExport int TranslateSQLType(int stp, int prec, int& len, char& v);
+/* This function is exported for use in OEM table type DLLs */
+DllExport int TranslateSQLType(int stp, int prec,
+ int& len, char& v, bool& w);
#endif
DllExport char *GetFormatType(int);
DllExport int GetFormatType(char);
@@ -94,18 +95,18 @@ class DllExport VALUE : public BLOCK {
virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0;
virtual bool SetValue_char(char *p, int n) = 0;
virtual void SetValue_psz(PSZ s) = 0;
- virtual void SetValue_bool(bool b) {assert(FALSE);}
+ virtual void SetValue_bool(bool) {assert(FALSE);}
virtual int CompareValue(PVAL vp) = 0;
virtual BYTE TestValue(PVAL vp);
- virtual void SetValue(char c) {assert(false);}
- virtual void SetValue(uchar c) {assert(false);}
- virtual void SetValue(short i) {assert(false);}
- virtual void SetValue(ushort i) {assert(false);}
- virtual void SetValue(int n) {assert(false);}
- virtual void SetValue(uint n) {assert(false);}
- virtual void SetValue(longlong n) {assert(false);}
- virtual void SetValue(ulonglong n) {assert(false);}
- virtual void SetValue(double f) {assert(false);}
+ virtual void SetValue(char) {assert(false);}
+ virtual void SetValue(uchar) {assert(false);}
+ virtual void SetValue(short) {assert(false);}
+ virtual void SetValue(ushort) {assert(false);}
+ virtual void SetValue(int) {assert(false);}
+ virtual void SetValue(uint) {assert(false);}
+ virtual void SetValue(longlong) {assert(false);}
+ virtual void SetValue(ulonglong) {assert(false);}
+ virtual void SetValue(double) {assert(false);}
virtual void SetValue_pvblk(PVBLK blk, int n) = 0;
virtual void SetBinValue(void *p) = 0;
virtual bool GetBinValue(void *buf, int buflen, bool go) = 0;
@@ -338,7 +339,7 @@ class DllExport BINVAL: public VALUE {
virtual void SetValue(double f);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual int CompareValue(PVAL vp) {assert(false); return 0;}
+ virtual int CompareValue(PVAL) {assert(false); return 0;}
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual bool IsEqual(PVAL vp, bool chktype);
@@ -359,14 +360,9 @@ class DllExport DTVAL : public TYPVAL<int> {
public:
// Constructors
DTVAL(PGLOBAL g, int n, int p, PSZ fmt);
- DTVAL(PGLOBAL g, PSZ s, int n);
- DTVAL(PGLOBAL g, short i);
- DTVAL(PGLOBAL g, int n);
- DTVAL(PGLOBAL g, longlong n);
- DTVAL(PGLOBAL g, double f);
+ DTVAL(int n);
// Implementation
- virtual bool IsZero(void) {return Null;}
virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual bool SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s);
diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp
index 024a9c081cd..a2d75cec8ab 100755
--- a/storage/connect/xindex.cpp
+++ b/storage/connect/xindex.cpp
@@ -1,7 +1,7 @@
/***************** Xindex C++ Class Xindex Code (.CPP) *****************/
/* Name: XINDEX.CPP Version 2.9 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
/* */
/* This file contains the class XINDEX implementation code. */
/***********************************************************************/
@@ -10,12 +10,12 @@
/* Include relevant sections of the System header files. */
/***********************************************************************/
#include "my_global.h"
-#if defined(WIN32)
+#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
#include <errno.h>
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
#if defined(UNIX)
#include <sys/types.h>
#include <sys/stat.h>
@@ -25,7 +25,7 @@
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include required application header files */
@@ -179,7 +179,7 @@ XXBASE::XXBASE(PTDBDOS tbxp, bool b) : CSORT(b),
/***********************************************************************/
/* Make file output of XINDEX contents. */
/***********************************************************************/
-void XXBASE::Print(PGLOBAL g, FILE *f, uint n)
+void XXBASE::Print(PGLOBAL, FILE *f, uint n)
{
char m[64];
@@ -191,7 +191,7 @@ void XXBASE::Print(PGLOBAL g, FILE *f, uint n)
/***********************************************************************/
/* Make string output of XINDEX contents. */
/***********************************************************************/
-void XXBASE::Print(PGLOBAL g, char *ps, uint z)
+void XXBASE::Print(PGLOBAL, char *ps, uint z)
{
*ps = '\0';
strncat(ps, "Xindex", z);
@@ -287,7 +287,7 @@ int XINDEX::Qcompare(int *i1, int *i2)
/* Sure enough, it is done while records are read and permit to avoid */
/* reading the table while doing the join (Dynamic index only) */
/***********************************************************************/
-bool XINDEX::AddColumns(PIXDEF xdp)
+bool XINDEX::AddColumns(void)
{
if (!Dynamic)
return false; // Not applying to static index
@@ -340,6 +340,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
} // endif n
+ if (trace)
+ htrc("XINDEX Make: n=%d\n", n);
+
// File position must be stored
Record.Size = n * sizeof(int);
@@ -377,7 +380,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
To_LastCol = prev;
- if (AddColumns(sxp)) {
+ if (AddColumns()) {
PCOL kolp = To_Cols[0]; // Temporary while imposing Nk = 1
i = 0;
@@ -477,6 +480,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
} else
To_Rec[nkey] = Tdbp->GetRecpos();
+ if (trace > 1)
+ htrc("Make: To_Rec[%d]=%d\n", nkey, To_Rec[nkey]);
+
/*******************************************************************/
/* Get the keys and place them in the key blocks. */
/*******************************************************************/
@@ -733,7 +739,7 @@ int XINDEX::ColMaxSame(PXCOL kp)
/* Reorder: use the sort index to reorder the data in storage so */
/* it will be physically sorted and sort index can be removed. */
/***********************************************************************/
-bool XINDEX::Reorder(PGLOBAL g)
+bool XINDEX::Reorder(PGLOBAL g __attribute__((unused)))
{
register int i, j, k, n;
bool sorted = true;
@@ -835,7 +841,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
if ((sep = defp->GetBoolCatInfo("SepIndex", false))) {
// Index is saved in a separate file
-#if !defined(UNIX)
+#if defined(__WIN__)
char drive[_MAX_DRIVE];
#else
char *drive = NULL;
@@ -988,7 +994,7 @@ bool XINDEX::Init(PGLOBAL g)
if (defp->SepIndex()) {
// Index was saved in a separate file
-#if !defined(UNIX)
+#if defined(__WIN__)
char drive[_MAX_DRIVE];
#else
char *drive = NULL;
@@ -1241,7 +1247,7 @@ bool XINDEX::MapInit(PGLOBAL g)
if (defp->SepIndex()) {
// Index was save in a separate file
-#if !defined(UNIX)
+#if defined(__WIN__)
char drive[_MAX_DRIVE];
#else
char *drive = NULL;
@@ -1454,7 +1460,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk)
if (defp->SepIndex()) {
// Index was saved in a separate file
-#if !defined(UNIX)
+#if defined(__WIN__)
char drive[_MAX_DRIVE];
#else
char *drive = NULL;
@@ -1585,7 +1591,7 @@ int XINDEX::Range(PGLOBAL g, int limit, bool incl)
if (++i == Nval) break;
} // endfor kp
- if ((k = FastFind(Nval)) < Num_K)
+ if ((k = FastFind()) < Num_K)
n = k;
// if (limit)
// n = (Mul) ? k : kp->Val_K;
@@ -1759,6 +1765,9 @@ int XINDEX::Fetch(PGLOBAL g)
if (Num_K == 0)
return -1; // means end of file
+ if (trace > 1)
+ htrc("XINDEX Fetch: Op=%d\n", Op);
+
/*********************************************************************/
/* Table read through a sorted index. */
/*********************************************************************/
@@ -1776,9 +1785,6 @@ int XINDEX::Fetch(PGLOBAL g)
break;
case OP_SAME: // Read next same
// Logically the key values should be the same as before
- if (trace > 1)
- htrc("looking for next same value\n");
-
if (NextVal(true)) {
Op = OP_EQ;
return -2; // no more equal values
@@ -1824,9 +1830,9 @@ int XINDEX::Fetch(PGLOBAL g)
Nth++;
if (trace > 1)
- htrc("Fetch: Looking for new value\n");
+ htrc("Fetch: Looking for new value Nth=%d\n", Nth);
- Cur_K = FastFind(Nval);
+ Cur_K = FastFind();
if (Cur_K >= Num_K)
/*************************************************************/
@@ -1857,12 +1863,12 @@ int XINDEX::Fetch(PGLOBAL g)
/* FastFind: Returns the index of matching record in a join using an */
/* optimized algorithm based on dichotomie and optimized comparing. */
/***********************************************************************/
-int XINDEX::FastFind(int nv)
+int XINDEX::FastFind(void)
{
register int curk, sup, inf, i= 0, k, n = 2;
register PXCOL kp, kcp;
- assert((int)nv == Nval);
+//assert((int)nv == Nval);
if (Nblk && Op == OP_EQ) {
// Look in block values to find in which block to search
@@ -1896,6 +1902,10 @@ int XINDEX::FastFind(int nv)
sup = To_KeyCol->Ndf;
} // endif Nblk
+ if (trace > 2)
+ htrc("XINDEX FastFind: Nblk=%d Op=%d inf=%d sup=%d\n",
+ Nblk, Op, inf, sup);
+
for (k = 0, kcp = To_KeyCol; kcp; kcp = kcp->Next) {
while (sup - inf > 1) {
i = (inf + sup) >> 1;
@@ -1970,6 +1980,9 @@ int XINDEX::FastFind(int nv)
curk = (kcp->Kof) ? kcp->Kof[kcp->Val_K] : kcp->Val_K;
} // endfor kcp
+ if (trace > 2)
+ htrc("XINDEX FastFind: curk=%d\n", curk);
+
return curk;
} // end of FastFind
@@ -2018,7 +2031,7 @@ int XINDXS::Range(PGLOBAL g, int limit, bool incl)
/*********************************************************************/
if (xp->GetType() == TYPE_CONST) {
kp->Valp->SetValue_pval(xp->GetValue(), !kp->Prefix);
- k = FastFind(Nval);
+ k = FastFind();
if (k < Num_K || Op != OP_EQ)
if (limit)
@@ -2043,8 +2056,7 @@ int XINDXS::GroupSize(void)
#if defined(_DEBUG)
assert(To_KeyCol->Val_K >= 0 && To_KeyCol->Val_K < Ndif);
#endif // _DEBUG
- return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K]
- : 1;
+ return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] : 1;
} // end of GroupSize
/***********************************************************************/
@@ -2106,6 +2118,9 @@ int XINDXS::Fetch(PGLOBAL g)
if (Num_K == 0)
return -1; // means end of file
+ if (trace > 1)
+ htrc("XINDXS Fetch: Op=%d\n", Op);
+
/*********************************************************************/
/* Table read through a sorted index. */
/*********************************************************************/
@@ -2120,9 +2135,6 @@ int XINDXS::Fetch(PGLOBAL g)
Op = OP_NEXT;
break;
case OP_SAME: // Read next same
- if (trace > 1)
- htrc("looking for next same value\n");
-
if (!Mul || NextVal(true)) {
Op = OP_EQ;
return -2; // No more equal values
@@ -2160,9 +2172,9 @@ int XINDXS::Fetch(PGLOBAL g)
Nth++;
if (trace > 1)
- htrc("Fetch: Looking for new value\n");
+ htrc("Fetch: Looking for new value Nth=%d\n", Nth);
- Cur_K = FastFind(1);
+ Cur_K = FastFind();
if (Cur_K >= Num_K)
// Rank not whithin index table, signal record not found
@@ -2190,9 +2202,9 @@ int XINDXS::Fetch(PGLOBAL g)
/* FastFind: Returns the index of matching indexed record using an */
/* optimized algorithm based on dichotomie and optimized comparing. */
/***********************************************************************/
-int XINDXS::FastFind(int nk)
+int XINDXS::FastFind(void)
{
- register int sup, inf, i= 0, n = 2;
+ register int sup, inf, i= 0, n = 2;
register PXCOL kcp = To_KeyCol;
if (Nblk && Op == OP_EQ) {
@@ -2215,7 +2227,6 @@ int XINDXS::FastFind(int nk)
if (inf < 0)
return Num_K;
-// i = inf;
inf *= Sblk;
if ((sup = inf + Sblk) > Ndif)
@@ -2227,6 +2238,10 @@ int XINDXS::FastFind(int nk)
sup = Ndif;
} // endif Nblk
+ if (trace > 2)
+ htrc("XINDXS FastFind: Nblk=%d Op=%d inf=%d sup=%d\n",
+ Nblk, Op, inf, sup);
+
while (sup - inf > 1) {
i = (inf + sup) >> 1;
@@ -2249,6 +2264,9 @@ int XINDXS::FastFind(int nk)
n = 0;
} // endif sup
+ if (trace > 2)
+ htrc("XINDXS FastFind: n=%d i=%d\n", n, i);
+
// Loop on kcp because of dynamic indexing
for (; kcp; kcp = kcp->Next)
kcp->Val_K = i; // Used by FillValue
@@ -2330,6 +2348,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
} // endif
NewOff.Low = (int)ftell(Xfile);
+
+ if (trace)
+ htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low);
+
} else if (mode == MODE_WRITE) {
if (id >= 0) {
// New not sep index file. Write the header.
@@ -2337,6 +2359,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
Write(g, noff, sizeof(IOFF), MAX_INDX, rc);
fseek(Xfile, 0, SEEK_END);
NewOff.Low = (int)ftell(Xfile);
+
+ if (trace)
+ htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low);
+
} // endif id
} else if (mode == MODE_READ && id >= 0) {
@@ -2346,6 +2372,9 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
return true;
} // endif MAX_INDX
+ if (trace)
+ htrc("XFILE Open: noff[%d].Low=%d\n", id, noff[id].Low);
+
// Position the cursor at the offset of this index
if (fseek(Xfile, noff[id].Low, SEEK_SET)) {
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek");
@@ -2360,7 +2389,8 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
/***********************************************************************/
/* Move into an index file. */
/***********************************************************************/
-bool XFILE::Seek(PGLOBAL g, int low, int high, int origin)
+bool XFILE::Seek(PGLOBAL g, int low, int high __attribute__((unused)),
+ int origin)
{
#if defined(_DEBUG)
assert(high == 0);
@@ -2371,7 +2401,6 @@ bool XFILE::Seek(PGLOBAL g, int low, int high, int origin)
return true;
} // endif
-//ftell(Xfile);
return false;
} // end of Seek
@@ -2479,7 +2508,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
if (trace)
htrc(" Xopen: filename=%s id=%d mode=%d\n", filename, id, mode);
-#if defined(WIN32)
+#if defined(__WIN__)
LONG high = 0;
DWORD rc, drc, access, share, creation;
@@ -2655,7 +2684,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
/***********************************************************************/
bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin)
{
-#if defined(WIN32)
+#if defined(__WIN__)
LONG hi = high;
DWORD rc = SetFilePointer(Hfile, low, &hi, origin);
@@ -2691,7 +2720,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
{
bool rc = false;
-#if defined(WIN32)
+#if defined(__WIN__)
bool brc;
DWORD nbr, count = (DWORD)(n * size);
@@ -2737,7 +2766,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
/***********************************************************************/
int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc)
{
-#if defined(WIN32)
+#if defined(__WIN__)
bool brc;
DWORD nbw, count = (DWORD)n * (DWORD) size;
@@ -2779,7 +2808,7 @@ void XHUGE::Close(char *fn, int id)
if (trace)
htrc("XHUGE::Close: fn=%s id=%d NewOff=%lld\n", fn, id, NewOff.Val);
-#if defined(WIN32)
+#if defined(__WIN__)
if (id >= 0 && fn) {
CloseFileHandle(Hfile);
Hfile = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, NULL,
@@ -2794,7 +2823,7 @@ void XHUGE::Close(char *fn, int id)
} // endif SetFilePointer
} // endif id
-#else // !WIN32
+#else // !__WIN__
if (id >= 0 && fn) {
if (Hfile != INVALID_HANDLE_VALUE) {
if (lseek64(Hfile, id * sizeof(IOFF), SEEK_SET) >= 0) {
@@ -2810,7 +2839,7 @@ void XHUGE::Close(char *fn, int id)
htrc("(XHUGE)error reopening %s: %s\n", fn, strerror(errno));
} // endif id
-#endif // !WIN32
+#endif // !__WIN__
XLOAD::Close();
} // end of Close
@@ -2819,7 +2848,7 @@ void XHUGE::Close(char *fn, int id)
/***********************************************************************/
/* Don't know whether this is possible for huge files. */
/***********************************************************************/
-void *XHUGE::FileView(PGLOBAL g, char *fn)
+void *XHUGE::FileView(PGLOBAL g, char *)
{
strcpy(g->Message, MSG(NO_PART_MAP));
return NULL;
@@ -2879,7 +2908,7 @@ bool XXROW::Init(PGLOBAL g)
/***********************************************************************/
/* RANGE: Tell how many record exist in a given value range. */
/***********************************************************************/
-int XXROW::Range(PGLOBAL g, int limit, bool incl)
+int XXROW::Range(PGLOBAL, int limit, bool incl)
{
int n = Valp->GetIntValue();
@@ -2895,7 +2924,7 @@ int XXROW::Range(PGLOBAL g, int limit, bool incl)
/***********************************************************************/
/* XXROW: Fetch a physical or logical record. */
/***********************************************************************/
-int XXROW::Fetch(PGLOBAL g)
+int XXROW::Fetch(PGLOBAL)
{
if (Num_K == 0)
return -1; // means end of file
@@ -2904,7 +2933,7 @@ int XXROW::Fetch(PGLOBAL g)
/* Look for a key equal to the link column of previous table, */
/* and return its rank whithin the index table. */
/*********************************************************************/
- Cur_K = FastFind(1);
+ Cur_K = FastFind();
if (Cur_K >= Num_K)
/*******************************************************************/
@@ -2926,7 +2955,7 @@ int XXROW::Fetch(PGLOBAL g)
/***********************************************************************/
/* FastFind: Returns the index of matching record in a join. */
/***********************************************************************/
-int XXROW::FastFind(int nk)
+int XXROW::FastFind(void)
{
int n = Valp->GetIntValue();
@@ -3158,12 +3187,18 @@ bool KXYCOL::InitFind(PGLOBAL g, PXOB xp)
xp->Reset();
xp->Eval(g);
Valp->SetValue_pval(xp->GetValue(), false);
-// Valp->SetValue_pval(xp->GetValue(), !Prefix);
} // endif Type
+ if (trace > 1) {
+ char buf[32];
+
+ htrc("KCOL InitFind: value=%s\n", Valp->GetCharString(buf));
+ } // endif trace
+
return false;
} // end of InitFind
+#if 0
/***********************************************************************/
/* InitBinFind: initialize Value to the value pointed by vp. */
/***********************************************************************/
@@ -3171,6 +3206,7 @@ void KXYCOL::InitBinFind(void *vp)
{
Valp->SetBinValue(vp);
} // end of InitBinFind
+#endif // 0
/***********************************************************************/
/* KXYCOL FillValue: called by COLBLK::Eval when a column value is */
diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h
index 6e40e9b160e..51b678992ea 100644
--- a/storage/connect/xindex.h
+++ b/storage/connect/xindex.h
@@ -1,7 +1,7 @@
/*************** Xindex H Declares Source Code File (.H) ***************/
/* Name: XINDEX.H Version 3.5 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2004 - 2013 */
+/* (C) Copyright to the author Olivier BERTRAND 2004 - 2015 */
/* */
/* This file contains the XINDEX class declares. */
/***********************************************************************/
@@ -65,7 +65,11 @@ typedef struct index_def : public BLOCK {
typedef struct index_off {
union {
+#if defined(WORDS_BIGENDIAN)
+ struct {int High; int Low;};
+#else // !WORDS_BIGENDIAN
struct {int Low; int High;};
+#endif //!WORDS_BIGENDIAN
longlong Val; // File position
}; // end of union
} IOFF;
@@ -205,12 +209,11 @@ class DllExport XXBASE : public CSORT, public BLOCK {
#endif // XMAP
virtual int MaxRange(void) {return 1;}
virtual int Fetch(PGLOBAL g) = 0;
- virtual bool NextVal(bool eq) {return true;}
+ virtual bool NextVal(bool) {return true;}
virtual bool PrevVal(void) {return true;}
- virtual int FastFind(int nk) = 0;
- virtual bool Reorder(PGLOBAL g) {return true;}
- virtual int Range(PGLOBAL g, int limit = 0, bool incl = true)
- {return -1;} // Means error
+ virtual int FastFind(void) = 0;
+ virtual bool Reorder(PGLOBAL) {return true;}
+ virtual int Range(PGLOBAL, int = 0, bool = true) {return -1;} // Means error
virtual int Qcompare(int *, int *) = 0;
virtual int GroupSize(void) {return 1;}
virtual void Close(void) = 0;
@@ -266,7 +269,7 @@ class DllExport XINDEX : public XXBASE {
#endif // XMAP
virtual int Qcompare(int *, int *);
virtual int Fetch(PGLOBAL g);
- virtual int FastFind(int nk);
+ virtual int FastFind(void);
virtual int GroupSize(void);
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int MaxRange(void) {return MaxSame;}
@@ -280,7 +283,7 @@ class DllExport XINDEX : public XXBASE {
bool GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk);
protected:
- bool AddColumns(PIXDEF xdp);
+ bool AddColumns(void);
bool NextValDif(void);
// Members
@@ -312,7 +315,7 @@ class DllExport XINDXS : public XINDEX {
// Methods
virtual int Qcompare(int *, int *);
virtual int Fetch(PGLOBAL g);
- virtual int FastFind(int nk);
+ virtual int FastFind(void);
virtual bool NextVal(bool eq);
virtual bool PrevVal(void);
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
@@ -347,7 +350,7 @@ class DllExport XLOAD : public BLOCK {
protected:
// Members
-#if defined(WIN32)
+#if defined(__WIN__)
HANDLE Hfile; // Handle to file or map
#else // UNIX
int Hfile; // Descriptor to file or map
@@ -421,14 +424,14 @@ class DllExport XXROW : public XXBASE {
// Methods
virtual bool Init(PGLOBAL g);
#if defined(XMAP)
- virtual bool MapInit(PGLOBAL g) {return true;}
+ virtual bool MapInit(PGLOBAL) {return true;}
#endif // XMAP
virtual int Fetch(PGLOBAL g);
- virtual int FastFind(int nk);
+ virtual int FastFind(void);
virtual int MaxRange(void) {return 1;}
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int Qcompare(int *, int *) {assert(false); return 0;}
- virtual bool Make(PGLOBAL g, PIXDEF sxp) {return false;}
+ virtual bool Make(PGLOBAL, PIXDEF) {return false;}
virtual void Close(void) {}
protected:
@@ -463,7 +466,7 @@ class KXYCOL: public BLOCK {
virtual void FreeData(void);
virtual void FillValue(PVAL valp);
virtual int CompVal(int i);
- void InitBinFind(void *vp);
+// void InitBinFind(void *vp);
bool MakeBlockArray(PGLOBAL g, int nb, int size);
int Compare(int i1, int i2);
int CompBval(int i);
diff --git a/storage/connect/xobject.cpp b/storage/connect/xobject.cpp
index 92bf039c07c..a6faebf3c2b 100644
--- a/storage/connect/xobject.cpp
+++ b/storage/connect/xobject.cpp
@@ -11,6 +11,7 @@
/* Include mariaDB header file. */
/***********************************************************************/
#include "my_global.h"
+#include "m_string.h"
/***********************************************************************/
/* Include required application header files */
diff --git a/storage/connect/xobject.h b/storage/connect/xobject.h
index 8e2358dd526..82ff9e21225 100644
--- a/storage/connect/xobject.h
+++ b/storage/connect/xobject.h
@@ -42,9 +42,9 @@ class DllExport XOBJECT : public BLOCK {
virtual int GetResultType(void) {return TYPE_VOID;}
virtual int GetKey(void) {return 0;}
#if defined(_DEBUG)
- virtual void SetKey(int k) {assert(false);}
+ virtual void SetKey(int) {assert(false);}
#else // !_DEBUG
- virtual void SetKey(int k) {} // Only defined for COLBLK
+ virtual void SetKey(int) {} // Only defined for COLBLK
#endif // !_DEBUG
virtual int GetLength(void) = 0;
virtual int GetLengthEx(void) = 0;
diff --git a/storage/connect/xtable.h b/storage/connect/xtable.h
index d1ea2b0d85f..1a75d97bafa 100644
--- a/storage/connect/xtable.h
+++ b/storage/connect/xtable.h
@@ -77,21 +77,21 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
virtual int GetTdb_No(void) {return Tdb_No;}
virtual PTDB GetNext(void) {return Next;}
virtual PCATLG GetCat(void) {return NULL;}
- virtual void SetAbort(bool b) {;}
+ virtual void SetAbort(bool) {;}
// Methods
virtual bool IsSame(PTDB tp) {return tp == this;}
virtual bool IsSpecial(PSZ name) = 0;
- virtual bool GetBlockValues(PGLOBAL g) {return false;}
- virtual int Cardinality(PGLOBAL g) {return 0;}
+ virtual bool GetBlockValues(PGLOBAL) {return false;}
+ virtual int Cardinality(PGLOBAL) {return 0;}
virtual int GetMaxSize(PGLOBAL) = 0;
virtual int GetProgMax(PGLOBAL) = 0;
virtual int GetProgCur(void) = 0;
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual bool IsReadOnly(void) {return true;}
virtual const CHARSET_INFO *data_charset() {return NULL;}
- virtual PTDB Duplicate(PGLOBAL g) {return NULL;}
- virtual PTDB CopyOne(PTABS t) {return this;}
+ virtual PTDB Duplicate(PGLOBAL) {return NULL;}
+ virtual PTDB CopyOne(PTABS) {return this;}
virtual PTDB Copy(PTABS t);
virtual void PrintAM(FILE *f, char *m)
{fprintf(f, "%s AM(%d)\n", m, GetAmType());}
@@ -108,7 +108,7 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
virtual int WriteDB(PGLOBAL) = 0;
virtual int DeleteDB(PGLOBAL, int) = 0;
virtual void CloseDB(PGLOBAL) = 0;
- virtual int CheckWrite(PGLOBAL g) {return 0;}
+ virtual int CheckWrite(PGLOBAL) {return 0;}
virtual bool ReadKey(PGLOBAL, OPVAL, const void *, int) = 0;
protected:
@@ -155,7 +155,7 @@ class DllExport TDBASE : public TDB {
PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;}
// Methods
- virtual bool IsUsingTemp(PGLOBAL g) {return false;}
+ virtual bool IsUsingTemp(PGLOBAL) {return false;}
virtual bool IsIndexed(void) {return false;}
virtual bool IsSpecial(PSZ name);
virtual PCATLG GetCat(void);
@@ -170,9 +170,9 @@ class DllExport TDBASE : public TDB {
virtual CHARSET_INFO *data_charset(void);
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
virtual int GetProgCur(void) {return GetRecpos();}
- virtual PSZ GetFile(PGLOBAL g) {return "Not a file";}
+ virtual PSZ GetFile(PGLOBAL) {return "Not a file";}
virtual int GetRemote(void) {return 0;}
- virtual void SetFile(PGLOBAL g, PSZ fn) {}
+ virtual void SetFile(PGLOBAL, PSZ) {}
virtual void ResetDB(void) {}
virtual void ResetSize(void) {MaxSize = -1;}
virtual void RestoreNrec(void) {}
@@ -183,12 +183,12 @@ class DllExport TDBASE : public TDB {
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
virtual PCOL MakeCol(PGLOBAL, PCOLDEF, PCOL, int)
{assert(false); return NULL;}
- virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp);
+ virtual PCOL InsertSpecialColumn(PCOL colp);
virtual PCOL InsertSpcBlk(PGLOBAL g, PCOLDEF cdp);
virtual void MarkDB(PGLOBAL g, PTDB tdb2);
- virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
+ virtual int MakeIndex(PGLOBAL g, PIXDEF, bool)
{strcpy(g->Message, "Remote index"); return RC_INFO;}
- virtual bool ReadKey(PGLOBAL g, OPVAL op, const void *key, int len)
+ virtual bool ReadKey(PGLOBAL, OPVAL, const void *, int)
{assert(false); return true;}
protected:
@@ -225,7 +225,7 @@ class DllExport TDBCAT : public TDBASE {
// Methods
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
- virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
+ virtual int RowNumber(PGLOBAL, bool = false) {return N + 1;}
virtual bool SetRecpos(PGLOBAL g, int recpos);
// Database routines
diff --git a/storage/federatedx/README.windows b/storage/federatedx/README.windows
index 3f1f2a3c79a..74de15c6521 100644
--- a/storage/federatedx/README.windows
+++ b/storage/federatedx/README.windows
@@ -1,23 +1,23 @@
-The following files are changed in order to build a new engine on Windows:
-
-- Update win\configure.js with
-case "WITH_FEDERATEDX_STORAGE_ENGINE":
-to make sure it will pass WITH_FEDERATEDX_STORAGE_ENGINE in.
-
-- Update CMakeFiles.txt under mysql root:
- IF(WITH_FEDERATEDX_STORAGE_ENGINE)
- ADD_DEFINITIONS(-D WITH_FEDERATEDX_STORAGE_ENGINE)
- SET (mysql_plugin_defs
- "${mysql_plugin_defs},builtin_skeleton_plugin")
- ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
-
- and,
-
- IF(WITH_FEDERATEDX_STORAGE_ENGINE)
- ADD_SUBDIRECTORY(storage/skeleton/src)
- ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
-
- - Update CMakeFiles.txt under sql:
- IF(WITH_FEDERATEDX_STORAGE_ENGINE)
- TARGET_LINK_LIBRARIES(mysqld skeleton)
- ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
+The following files are changed in order to build a new engine on Windows:
+
+- Update win\configure.js with
+case "WITH_FEDERATEDX_STORAGE_ENGINE":
+to make sure it will pass WITH_FEDERATEDX_STORAGE_ENGINE in.
+
+- Update CMakeFiles.txt under mysql root:
+ IF(WITH_FEDERATEDX_STORAGE_ENGINE)
+ ADD_DEFINITIONS(-D WITH_FEDERATEDX_STORAGE_ENGINE)
+ SET (mysql_plugin_defs
+ "${mysql_plugin_defs},builtin_skeleton_plugin")
+ ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
+
+ and,
+
+ IF(WITH_FEDERATEDX_STORAGE_ENGINE)
+ ADD_SUBDIRECTORY(storage/skeleton/src)
+ ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
+
+ - Update CMakeFiles.txt under sql:
+ IF(WITH_FEDERATEDX_STORAGE_ENGINE)
+ TARGET_LINK_LIBRARIES(mysqld skeleton)
+ ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
diff --git a/storage/innobase/api/api0api.cc b/storage/innobase/api/api0api.cc
index 8769fc47166..0fe21423232 100644
--- a/storage/innobase/api/api0api.cc
+++ b/storage/innobase/api/api0api.cc
@@ -595,6 +595,21 @@ ib_trx_begin(
return(static_cast<ib_trx_t>(trx));
}
+
+/*****************************************************************//**
+Check if transaction is read_only
+@return transaction read_only status */
+UNIV_INTERN
+ib_u32_t
+ib_trx_read_only(
+/*=============*/
+ ib_trx_t ib_trx) /*!< in: trx handle */
+{
+ trx_t* trx = (trx_t*) ib_trx;
+
+ return(trx->read_only);
+}
+
/*****************************************************************//**
Get the transaction's state.
@return transaction state */
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 287ad154d2f..12115fde7f4 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved.
@@ -495,6 +495,79 @@ buf_page_is_zeroes(
return(true);
}
+/** Checks if the page is in crc32 checksum format.
+@param[in] read_buf database page
+@param[in] checksum_field1 new checksum field
+@param[in] checksum_field2 old checksum field
+@return true if the page is in crc32 checksum format */
+UNIV_INLINE
+bool
+buf_page_is_checksum_valid_crc32(
+ const byte* read_buf,
+ ulint checksum_field1,
+ ulint checksum_field2)
+{
+ ib_uint32_t crc32 = buf_calc_page_crc32(read_buf);
+
+ return(checksum_field1 == crc32 && checksum_field2 == crc32);
+}
+
+/** Checks if the page is in innodb checksum format.
+@param[in] read_buf database page
+@param[in] checksum_field1 new checksum field
+@param[in] checksum_field2 old checksum field
+@return true if the page is in innodb checksum format */
+UNIV_INLINE
+bool
+buf_page_is_checksum_valid_innodb(
+ const byte* read_buf,
+ ulint checksum_field1,
+ ulint checksum_field2)
+{
+ /* There are 2 valid formulas for
+ checksum_field2 (old checksum field) which algo=innodb could have
+ written to the page:
+
+ 1. Very old versions of InnoDB only stored 8 byte lsn to the
+ start and the end of the page.
+
+ 2. Newer InnoDB versions store the old formula checksum
+ (buf_calc_page_old_checksum()). */
+
+ if (checksum_field2 != mach_read_from_4(read_buf + FIL_PAGE_LSN)
+ && checksum_field2 != buf_calc_page_old_checksum(read_buf)) {
+ return(false);
+ }
+
+ /* old field is fine, check the new field */
+
+ /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
+ (always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
+
+ if (checksum_field1 != 0
+ && checksum_field1 != buf_calc_page_new_checksum(read_buf)) {
+ return(false);
+ }
+
+ return(true);
+}
+
+/** Checks if the page is in none checksum format.
+@param[in] read_buf database page
+@param[in] checksum_field1 new checksum field
+@param[in] checksum_field2 old checksum field
+@return true if the page is in none checksum format */
+UNIV_INLINE
+bool
+buf_page_is_checksum_valid_none(
+ const byte* read_buf,
+ ulint checksum_field1,
+ ulint checksum_field2)
+{
+ return(checksum_field1 == checksum_field2
+ && checksum_field1 == BUF_NO_CHECKSUM_MAGIC);
+}
+
/********************************************************************//**
Checks if a page is corrupt.
@return TRUE if corrupted */
@@ -511,8 +584,6 @@ buf_page_is_corrupted(
ulint page_encrypted = fil_page_is_encrypted(read_buf);
ulint checksum_field1;
ulint checksum_field2;
- ibool crc32_inited = FALSE;
- ib_uint32_t crc32 = ULINT32_UNDEFINED;
if (!page_encrypted && !zip_size
&& memcmp(read_buf + FIL_PAGE_LSN + 4,
@@ -595,148 +666,121 @@ buf_page_is_corrupted(
return(FALSE);
}
- switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) {
- case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
-
- crc32 = buf_calc_page_crc32(read_buf);
-
- return(checksum_field1 != crc32 || checksum_field2 != crc32);
-
- case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
-
- return(checksum_field1
- != buf_calc_page_new_checksum(read_buf)
- || checksum_field2
- != buf_calc_page_old_checksum(read_buf));
-
- case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
+ DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
- return(checksum_field1 != BUF_NO_CHECKSUM_MAGIC
- || checksum_field2 != BUF_NO_CHECKSUM_MAGIC);
+ ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET);
+ ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID);
+ const srv_checksum_algorithm_t curr_algo =
+ static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
+ switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_CRC32:
- case SRV_CHECKSUM_ALGORITHM_INNODB:
- /* There are 3 valid formulas for
- checksum_field2 (old checksum field):
-
- 1. Very old versions of InnoDB only stored 8 byte lsn to the
- start and the end of the page.
-
- 2. InnoDB versions before MySQL 5.6.3 store the old formula
- checksum (buf_calc_page_old_checksum()).
-
- 3. InnoDB versions 5.6.3 and newer with
- innodb_checksum_algorithm=strict_crc32|crc32 store CRC32. */
-
- /* since innodb_checksum_algorithm is not strict_* allow
- any of the algos to match for the old field */
-
- if (checksum_field2
- != mach_read_from_4(read_buf + FIL_PAGE_LSN)
- && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) {
-
- /* The checksum does not match any of the
- fast to check. First check the selected algorithm
- for writing checksums because we assume that the
- chance of it matching is higher. */
-
- if (srv_checksum_algorithm
- == SRV_CHECKSUM_ALGORITHM_CRC32) {
-
- crc32 = buf_calc_page_crc32(read_buf);
- crc32_inited = TRUE;
-
- if (checksum_field2 != crc32
- && checksum_field2
- != buf_calc_page_old_checksum(read_buf)) {
+ case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
- return(TRUE);
- }
- } else {
- ut_ad(srv_checksum_algorithm
- == SRV_CHECKSUM_ALGORITHM_INNODB);
+ if (buf_page_is_checksum_valid_crc32(read_buf,
+ checksum_field1, checksum_field2)) {
+ return(FALSE);
+ }
- if (checksum_field2
- != buf_calc_page_old_checksum(read_buf)) {
+ if (buf_page_is_checksum_valid_none(read_buf,
+ checksum_field1, checksum_field2)) {
+ if (curr_algo
+ == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_NONE,
+ space_id, page_no);
+ }
- crc32 = buf_calc_page_crc32(read_buf);
- crc32_inited = TRUE;
+ return(FALSE);
+ }
- if (checksum_field2 != crc32) {
- return(TRUE);
- }
- }
+ if (buf_page_is_checksum_valid_innodb(read_buf,
+ checksum_field1, checksum_field2)) {
+ if (curr_algo
+ == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_INNODB,
+ space_id, page_no);
}
- }
- /* old field is fine, check the new field */
+ return(FALSE);
+ }
- /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
- (always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
+ return(TRUE);
- if (checksum_field1 != 0
- && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) {
+ case SRV_CHECKSUM_ALGORITHM_INNODB:
+ case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
- /* The checksum does not match any of the
- fast to check. First check the selected algorithm
- for writing checksums because we assume that the
- chance of it matching is higher. */
+ if (buf_page_is_checksum_valid_innodb(read_buf,
+ checksum_field1, checksum_field2)) {
+ return(FALSE);
+ }
- if (srv_checksum_algorithm
- == SRV_CHECKSUM_ALGORITHM_CRC32) {
+ if (buf_page_is_checksum_valid_none(read_buf,
+ checksum_field1, checksum_field2)) {
+ if (curr_algo
+ == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_NONE,
+ space_id, page_no);
+ }
- if (!crc32_inited) {
- crc32 = buf_calc_page_crc32(read_buf);
- crc32_inited = TRUE;
- }
+ return(FALSE);
+ }
- if (checksum_field1 != crc32
- && checksum_field1
- != buf_calc_page_new_checksum(read_buf)) {
+ if (buf_page_is_checksum_valid_crc32(read_buf,
+ checksum_field1, checksum_field2)) {
+ if (curr_algo
+ == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_CRC32,
+ space_id, page_no);
+ }
- return(TRUE);
- }
- } else {
- ut_ad(srv_checksum_algorithm
- == SRV_CHECKSUM_ALGORITHM_INNODB);
+ return(FALSE);
+ }
- if (checksum_field1
- != buf_calc_page_new_checksum(read_buf)) {
+ return(TRUE);
- if (!crc32_inited) {
- crc32 = buf_calc_page_crc32(
- read_buf);
- crc32_inited = TRUE;
- }
+ case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
- if (checksum_field1 != crc32) {
- return(TRUE);
- }
- }
- }
+ if (buf_page_is_checksum_valid_none(read_buf,
+ checksum_field1, checksum_field2)) {
+ return(FALSE);
}
- /* If CRC32 is stored in at least one of the fields, then the
- other field must also be CRC32 */
- if (crc32_inited
- && ((checksum_field1 == crc32
- && checksum_field2 != crc32)
- || (checksum_field1 != crc32
- && checksum_field2 == crc32))) {
+ if (buf_page_is_checksum_valid_crc32(read_buf,
+ checksum_field1, checksum_field2)) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_CRC32,
+ space_id, page_no);
+ return(FALSE);
+ }
- return(TRUE);
+ if (buf_page_is_checksum_valid_innodb(read_buf,
+ checksum_field1, checksum_field2)) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_INNODB,
+ space_id, page_no);
+ return(FALSE);
}
- break;
+ return(TRUE);
+
case SRV_CHECKSUM_ALGORITHM_NONE:
/* should have returned FALSE earlier */
- ut_error;
+ break;
/* no default so the compiler will emit a warning if new enum
is added and not handled here */
}
- DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
-
+ ut_error;
return(FALSE);
}
@@ -1823,6 +1867,9 @@ page_found:
goto page_found;
}
+ /* The maximum number of purge threads should never exceed
+ BUF_POOL_WATCH_SIZE. So there is no way for purge thread
+ instance to hold a watch when setting another watch. */
for (i = 0; i < BUF_POOL_WATCH_SIZE; i++) {
bpage = &buf_pool->watch[i];
diff --git a/storage/innobase/buf/buf0checksum.cc b/storage/innobase/buf/buf0checksum.cc
index aa02cda2937..4101d117896 100644
--- a/storage/innobase/buf/buf0checksum.cc
+++ b/storage/innobase/buf/buf0checksum.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -141,14 +141,17 @@ buf_checksum_algorithm_name(
{
switch (algo) {
case SRV_CHECKSUM_ALGORITHM_CRC32:
- case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
return("crc32");
+ case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
+ return("strict_crc32");
case SRV_CHECKSUM_ALGORITHM_INNODB:
- case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
return("innodb");
+ case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
+ return("strict_innodb");
case SRV_CHECKSUM_ALGORITHM_NONE:
- case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return("none");
+ case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
+ return("strict_none");
}
ut_error;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index fe59d076358..b9b8ecd4916 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -544,7 +544,8 @@ ib_cb_t innodb_api_cb[] = {
(ib_cb_t) ib_get_idx_field_name,
(ib_cb_t) ib_trx_get_start_time,
(ib_cb_t) ib_cfg_bk_commit_interval,
- (ib_cb_t) ib_cursor_stmt_begin
+ (ib_cb_t) ib_cursor_stmt_begin,
+ (ib_cb_t) ib_trx_read_only
};
@@ -9190,6 +9191,11 @@ ha_innobase::general_fetch(
DBUG_ENTER("general_fetch");
+ /* If transaction is not startted do not continue, instead return a error code. */
+ if(!(prebuilt->sql_stat_start || (prebuilt->trx && prebuilt->trx->state == 1))) {
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
+
ut_a(prebuilt->trx == thd_to_trx(user_thd));
innobase_srv_conc_enter_innodb(prebuilt->trx);
@@ -12606,6 +12612,13 @@ ha_innobase::estimate_rows_upper_bound()
prebuilt->trx->op_info = "";
+ /* Set num_rows less than MERGEBUFF to simulate the case where we do
+ not have enough space to merge the externally sorted file blocks. */
+ DBUG_EXECUTE_IF("set_num_rows_lt_MERGEBUFF",
+ estimate = 2;
+ DBUG_SET("-d,set_num_rows_lt_MERGEBUFF");
+ );
+
DBUG_RETURN((ha_rows) estimate);
}
@@ -12871,7 +12884,6 @@ ha_innobase::info_low(
dict_table_t* ib_table;
ha_rows rec_per_key;
ib_uint64_t n_rows;
- char path[FN_REFLEN];
os_file_stat_t stat_info;
DBUG_ENTER("info");
@@ -12929,17 +12941,6 @@ ha_innobase::info_low(
"returning various info to MySQL";
}
- my_snprintf(path, sizeof(path), "%s/%s%s",
- mysql_data_home, ib_table->name, reg_ext);
-
- unpack_filename(path,path);
-
- /* Note that we do not know the access time of the table,
- nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
-
- if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) {
- stats.create_time = (ulong) stat_info.ctime;
- }
}
if (flag & HA_STATUS_VARIABLE) {
@@ -13071,6 +13072,7 @@ ha_innobase::info_low(
if (flag & HA_STATUS_CONST) {
ulong i;
+ char path[FN_REFLEN];
/* Verify the number of index in InnoDB and MySQL
matches up. If prebuilt->clust_index_was_generated
holds, InnoDB defines GEN_CLUST_INDEX internally */
@@ -13224,6 +13226,20 @@ ha_innobase::info_low(
if (!(flag & HA_STATUS_NO_LOCK)) {
dict_table_stats_unlock(ib_table, RW_S_LATCH);
}
+
+ my_snprintf(path, sizeof(path), "%s/%s%s",
+ mysql_data_home,
+ table->s->normalized_path.str,
+ reg_ext);
+
+ unpack_filename(path,path);
+
+ /* Note that we do not know the access time of the table,
+ nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
+
+ if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) {
+ stats.create_time = (ulong) stat_info.ctime;
+ }
}
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
diff --git a/storage/innobase/include/api0api.h b/storage/innobase/include/api0api.h
index d77d691becc..e4c9c941de5 100644
--- a/storage/innobase/include/api0api.h
+++ b/storage/innobase/include/api0api.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2011, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -494,6 +494,14 @@ ib_trx_state(
/*=========*/
ib_trx_t ib_trx); /*!< in: trx handle */
+
+/*****************************************************************//**
+Check if the transaction is read_only */
+ib_u32_t
+ib_trx_read_only(
+/*=============*/
+ ib_trx_t ib_trx); /*!< in: trx handle */
+
/*****************************************************************//**
Release the resources of the transaction. If the transaction was
selected as a victim by InnoDB and rolled back then use this function
diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h
index fe6b755dc59..04593f5b754 100644
--- a/storage/innobase/include/os0file.h
+++ b/storage/innobase/include/os0file.h
@@ -1,6 +1,6 @@
/***********************************************************************
-Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2015, MariaDB Corporation.
@@ -387,10 +387,10 @@ to original un-instrumented file I/O APIs */
enum os_file_type_t {
OS_FILE_TYPE_UNKNOWN = 0,
- OS_FILE_TYPE_FILE, /* regular file */
+ OS_FILE_TYPE_FILE, /* regular file
+ (or a character/block device) */
OS_FILE_TYPE_DIR, /* directory */
- OS_FILE_TYPE_LINK, /* symbolic link */
- OS_FILE_TYPE_BLOCK /* block device */
+ OS_FILE_TYPE_LINK /* symbolic link */
};
/* Maximum path string length in bytes when referring to tables with in the
diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h
index b16a99b51c0..feb64fb1e41 100644
--- a/storage/innobase/include/os0sync.h
+++ b/storage/innobase/include/os0sync.h
@@ -452,7 +452,7 @@ Returns the old value of *ptr, atomically sets *ptr to new_val */
# define os_atomic_test_and_set_ulint(ptr, new_val) \
__sync_lock_test_and_set(ptr, new_val)
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__aarch64__)
/*
os_atomic_test_and_set_byte_release() should imply a release barrier before
setting, and a full barrier after. But __sync_lock_test_and_set() is only
diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h
index 2b47aef8790..d83b6e1985d 100644
--- a/storage/innobase/include/page0page.h
+++ b/storage/innobase/include/page0page.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1123,6 +1123,20 @@ page_find_rec_with_heap_no(
const rec_t*
page_find_rec_max_not_deleted(
const page_t* page);
+
+/** Issue a warning when the checksum that is stored in the page is valid,
+but different than the global setting innodb_checksum_algorithm.
+@param[in] current_algo current checksum algorithm
+@param[in] page_checksum page valid checksum
+@param[in] space_id tablespace id
+@param[in] page_no page number */
+void
+page_warn_strict_checksum(
+ srv_checksum_algorithm_t curr_algo,
+ srv_checksum_algorithm_t page_checksum,
+ ulint space_id,
+ ulint page_no);
+
#ifdef UNIV_MATERIALIZE
#undef UNIV_INLINE
#define UNIV_INLINE UNIV_INLINE_ORIGINAL
diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h
index 6fe6934e35c..0c2abef4b09 100644
--- a/storage/innobase/include/page0zip.h
+++ b/storage/innobase/include/page0zip.h
@@ -545,6 +545,21 @@ from outside the buffer pool.
# define UNIV_INLINE UNIV_INLINE_ORIGINAL
#endif
+#ifdef UNIV_INNOCHECKSUM
+/** Issue a warning when the checksum that is stored in the page is valid,
+but different than the global setting innodb_checksum_algorithm.
+@param[in] current_algo current checksum algorithm
+@param[in] page_checksum page valid checksum
+@param[in] space_id tablespace id
+@param[in] page_no page number */
+void
+page_warn_strict_checksum(
+ srv_checksum_algorithm_t curr_algo,
+ srv_checksum_algorithm_t page_checksum,
+ ulint space_id,
+ ulint page_no);
+#endif /* UNIV_INNOCHECKSUM */
+
#ifndef UNIV_INNOCHECKSUM
#ifndef UNIV_NONINL
# include "page0zip.ic"
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index f8dad7b3ced..4732ac48290 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -45,7 +45,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 6
-#define INNODB_VERSION_BUGFIX 24
+#define INNODB_VERSION_BUGFIX 25
/* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins;
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index d844ebfccb3..80525a39d1e 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -1,6 +1,6 @@
/***********************************************************************
-Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2015, MariaDB Corporation.
@@ -3470,8 +3470,9 @@ os_file_get_status(
stat_info->type = OS_FILE_TYPE_LINK;
break;
case S_IFBLK:
- stat_info->type = OS_FILE_TYPE_BLOCK;
- break;
+ /* Handle block device as regular file. */
+ case S_IFCHR:
+ /* Handle character device as regular file. */
case S_IFREG:
stat_info->type = OS_FILE_TYPE_FILE;
break;
@@ -3480,8 +3481,8 @@ os_file_get_status(
}
- if (check_rw_perm && (stat_info->type == OS_FILE_TYPE_FILE
- || stat_info->type == OS_FILE_TYPE_BLOCK)) {
+ if (check_rw_perm && stat_info->type == OS_FILE_TYPE_FILE) {
+
int fh;
int access;
diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc
index 4aff88818bb..fca8641342c 100644
--- a/storage/innobase/page/page0page.cc
+++ b/storage/innobase/page/page0page.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
This program is free software; you can redistribute it and/or modify it under
@@ -2819,3 +2819,45 @@ page_find_rec_max_not_deleted(
}
return(prev_rec);
}
+
+/** Issue a warning when the checksum that is stored in the page is valid,
+but different than the global setting innodb_checksum_algorithm.
+@param[in] current_algo current checksum algorithm
+@param[in] page_checksum page valid checksum
+@param[in] space_id tablespace id
+@param[in] page_no page number */
+void
+page_warn_strict_checksum(
+ srv_checksum_algorithm_t curr_algo,
+ srv_checksum_algorithm_t page_checksum,
+ ulint space_id,
+ ulint page_no)
+{
+ srv_checksum_algorithm_t curr_algo_nonstrict;
+ switch (curr_algo) {
+ case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
+ curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_CRC32;
+ break;
+ case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
+ curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_INNODB;
+ break;
+ case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
+ curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_NONE;
+ break;
+ default:
+ ut_error;
+ }
+
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "innodb_checksum_algorithm is set to \"%s\""
+ " but the page [page id: space=" ULINTPF ","
+ " page number=" ULINTPF "] contains a valid checksum \"%s\"."
+ " Accepting the page as valid. Change innodb_checksum_algorithm"
+ " to \"%s\" to silently accept such pages or rewrite all pages"
+ " so that they contain \"%s\" checksum.",
+ buf_checksum_algorithm_name(curr_algo),
+ space_id, page_no,
+ buf_checksum_algorithm_name(page_checksum),
+ buf_checksum_algorithm_name(curr_algo_nonstrict),
+ buf_checksum_algorithm_name(curr_algo_nonstrict));
+}
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index 0e36040ffe2..e8fd10912a7 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -47,6 +47,8 @@ using namespace std;
#include "btr0cur.h"
#include "page0types.h"
#include "log0recv.h"
+#else
+#define page_warn_strict_checksum(A,B,C,D)
#endif /* !UNIV_INNOCHECKSUM */
#include "zlib.h"
#ifndef UNIV_HOTBACKUP
@@ -4926,6 +4928,10 @@ page_zip_verify_checksum(
stored = static_cast<ib_uint32_t>(mach_read_from_4(
static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM));
+ ulint page_no = mach_read_from_4(static_cast<const unsigned char*> (data) + FIL_PAGE_OFFSET);
+ ulint space_id = mach_read_from_4(static_cast<const unsigned char*>
+ (data) + FIL_PAGE_SPACE_ID);
+
#if FIL_PAGE_LSN % 8
#error "FIL_PAGE_LSN must be 64 bit aligned"
#endif
@@ -4951,40 +4957,113 @@ page_zip_verify_checksum(
}
#endif
+ const srv_checksum_algorithm_t curr_algo =
+ static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
+
+ if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) {
+ return(TRUE);
+ }
+
calc = static_cast<ib_uint32_t>(page_zip_calc_checksum(
- data, size, static_cast<srv_checksum_algorithm_t>(
- srv_checksum_algorithm)));
+ data, size, curr_algo));
if (stored == calc) {
return(TRUE);
}
- switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) {
+ switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
- case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
- case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
- return(stored == calc);
case SRV_CHECKSUM_ALGORITHM_CRC32:
+
if (stored == BUF_NO_CHECKSUM_MAGIC) {
+ if (curr_algo
+ == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_NONE,
+ space_id, page_no);
+ }
+
return(TRUE);
}
- crc32 = calc;
+
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
+
+ if (stored == innodb) {
+ if (curr_algo
+ == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_INNODB,
+ space_id, page_no);
+ }
+
+ return(TRUE);
+ }
+
break;
+ case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
case SRV_CHECKSUM_ALGORITHM_INNODB:
+
if (stored == BUF_NO_CHECKSUM_MAGIC) {
+ if (curr_algo
+ == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_NONE,
+ space_id, page_no);
+ }
+
+ return(TRUE);
+ }
+
+ crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
+ data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
+
+ if (stored == crc32) {
+ if (curr_algo
+ == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_CRC32,
+ space_id, page_no);
+ }
+
return(TRUE);
}
+
+ break;
+ case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
+
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
- innodb = calc;
+
+ if (stored == crc32) {
+ page_warn_strict_checksum(
+ curr_algo, SRV_CHECKSUM_ALGORITHM_CRC32,
+ space_id, page_no);
+
+ return(TRUE);
+ }
+
+ innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
+ data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
+
+ if (stored == innodb) {
+ page_warn_strict_checksum(
+ curr_algo,
+ SRV_CHECKSUM_ALGORITHM_INNODB,
+ space_id, page_no);
+ return(TRUE);
+ }
+
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
- return(TRUE);
+ ut_error;
/* no default so the compiler will emit a warning if new enum
is added and not handled here */
}
- return(stored == crc32 || stored == innodb);
+ return(FALSE);
}
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index b225669b0f7..cab7621a0d4 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -1327,18 +1327,14 @@ row_insert_for_mysql(
mem_analyze_corruption(prebuilt);
ut_error;
- } else if (srv_created_new_raw || srv_force_recovery) {
- fputs("InnoDB: A new raw disk partition was initialized or\n"
- "InnoDB: innodb_force_recovery is on: we do not allow\n"
+ } else if (srv_force_recovery) {
+ fputs("InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n"
"InnoDB: mysqld and edit my.cnf so that"
- " newraw is replaced\n"
- "InnoDB: with raw, and innodb_force_... is removed.\n",
+ "InnoDB: innodb_force_... is removed.\n",
stderr);
- if(srv_force_recovery) {
- return(DB_READ_ONLY);
- }
- return(DB_ERROR);
+
+ return(DB_READ_ONLY);
}
trx->op_info = "inserting";
@@ -1729,18 +1725,14 @@ row_update_for_mysql(
ut_error;
}
- if (UNIV_UNLIKELY(srv_created_new_raw || srv_force_recovery)) {
- fputs("InnoDB: A new raw disk partition was initialized or\n"
- "InnoDB: innodb_force_recovery is on: we do not allow\n"
+ if (UNIV_UNLIKELY(srv_force_recovery)) {
+ fputs("InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n"
- "InnoDB: mysqld and edit my.cnf so that newraw"
- " is replaced\n"
- "InnoDB: with raw, and innodb_force_... is removed.\n",
+ "InnoDB: mysqld and edit my.cnf so that"
+ "InnoDB: innodb_force_... is removed.\n",
stderr);
- if(srv_force_recovery) {
- return(DB_READ_ONLY);
- }
- return(DB_ERROR);
+
+ return(DB_READ_ONLY);
}
DEBUG_SYNC_C("innodb_row_update_for_mysql_begin");
@@ -2239,22 +2231,6 @@ row_create_table_for_mysql(
goto err_exit;
);
- if (srv_created_new_raw) {
- fputs("InnoDB: A new raw disk partition was initialized:\n"
- "InnoDB: we do not allow database modifications"
- " by the user.\n"
- "InnoDB: Shut down mysqld and edit my.cnf so that newraw"
- " is replaced with raw.\n", stderr);
-err_exit:
- dict_mem_table_free(table);
-
- if (commit) {
- trx_commit_for_mysql(trx);
- }
-
- return(DB_ERROR);
- }
-
trx->op_info = "creating table";
if (row_mysql_is_system_table(table->name)) {
@@ -2265,7 +2241,19 @@ err_exit:
"InnoDB: MySQL system tables must be"
" of the MyISAM type!\n",
table->name);
- goto err_exit;
+
+#ifndef DBUG_OFF
+err_exit:
+#endif /* !DBUG_OFF */
+ dict_mem_table_free(table);
+
+ if (commit) {
+ trx_commit_for_mysql(trx);
+ }
+
+ trx->op_info = "";
+
+ return(DB_ERROR);
}
trx_start_if_not_started_xa(trx);
@@ -3350,16 +3338,6 @@ row_truncate_table_for_mysql(
ut_ad(table);
- if (srv_created_new_raw) {
- fputs("InnoDB: A new raw disk partition was initialized:\n"
- "InnoDB: we do not allow database modifications"
- " by the user.\n"
- "InnoDB: Shut down mysqld and edit my.cnf so that newraw"
- " is replaced with raw.\n", stderr);
-
- return(DB_ERROR);
- }
-
if (dict_table_is_discarded(table)) {
return(DB_TABLESPACE_DELETED);
} else if (table->ibd_file_missing) {
@@ -3839,16 +3817,6 @@ row_drop_table_for_mysql(
ut_a(name != NULL);
- if (srv_created_new_raw) {
- fputs("InnoDB: A new raw disk partition was initialized:\n"
- "InnoDB: we do not allow database modifications"
- " by the user.\n"
- "InnoDB: Shut down mysqld and edit my.cnf so that newraw"
- " is replaced with raw.\n", stderr);
-
- DBUG_RETURN(DB_ERROR);
- }
-
/* The table name is prefixed with the database name and a '/'.
Certain table names starting with 'innodb_' have their special
meaning regardless of the database name. Thus, we need to
@@ -4866,19 +4834,16 @@ row_rename_table_for_mysql(
ut_a(new_name != NULL);
ut_ad(trx->state == TRX_STATE_ACTIVE);
- if (srv_created_new_raw || srv_force_recovery) {
- fputs("InnoDB: A new raw disk partition was initialized or\n"
- "InnoDB: innodb_force_recovery is on: we do not allow\n"
+ if (srv_force_recovery) {
+ fputs("InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n"
- "InnoDB: mysqld and edit my.cnf so that newraw"
- " is replaced\n"
- "InnoDB: with raw, and innodb_force_... is removed.\n",
+ "InnoDB: mysqld and edit my.cnf so that"
+ "InnoDB: innodb_force_... is removed.\n",
stderr);
- if(srv_force_recovery) {
- err = DB_READ_ONLY;
- }
+ err = DB_READ_ONLY;
goto funct_exit;
+
} else if (row_mysql_is_system_table(new_name)) {
fprintf(stderr,
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 03fd34827f5..648e9e95f19 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2015, MariaDB Corporation
@@ -244,8 +244,8 @@ srv_file_check_mode(
/* Note: stat.rw_perm is only valid of files */
- if (stat.type == OS_FILE_TYPE_FILE
- || stat.type == OS_FILE_TYPE_BLOCK) {
+ if (stat.type == OS_FILE_TYPE_FILE) {
+
if (!stat.rw_perm) {
ib_logf(IB_LOG_LEVEL_ERROR,
@@ -442,14 +442,16 @@ srv_parse_data_file_paths_and_sizes(
&& *(str + 1) == 'e'
&& *(str + 2) == 'w') {
str += 3;
+ /* Initialize new raw device only during bootstrap */
(srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW;
}
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
str += 3;
+ /* Initialize new raw device only during bootstrap */
if ((srv_data_file_is_raw_partition)[i] == 0) {
- (srv_data_file_is_raw_partition)[i] = SRV_OLD_RAW;
+ (srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW;
}
}
@@ -905,6 +907,24 @@ open_or_create_data_files(
return(DB_ERROR);
}
+
+ const char* check_msg;
+ check_msg = fil_read_first_page(
+ files[i], FALSE, &flags, &space,
+#ifdef UNIV_LOG_ARCHIVE
+ min_arch_log_no, max_arch_log_no,
+#endif /* UNIV_LOG_ARCHIVE */
+ min_flushed_lsn, max_flushed_lsn, NULL);
+
+ /* If first page is valid, don't overwrite DB.
+ It prevents overwriting DB when mysql_install_db
+ starts mysqld multiple times during bootstrap. */
+ if (check_msg == NULL) {
+
+ srv_created_new_raw = FALSE;
+ ret = FALSE;
+ }
+
} else if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
srv_start_raw_disk_in_use = TRUE;
@@ -3167,9 +3187,9 @@ innobase_shutdown_for_mysql(void)
ibuf_close();
log_shutdown();
- lock_sys_close();
trx_sys_file_format_close();
trx_sys_close();
+ lock_sys_close();
/* We don't create these mutexes in RO mode because we don't create
the temp files that the cover. */
diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc
index aa0cdfee4c0..d464515a228 100644
--- a/storage/innobase/sync/sync0arr.cc
+++ b/storage/innobase/sync/sync0arr.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved.
@@ -1119,8 +1119,8 @@ sync_array_print_info_low(
os_thread_id_t r = 0;
fprintf(file,
- "OS WAIT ARRAY INFO: reservation count %ld\n",
- (long) arr->res_count);
+ "OS WAIT ARRAY INFO: reservation count " ULINTPF "\n",
+ arr->res_count);
for (i = 0; count < arr->n_reserved; ++i) {
sync_cell_t* cell;
@@ -1215,7 +1215,7 @@ sync_array_print(
}
fprintf(file,
- "OS WAIT ARRAY INFO: signal count %ld\n", (long) sg_count);
+ "OS WAIT ARRAY INFO: signal count " ULINTPF "\n", sg_count);
}
diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc
index 2c31af9442c..81df8062c54 100644
--- a/storage/innobase/trx/trx0sys.cc
+++ b/storage/innobase/trx/trx0sys.cc
@@ -1319,8 +1319,6 @@ trx_sys_close(void)
/* Free the double write data structures. */
buf_dblwr_free();
- mutex_enter(&trx_sys->mutex);
-
ut_a(UT_LIST_GET_LEN(trx_sys->ro_trx_list) == 0);
/* Only prepared transactions may be left in the system. Free them. */
@@ -1360,8 +1358,6 @@ trx_sys_close(void)
ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == 0);
ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0);
- mutex_exit(&trx_sys->mutex);
-
mutex_free(&trx_sys->mutex);
mem_free(trx_sys);
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 5410bb98190..7f3cfa22255 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -312,11 +312,10 @@ trx_free_prepared(
/*==============*/
trx_t* trx) /*!< in, own: trx object */
{
- ut_ad(mutex_own(&trx_sys->mutex));
-
ut_a(trx_state_eq(trx, TRX_STATE_PREPARED));
ut_a(trx->magic_n == TRX_MAGIC_N);
+ lock_trx_release_locks(trx);
trx_undo_free_prepared(trx);
assert_trx_in_rw_list(trx);
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index 506ce2307a3..c031c7f2500 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -3117,10 +3117,8 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ;
key++,keyinfo++)
{
- if (! maria_is_key_active(share->state.key_map, key))
- continue;
-
- if (share->state.key_root[key] != HA_OFFSET_ERROR)
+ if (maria_is_key_active(share->state.key_map, key) &&
+ share->state.key_root[key] != HA_OFFSET_ERROR)
{
index_pos[key]=param->new_file_pos; /* Write first block here */
if (sort_one_index(param,info,keyinfo,share->state.key_root[key],
diff --git a/storage/mroonga/vendor/groonga/CMakeLists.txt b/storage/mroonga/vendor/groonga/CMakeLists.txt
index 85a84f91ef0..f1ca174ed50 100644
--- a/storage/mroonga/vendor/groonga/CMakeLists.txt
+++ b/storage/mroonga/vendor/groonga/CMakeLists.txt
@@ -168,7 +168,7 @@ macro(check_build_flag flag)
check_cxxflag(${flag})
endmacro()
-if(CMAKE_COMPILER_IS_GNUCXX)
+if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX)
check_build_flag("-Wall")
check_build_flag("-Wextra")
check_build_flag("-Wno-unused-but-set-variable")
@@ -201,7 +201,7 @@ endif()
option(GRN_WITH_DEBUG "enable debug build." OFF)
if(GRN_WITH_DEBUG)
- if(CMAKE_COMPILER_IS_GNUCXX)
+ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX)
set(GRN_C_COMPILE_FLAGS "${GRN_C_COMPILE_FLAGS} -g3 -O0")
set(GRN_CXX_COMPILE_FLAGS "${GRN_CXX_COMPILE_FLAGS} -g3 -O0")
endif()
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index c38e7378015..9175f50fce7 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -1936,16 +1936,8 @@ int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name)
for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ;
key++,keyinfo++)
{
- if (! mi_is_key_active(info->s->state.key_map, key))
- {
- /* Since the key is not active, this should not be read, but we
- initialize it anyway to silence a Valgrind warn when passing that
- chunk of memory to pwrite(). */
- index_pos[key]= HA_OFFSET_ERROR;
- continue;
- }
-
- if (share->state.key_root[key] != HA_OFFSET_ERROR)
+ if (mi_is_key_active(info->s->state.key_map, key) &&
+ share->state.key_root[key] != HA_OFFSET_ERROR)
{
index_pos[key]=param->new_file_pos; /* Write first block here */
if (sort_one_index(param,info,keyinfo,share->state.key_root[key],
diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c
index 9ab0bd99201..be61734e01c 100644
--- a/storage/myisam/rt_split.c
+++ b/storage/myisam/rt_split.c
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2002, 2010, Oracle and/or its affiliates
+ Copyright (c) 2002, 2015, Oracle and/or its affiliates
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -69,6 +69,10 @@ static double mbr_join_square(const double *a, const double *b, int n_dim)
b += 2;
}while (a != end);
+ /* Check for infinity or NaN */
+ if (my_isinf(square) || isnan(square))
+ square = DBL_MAX;
+
return square;
}
@@ -103,6 +107,9 @@ static void pick_seeds(SplitStruct *node, int n_entries,
double max_d = -DBL_MAX;
double d;
+ *seed_a = node;
+ *seed_b = node + 1;
+
for (cur1 = node; cur1 < lim1; ++cur1)
{
for (cur2=cur1 + 1; cur2 < lim2; ++cur2)
diff --git a/storage/oqgraph/CMakeLists.txt b/storage/oqgraph/CMakeLists.txt
index 2c09a27a581..1cb5c828d92 100644
--- a/storage/oqgraph/CMakeLists.txt
+++ b/storage/oqgraph/CMakeLists.txt
@@ -25,6 +25,7 @@ IF(MSVC)
# ENDIF()
ELSE()
# See if that works. On old gcc it'll fail because of -fno-rtti
+SET(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}")
CHECK_CXX_SOURCE_COMPILES(
"
#define BOOST_NO_RTTI 1
diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc
index 2e1393ec591..81592c85d0c 100644
--- a/storage/perfschema/ha_perfschema.cc
+++ b/storage/perfschema/ha_perfschema.cc
@@ -225,7 +225,7 @@ maria_declare_plugin(perfschema)
0x0001,
pfs_status_vars,
NULL,
- "5.6.20",
+ "5.6.25",
MariaDB_PLUGIN_MATURITY_STABLE
}
maria_declare_plugin_end;
diff --git a/storage/sphinx/mysql-test/sphinx/my.cnf b/storage/sphinx/mysql-test/sphinx/my.cnf
index a3789a065bf..f60380b7171 100644
--- a/storage/sphinx/mysql-test/sphinx/my.cnf
+++ b/storage/sphinx/mysql-test/sphinx/my.cnf
@@ -16,7 +16,6 @@ mem_limit = 32M
[searchd]
read_timeout = 5
max_children = 30
-max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
@@ -24,7 +23,7 @@ log = @ENV.MYSQLTEST_VARDIR/searchd/sphinx-searchd.log
query_log = @ENV.MYSQLTEST_VARDIR/searchd/sphinx-query.log
#log-error = @ENV.MYSQLTEST_VARDIR/searchd/sphinx.log
pid_file = @ENV.MYSQLTEST_VARDIR/run/searchd.pid
-port = @ENV.SPHINXSEARCH_PORT
+listen = @ENV.SPHINXSEARCH_PORT
[ENV]
SPHINXSEARCH_PORT = @OPT.port
diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt
index 08adb7355e4..a8a821e5ad6 100644
--- a/storage/tokudb/CMakeLists.txt
+++ b/storage/tokudb/CMakeLists.txt
@@ -25,8 +25,8 @@ IF (HAVE_WVLA)
ENDIF()
############################################
-SET(TOKUDB_VERSION "tokudb-7.5.6")
SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb.cnf\nusr/bin/tokuftdump\nusr/share/doc/mariadb-server-10.1/README-TOKUDB\nusr/share/doc/mariadb-server-10.1/README.md" PARENT_SCOPE)
+SET(TOKUDB_VERSION "tokudb-7.5.7")
SET(USE_BDB OFF CACHE BOOL "")
MARK_AS_ADVANCED(BUILDNAME)
MARK_AS_ADVANCED(BUILD_TESTING)
diff --git a/storage/tokudb/ft-index/buildheader/make_tdb.cc b/storage/tokudb/ft-index/buildheader/make_tdb.cc
index 3f9a721d9aa..53706649231 100644
--- a/storage/tokudb/ft-index/buildheader/make_tdb.cc
+++ b/storage/tokudb/ft-index/buildheader/make_tdb.cc
@@ -587,6 +587,7 @@ static void print_db_txn_struct (void) {
"uint64_t (*get_client_id)(DB_TXN *)",
"bool (*is_prepared)(DB_TXN *)",
"DB_TXN *(*get_child)(DB_TXN *)",
+ "uint64_t (*get_start_time)(DB_TXN *)",
NULL};
sort_and_dump_fields("db_txn", false, extra);
}
@@ -786,7 +787,7 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) {
printf("typedef void (*lock_timeout_callback)(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid);\n");
printf("typedef int (*iterate_row_locks_callback)(DB **db, DBT *left_key, DBT *right_key, void *extra);\n");
- printf("typedef int (*iterate_transactions_callback)(uint64_t txnid, uint64_t client_id, iterate_row_locks_callback cb, void *locks_extra, void *extra);\n");
+ printf("typedef int (*iterate_transactions_callback)(DB_TXN *dbtxn, iterate_row_locks_callback cb, void *locks_extra, void *extra);\n");
printf("typedef int (*iterate_requests_callback)(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid, uint64_t start_time, void *extra);\n");
print_db_env_struct();
print_db_key_range_struct();
diff --git a/storage/tokudb/ft-index/ft/ft-verify.cc b/storage/tokudb/ft-index/ft/ft-verify.cc
index d9606f37604..0a85136816f 100644
--- a/storage/tokudb/ft-index/ft/ft-verify.cc
+++ b/storage/tokudb/ft-index/ft/ft-verify.cc
@@ -160,10 +160,14 @@ get_ith_key_dbt (BASEMENTNODE bn, int i) {
#define VERIFY_ASSERTION(predicate, i, string) ({ \
if(!(predicate)) { \
- (void) verbose; \
- if (true) { \
- fprintf(stderr, "%s:%d: Looking at child %d of block %" PRId64 ": %s\n", __FILE__, __LINE__, i, blocknum.b, string); \
- } \
+ fprintf(stderr, "%s:%d: Looking at child %d of block %" PRId64 ": %s\n", __FILE__, __LINE__, i, blocknum.b, string); \
+ result = TOKUDB_NEEDS_REPAIR; \
+ if (!keep_going_on_failure) goto done; \
+ }})
+
+#define VERIFY_ASSERTION_BASEMENT(predicate, bn, entry, string) ({ \
+ if(!(predicate)) { \
+ fprintf(stderr, "%s:%d: Looking at block %" PRId64 " bn %d entry %d: %s\n", __FILE__, __LINE__, blocknum.b, bn, entry, string); \
result = TOKUDB_NEEDS_REPAIR; \
if (!keep_going_on_failure) goto done; \
}})
@@ -201,7 +205,6 @@ struct verify_message_tree_extra {
int verify_message_tree(const int32_t &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e) __attribute__((nonnull(3)));
int verify_message_tree(const int32_t &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e)
{
- int verbose = e->verbose;
BLOCKNUM blocknum = e->blocknum;
int keep_going_on_failure = e->keep_going_on_failure;
int result = 0;
@@ -236,7 +239,6 @@ int error_on_iter(const int32_t &UU(offset), const uint32_t UU(idx), void *UU(e)
int verify_marked_messages(const int32_t &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e) __attribute__((nonnull(3)));
int verify_marked_messages(const int32_t &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e)
{
- int verbose = e->verbose;
BLOCKNUM blocknum = e->blocknum;
int keep_going_on_failure = e->keep_going_on_failure;
int result = 0;
@@ -462,16 +464,16 @@ toku_verify_ftnode_internal(FT_HANDLE ft_handle,
DBT kdbt = get_ith_key_dbt(bn, j);
if (curr_less_pivot) {
int compare = compare_pairs(ft_handle, curr_less_pivot, &kdbt);
- VERIFY_ASSERTION(compare < 0, j, "The leafentry is >= the lower-bound pivot");
+ VERIFY_ASSERTION_BASEMENT(compare < 0, i, j, "The leafentry is >= the lower-bound pivot");
}
if (curr_geq_pivot) {
int compare = compare_pairs(ft_handle, curr_geq_pivot, &kdbt);
- VERIFY_ASSERTION(compare >= 0, j, "The leafentry is < the upper-bound pivot");
+ VERIFY_ASSERTION_BASEMENT(compare >= 0, i, j, "The leafentry is < the upper-bound pivot");
}
if (0 < j) {
DBT prev_key_dbt = get_ith_key_dbt(bn, j-1);
int compare = compare_pairs(ft_handle, &prev_key_dbt, &kdbt);
- VERIFY_ASSERTION(compare < 0, j, "Adjacent leafentries are out of order");
+ VERIFY_ASSERTION_BASEMENT(compare < 0, i, j, "Adjacent leafentries are out of order");
}
}
}
diff --git a/storage/tokudb/ft-index/ft/logger/recover.cc b/storage/tokudb/ft-index/ft/logger/recover.cc
index cae7397651d..680485201da 100644
--- a/storage/tokudb/ft-index/ft/logger/recover.cc
+++ b/storage/tokudb/ft-index/ft/logger/recover.cc
@@ -111,7 +111,8 @@ int tokuft_recovery_trace = 0; // turn on recovery tracing, d
#endif
// time in seconds between recovery progress reports
-#define TOKUDB_RECOVERY_PROGRESS_TIME 15
+#define TOKUFT_RECOVERY_PROGRESS_TIME 15
+time_t tokuft_recovery_progress_time = TOKUFT_RECOVERY_PROGRESS_TIME;
enum ss {
BACKWARD_NEWER_CHECKPOINT_END = 1,
@@ -325,14 +326,12 @@ static int recover_env_init (RECOVER_ENV renv,
}
static void recover_env_cleanup (RECOVER_ENV renv) {
- int r;
-
invariant_zero(renv->fmap.filenums->size());
file_map_destroy(&renv->fmap);
if (renv->destroy_logger_at_end) {
toku_logger_close_rollback(renv->logger);
- r = toku_logger_close(&renv->logger);
+ int r = toku_logger_close(&renv->logger);
assert(r == 0);
} else {
toku_logger_write_log_files(renv->logger, true);
@@ -749,6 +748,36 @@ static int toku_recover_backward_xbegin (struct logtype_xbegin *UU(l), RECOVER_E
return 0;
}
+struct toku_txn_progress_extra {
+ time_t tlast;
+ LSN lsn;
+ const char *type;
+ TXNID_PAIR xid;
+ uint64_t last_total;
+};
+
+static void toku_recover_txn_progress(TOKU_TXN_PROGRESS txn_progress, void *extra) {
+ toku_txn_progress_extra *txn_progress_extra = static_cast<toku_txn_progress_extra *>(extra);
+ if (txn_progress_extra->last_total == 0)
+ txn_progress_extra->last_total = txn_progress->entries_total;
+ else
+ assert(txn_progress_extra->last_total == txn_progress->entries_total);
+ time_t tnow = time(NULL);
+ if (tnow - txn_progress_extra->tlast >= tokuft_recovery_progress_time) {
+ txn_progress_extra->tlast = tnow;
+ fprintf(stderr, "%.24s TokuFT ", ctime(&tnow));
+ if (txn_progress_extra->lsn.lsn != 0)
+ fprintf(stderr, "lsn %" PRIu64 " ", txn_progress_extra->lsn.lsn);
+ fprintf(stderr, "%s xid %" PRIu64 ":%" PRIu64 " ",
+ txn_progress_extra->type, txn_progress_extra->xid.parent_id64, txn_progress_extra->xid.child_id64);
+ fprintf(stderr, "%" PRIu64 "/%" PRIu64 " ",
+ txn_progress->entries_processed, txn_progress->entries_total);
+ if (txn_progress->entries_total > 0)
+ fprintf(stderr, "%.0f%% ", ((double) txn_progress->entries_processed / (double) txn_progress->entries_total) * 100.0);
+ fprintf(stderr, "\n");
+ }
+}
+
static int toku_recover_xcommit (struct logtype_xcommit *l, RECOVER_ENV renv) {
// find the transaction by transaction id
TOKUTXN txn = NULL;
@@ -756,8 +785,8 @@ static int toku_recover_xcommit (struct logtype_xcommit *l, RECOVER_ENV renv) {
assert(txn!=NULL);
// commit the transaction
- int r = toku_txn_commit_with_lsn(txn, true, l->lsn,
- NULL, NULL);
+ toku_txn_progress_extra extra = { time(NULL), l->lsn, "commit", l->xid };
+ int r = toku_txn_commit_with_lsn(txn, true, l->lsn, toku_recover_txn_progress, &extra);
assert(r == 0);
// close the transaction
@@ -799,7 +828,8 @@ static int toku_recover_xabort (struct logtype_xabort *l, RECOVER_ENV renv) {
assert(txn!=NULL);
// abort the transaction
- r = toku_txn_abort_with_lsn(txn, l->lsn, NULL, NULL);
+ toku_txn_progress_extra extra = { time(NULL), l->lsn, "abort", l->xid };
+ r = toku_txn_abort_with_lsn(txn, l->lsn, toku_recover_txn_progress, &extra);
assert(r == 0);
// close the transaction
@@ -1301,7 +1331,6 @@ static int is_txn_unprepared(TOKUTXN txn, void* extra) {
return 0;
}
-
static int find_an_unprepared_txn (RECOVER_ENV renv, TOKUTXN *txnp) {
TOKUTXN txn = nullptr;
int r = toku_txn_manager_iter_over_live_root_txns(
@@ -1326,6 +1355,7 @@ static int call_prepare_txn_callback_iter(TOKUTXN txn, void* extra) {
}
static void recover_abort_live_txn(TOKUTXN txn) {
+ fprintf(stderr, "%s %" PRIu64 "\n", __FUNCTION__, txn->txnid.parent_id64);
// recursively abort all children first
if (txn->child != NULL) {
recover_abort_live_txn(txn->child);
@@ -1333,7 +1363,8 @@ static void recover_abort_live_txn(TOKUTXN txn) {
// sanity check that the recursive call successfully NULLs out txn->child
invariant(txn->child == NULL);
// abort the transaction
- int r = toku_txn_abort_txn(txn, NULL, NULL);
+ toku_txn_progress_extra extra = { time(NULL), ZERO_LSN, "abort live", txn->txnid };
+ int r = toku_txn_abort_txn(txn, toku_recover_txn_progress, &extra);
assert(r == 0);
// close the transaction
@@ -1451,9 +1482,10 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
// trace progress
if ((i % 1000) == 0) {
tnow = time(NULL);
- if (tnow - tlast >= TOKUDB_RECOVERY_PROGRESS_TIME) {
+ if (tnow - tlast >= tokuft_recovery_progress_time) {
thislsn = toku_log_entry_get_lsn(le);
- fprintf(stderr, "%.24s TokuFT recovery scanning backward from %" PRIu64 " at %" PRIu64 " (%s)\n", ctime(&tnow), lastlsn.lsn, thislsn.lsn, recover_state(renv));
+ fprintf(stderr, "%.24s TokuFT recovery scanning backward from %" PRIu64 " at %" PRIu64 " (%s)\n",
+ ctime(&tnow), lastlsn.lsn, thislsn.lsn, recover_state(renv));
tlast = tnow;
}
}
@@ -1482,16 +1514,18 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
assert(le);
thislsn = toku_log_entry_get_lsn(le);
tnow = time(NULL);
- fprintf(stderr, "%.24s TokuFT recovery starts scanning forward to %" PRIu64 " from %" PRIu64 " left %" PRIu64 " (%s)\n", ctime(&tnow), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn, recover_state(renv));
+ fprintf(stderr, "%.24s TokuFT recovery starts scanning forward to %" PRIu64 " from %" PRIu64 " left %" PRIu64 " (%s)\n",
+ ctime(&tnow), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn, recover_state(renv));
for (unsigned i=0; 1; i++) {
// trace progress
if ((i % 1000) == 0) {
tnow = time(NULL);
- if (tnow - tlast >= TOKUDB_RECOVERY_PROGRESS_TIME) {
+ if (tnow - tlast >= tokuft_recovery_progress_time) {
thislsn = toku_log_entry_get_lsn(le);
- fprintf(stderr, "%.24s TokuFT recovery scanning forward to %" PRIu64 " at %" PRIu64 " left %" PRIu64 " (%s)\n", ctime(&tnow), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn, recover_state(renv));
+ fprintf(stderr, "%.24s TokuFT recovery scanning forward to %" PRIu64 " at %" PRIu64 " left %" PRIu64 " (%s)\n",
+ ctime(&tnow), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn, recover_state(renv));
tlast = tnow;
}
}
diff --git a/storage/tokudb/ft-index/ft/txn/txn.cc b/storage/tokudb/ft-index/ft/txn/txn.cc
index 18d5a6b67dd..922c955a6b5 100644
--- a/storage/tokudb/ft-index/ft/txn/txn.cc
+++ b/storage/tokudb/ft-index/ft/txn/txn.cc
@@ -344,6 +344,7 @@ static txn_child_manager tcm;
.state = TOKUTXN_LIVE,
.num_pin = 0,
.client_id = 0,
+ .start_time = time(NULL),
};
TOKUTXN result = NULL;
@@ -787,6 +788,10 @@ void toku_txn_set_client_id(TOKUTXN txn, uint64_t client_id) {
txn->client_id = client_id;
}
+time_t toku_txn_get_start_time(struct tokutxn *txn) {
+ return txn->start_time;
+}
+
int toku_txn_reads_txnid(TXNID txnid, TOKUTXN txn) {
int r = 0;
TXNID oldest_live_in_snapshot = toku_get_oldest_in_live_root_txn_list(txn);
diff --git a/storage/tokudb/ft-index/ft/txn/txn.h b/storage/tokudb/ft-index/ft/txn/txn.h
index 6381b5a7779..4f2778bf858 100644
--- a/storage/tokudb/ft-index/ft/txn/txn.h
+++ b/storage/tokudb/ft-index/ft/txn/txn.h
@@ -253,6 +253,7 @@ struct tokutxn {
uint32_t num_pin; // number of threads (all hot indexes) that want this
// txn to not transition to commit or abort
uint64_t client_id;
+ time_t start_time;
};
typedef struct tokutxn *TOKUTXN;
@@ -368,6 +369,8 @@ bool toku_txn_has_spilled_rollback(struct tokutxn *txn);
uint64_t toku_txn_get_client_id(struct tokutxn *txn);
void toku_txn_set_client_id(struct tokutxn *txn, uint64_t client_id);
+time_t toku_txn_get_start_time(struct tokutxn *txn);
+
//
// This function is used by the leafentry iterators.
// returns TOKUDB_ACCEPT if live transaction context is allowed to read a value
diff --git a/storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc b/storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc
index dd00ddeeb9a..c104c5c8541 100644
--- a/storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc
+++ b/storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc
@@ -104,9 +104,11 @@ struct iterate_extra {
bool visited_txn[3];
};
-static int iterate_callback(uint64_t txnid, uint64_t client_id,
+static int iterate_callback(DB_TXN *txn,
iterate_row_locks_callback iterate_locks,
void *locks_extra, void *extra) {
+ uint64_t txnid = txn->id64(txn);
+ uint64_t client_id = txn->get_client_id(txn);
iterate_extra *info = reinterpret_cast<iterate_extra *>(extra);
DB *db;
DBT left_key, right_key;
diff --git a/storage/tokudb/ft-index/src/tests/test_stress0.cc b/storage/tokudb/ft-index/src/tests/test_stress0.cc
index 5dbca08db48..26192d851aa 100644
--- a/storage/tokudb/ft-index/src/tests/test_stress0.cc
+++ b/storage/tokudb/ft-index/src/tests/test_stress0.cc
@@ -140,9 +140,11 @@ static int UU() iterate_pending_lock_requests_op(DB_TXN *UU(txn), ARG arg, void
return r;
}
-static int iterate_txns(uint64_t txnid, uint64_t client_id,
+static int iterate_txns(DB_TXN *txn,
iterate_row_locks_callback iterate_locks,
void *locks_extra, void *extra) {
+ uint64_t txnid = txn->id64(txn);
+ uint64_t client_id = txn->get_client_id(txn);
invariant_null(extra);
invariant(txnid > 0);
invariant(client_id == 0);
diff --git a/storage/tokudb/ft-index/src/ydb.cc b/storage/tokudb/ft-index/src/ydb.cc
index 85445a67eef..ab15a44489e 100644
--- a/storage/tokudb/ft-index/src/ydb.cc
+++ b/storage/tokudb/ft-index/src/ydb.cc
@@ -2492,24 +2492,21 @@ struct iter_txns_callback_extra {
};
static int iter_txns_callback(TOKUTXN txn, void *extra) {
+ int r = 0;
iter_txns_callback_extra *info =
reinterpret_cast<iter_txns_callback_extra *>(extra);
-
DB_TXN *dbtxn = toku_txn_get_container_db_txn(txn);
invariant_notnull(dbtxn);
+ if (db_txn_struct_i(dbtxn)->tokutxn == txn) { // make sure that the dbtxn is fully initialized
+ toku_mutex_lock(&db_txn_struct_i(dbtxn)->txn_mutex);
+ toku_pthread_rwlock_rdlock(&info->env->i->open_dbs_rwlock);
- toku_mutex_lock(&db_txn_struct_i(dbtxn)->txn_mutex);
- toku_pthread_rwlock_rdlock(&info->env->i->open_dbs_rwlock);
-
- iter_txn_row_locks_callback_extra e(info->env, &db_txn_struct_i(dbtxn)->lt_map);
- const int r = info->callback(toku_txn_get_txnid(txn).parent_id64,
- toku_txn_get_client_id(txn),
- iter_txn_row_locks_callback,
- &e,
- info->extra);
+ iter_txn_row_locks_callback_extra e(info->env, &db_txn_struct_i(dbtxn)->lt_map);
+ r = info->callback(dbtxn, iter_txn_row_locks_callback, &e, info->extra);
- toku_pthread_rwlock_rdunlock(&info->env->i->open_dbs_rwlock);
- toku_mutex_unlock(&db_txn_struct_i(dbtxn)->txn_mutex);
+ toku_pthread_rwlock_rdunlock(&info->env->i->open_dbs_rwlock);
+ toku_mutex_unlock(&db_txn_struct_i(dbtxn)->txn_mutex);
+ }
return r;
}
diff --git a/storage/tokudb/ft-index/src/ydb_txn.cc b/storage/tokudb/ft-index/src/ydb_txn.cc
index 82903849535..885c6b713b2 100644
--- a/storage/tokudb/ft-index/src/ydb_txn.cc
+++ b/storage/tokudb/ft-index/src/ydb_txn.cc
@@ -433,6 +433,11 @@ static DB_TXN *toku_txn_get_child(DB_TXN *txn) {
return db_txn_struct_i(txn)->child;
}
+static uint64_t toku_txn_get_start_time(DB_TXN *txn) {
+ TOKUTXN ttxn = db_txn_struct_i(txn)->tokutxn;
+ return toku_txn_get_start_time(ttxn);
+}
+
static inline void txn_func_init(DB_TXN *txn) {
#define STXN(name) txn->name = locked_txn_ ## name
STXN(abort);
@@ -451,6 +456,7 @@ static inline void txn_func_init(DB_TXN *txn) {
txn->id64 = toku_txn_id64;
txn->is_prepared = toku_txn_is_prepared;
txn->get_child = toku_txn_get_child;
+ txn->get_start_time = toku_txn_get_start_time;
}
//
diff --git a/storage/tokudb/ft-index/tools/CMakeLists.txt b/storage/tokudb/ft-index/tools/CMakeLists.txt
index 71c44df9acd..f745517d84e 100644
--- a/storage/tokudb/ft-index/tools/CMakeLists.txt
+++ b/storage/tokudb/ft-index/tools/CMakeLists.txt
@@ -1,6 +1,6 @@
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE DONT_DEPRECATE_ERRNO)
-set(tools tokudb_dump tokuftdump tdb_logprint tdb-recover ftverify ba_replay)
+set(tools tokudb_dump tokuftdump tokuft_logprint tdb-recover ftverify ba_replay)
foreach(tool ${tools})
add_executable(${tool} ${tool}.cc)
add_dependencies(${tool} install_tdb_h)
@@ -12,9 +12,6 @@ endforeach(tool)
# link in math.h library just for this tool.
target_link_libraries(ftverify m)
-install(
- TARGETS tokuftdump
- DESTINATION ${INSTALL_BINDIR}
- COMPONENT Server
- )
+install(TARGETS tokuftdump DESTINATION ${INSTALL_BINDIR} COMPONENT Server)
+install(TARGETS tokuft_logprint DESTINATION ${INSTALL_BINDIR} COMPONENT Server)
diff --git a/storage/tokudb/ft-index/tools/tdb_logprint.cc b/storage/tokudb/ft-index/tools/tokuft_logprint.cc
index 15a28632cfb..1dd7581b9f5 100644
--- a/storage/tokudb/ft-index/tools/tdb_logprint.cc
+++ b/storage/tokudb/ft-index/tools/tokuft_logprint.cc
@@ -91,8 +91,6 @@ PATENT RIGHTS GRANT:
/* Dump the log from stdin to stdout. */
-#include <config.h>
-
#include "ft/log_header.h"
#include "ft/logger/logger.h"
diff --git a/storage/tokudb/ft-index/tools/tokuftdump.cc b/storage/tokudb/ft-index/tools/tokuftdump.cc
index d680a3dd0d0..14c3c31a061 100644
--- a/storage/tokudb/ft-index/tools/tokuftdump.cc
+++ b/storage/tokudb/ft-index/tools/tokuftdump.cc
@@ -250,6 +250,8 @@ static int64_t getRootNode(FT ft) {
}
static int print_le(const void* key, const uint32_t keylen, const LEAFENTRY &le, const uint32_t idx UU(), void *const ai UU()) {
+ unsigned int *le_index = (unsigned int *) ai;
+ printf("%u: ", *le_index); *le_index += 1;
print_klpair(stdout, key, keylen, le);
printf("\n");
return 0;
@@ -539,7 +541,8 @@ ok:
printf(" n_bytes_in_buffer= %" PRIu64 "", BLB_DATA(n, i)->get_disk_size());
printf(" items_in_buffer=%u\n", BLB_DATA(n, i)->num_klpairs());
if (do_dump_data) {
- BLB_DATA(n, i)->iterate<void, print_le>(NULL);
+ unsigned int le_index = 0;
+ BLB_DATA(n, i)->iterate<void, print_le>(&le_index);
}
}
}
@@ -938,6 +941,7 @@ static void run_iteractive_loop(int fd, FT ft, CACHEFILE cf) {
} else if (strcmp(fields[0], "header") == 0) {
toku_ft_free(ft);
open_header(fd, &ft, cf);
+ dump_header(ft);
} else if (strcmp(fields[0], "rn") == 0||strcmp(fields[0], "rootNode")==0||strcmp(fields[0], "rootnode") == 0) {
printf("Root node :%d\n",root);
} else if (strcmp(fields[0], "block") == 0 && nfields == 2) {
diff --git a/storage/tokudb/ft-index/util/scoped_malloc.cc b/storage/tokudb/ft-index/util/scoped_malloc.cc
index 551bd944beb..15d4fb3e52e 100644
--- a/storage/tokudb/ft-index/util/scoped_malloc.cc
+++ b/storage/tokudb/ft-index/util/scoped_malloc.cc
@@ -145,6 +145,9 @@ namespace toku {
}
void destroy() {
+#if TOKU_SCOPED_MALLOC_DEBUG
+ printf("%s %p %p\n", __FUNCTION__, this, m_stack);
+#endif
if (m_stack != NULL) {
toku_free(m_stack);
m_stack = NULL;
@@ -167,13 +170,17 @@ namespace toku {
static void destroy_and_deregister(void *key) {
invariant_notnull(key);
tl_stack *st = reinterpret_cast<tl_stack *>(key);
- st->destroy();
+ size_t n = 0;
toku_mutex_lock(&global_stack_set_mutex);
- invariant_notnull(global_stack_set);
- size_t n = global_stack_set->erase(st);
- invariant(n == 1);
+ if (global_stack_set) {
+ n = global_stack_set->erase(st);
+ }
toku_mutex_unlock(&global_stack_set_mutex);
+
+ if (n == 1) {
+ st->destroy(); // destroy the stack if this function erased it from the set. otherwise, somebody else destroyed it.
+ }
}
// Allocate 'size' bytes and return a pointer to the first byte
@@ -244,6 +251,11 @@ void toku_scoped_malloc_init(void) {
}
void toku_scoped_malloc_destroy(void) {
+ toku_scoped_malloc_destroy_key();
+ toku_scoped_malloc_destroy_set();
+}
+
+void toku_scoped_malloc_destroy_set(void) {
toku_mutex_lock(&toku::global_stack_set_mutex);
invariant_notnull(toku::global_stack_set);
// Destroy any tl_stacks that were registered as thread locals but did not
@@ -254,10 +266,11 @@ void toku_scoped_malloc_destroy(void) {
(*i)->destroy();
}
delete toku::global_stack_set;
+ toku::global_stack_set = nullptr;
toku_mutex_unlock(&toku::global_stack_set_mutex);
+}
- // We're deregistering the destructor key here. When this thread exits,
- // the tl_stack destructor won't get called, so we need to do that first.
+void toku_scoped_malloc_destroy_key(void) {
int r = pthread_key_delete(toku::tl_stack_destroy_pthread_key);
invariant_zero(r);
}
diff --git a/storage/tokudb/ft-index/util/scoped_malloc.h b/storage/tokudb/ft-index/util/scoped_malloc.h
index dbd919d155e..0233b0f1aa5 100644
--- a/storage/tokudb/ft-index/util/scoped_malloc.h
+++ b/storage/tokudb/ft-index/util/scoped_malloc.h
@@ -151,3 +151,7 @@ void toku_scoped_malloc_init(void);
void toku_scoped_malloc_destroy(void);
+void toku_scoped_malloc_destroy_set(void);
+
+void toku_scoped_malloc_destroy_key(void);
+
diff --git a/storage/tokudb/ft-index/util/tests/sm-basic.cc b/storage/tokudb/ft-index/util/tests/sm-basic.cc
new file mode 100644
index 00000000000..5df64294721
--- /dev/null
+++ b/storage/tokudb/ft-index/util/tests/sm-basic.cc
@@ -0,0 +1,127 @@
+/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
+#ident "$Id$"
+/*
+COPYING CONDITIONS NOTICE:
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation, and provided that the
+ following conditions are met:
+
+ * Redistributions of source code must retain this COPYING
+ CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
+ DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
+ PATENT MARKING NOTICE (below), and the PATENT RIGHTS
+ GRANT (below).
+
+ * Redistributions in binary form must reproduce this COPYING
+ CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
+ DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
+ PATENT MARKING NOTICE (below), and the PATENT RIGHTS
+ GRANT (below) in the documentation and/or other materials
+ provided with the distribution.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+COPYRIGHT NOTICE:
+
+ TokuFT, Tokutek Fractal Tree Indexing Library.
+ Copyright (C) 2007-2013 Tokutek, Inc.
+
+DISCLAIMER:
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+UNIVERSITY PATENT NOTICE:
+
+ The technology is licensed by the Massachusetts Institute of
+ Technology, Rutgers State University of New Jersey, and the Research
+ Foundation of State University of New York at Stony Brook under
+ United States of America Serial No. 11/760379 and to the patents
+ and/or patent applications resulting from it.
+
+PATENT MARKING NOTICE:
+
+ This software is covered by US Patent No. 8,185,551.
+ This software is covered by US Patent No. 8,489,638.
+
+PATENT RIGHTS GRANT:
+
+ "THIS IMPLEMENTATION" means the copyrightable works distributed by
+ Tokutek as part of the Fractal Tree project.
+
+ "PATENT CLAIMS" means the claims of patents that are owned or
+ licensable by Tokutek, both currently or in the future; and that in
+ the absence of this license would be infringed by THIS
+ IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
+
+ "PATENT CHALLENGE" shall mean a challenge to the validity,
+ patentability, enforceability and/or non-infringement of any of the
+ PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
+
+ Tokutek hereby grants to you, for the term and geographical scope of
+ the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
+ irrevocable (except as stated in this section) patent license to
+ make, have made, use, offer to sell, sell, import, transfer, and
+ otherwise run, modify, and propagate the contents of THIS
+ IMPLEMENTATION, where such license applies only to the PATENT
+ CLAIMS. This grant does not include claims that would be infringed
+ only as a consequence of further modifications of THIS
+ IMPLEMENTATION. If you or your agent or licensee institute or order
+ or agree to the institution of patent litigation against any entity
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
+ THIS IMPLEMENTATION constitutes direct or contributory patent
+ infringement, or inducement of patent infringement, then any rights
+ granted to you under this License shall terminate as of the date
+ such litigation is filed. If you or your agent or exclusive
+ licensee institute or order or agree to the institution of a PATENT
+ CHALLENGE, then Tokutek may terminate any rights granted to you
+ under this License.
+*/
+
+// test that basic scoped malloc works with a thread
+
+#ident "Copyright (c) 2015 Tokutek Inc. All rights reserved."
+#include <toku_portability.h>
+#include <toku_assert.h>
+#include <toku_pthread.h>
+#include <util/scoped_malloc.h>
+
+static void sm_test(void) {
+ toku::scoped_malloc a(1);
+ {
+ toku::scoped_malloc b(2);
+ {
+ toku::scoped_malloc c(3);
+ }
+ }
+}
+
+static void *sm_test_f(void *arg) {
+ sm_test();
+ return arg;
+}
+
+int main(void) {
+ toku_scoped_malloc_init();
+
+ // run the test
+ toku_pthread_t tid;
+ int r;
+ r = toku_pthread_create(&tid, NULL, sm_test_f, NULL);
+ assert_zero(r);
+ void *ret;
+ r = toku_pthread_join(tid, &ret);
+ assert_zero(r);
+
+ toku_scoped_malloc_destroy();
+
+ return 0;
+}
diff --git a/storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc b/storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc
new file mode 100644
index 00000000000..653d4148fd0
--- /dev/null
+++ b/storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc
@@ -0,0 +1,128 @@
+/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
+#ident "$Id$"
+/*
+COPYING CONDITIONS NOTICE:
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation, and provided that the
+ following conditions are met:
+
+ * Redistributions of source code must retain this COPYING
+ CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
+ DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
+ PATENT MARKING NOTICE (below), and the PATENT RIGHTS
+ GRANT (below).
+
+ * Redistributions in binary form must reproduce this COPYING
+ CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
+ DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
+ PATENT MARKING NOTICE (below), and the PATENT RIGHTS
+ GRANT (below) in the documentation and/or other materials
+ provided with the distribution.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+COPYRIGHT NOTICE:
+
+ TokuFT, Tokutek Fractal Tree Indexing Library.
+ Copyright (C) 2007-2013 Tokutek, Inc.
+
+DISCLAIMER:
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+UNIVERSITY PATENT NOTICE:
+
+ The technology is licensed by the Massachusetts Institute of
+ Technology, Rutgers State University of New Jersey, and the Research
+ Foundation of State University of New York at Stony Brook under
+ United States of America Serial No. 11/760379 and to the patents
+ and/or patent applications resulting from it.
+
+PATENT MARKING NOTICE:
+
+ This software is covered by US Patent No. 8,185,551.
+ This software is covered by US Patent No. 8,489,638.
+
+PATENT RIGHTS GRANT:
+
+ "THIS IMPLEMENTATION" means the copyrightable works distributed by
+ Tokutek as part of the Fractal Tree project.
+
+ "PATENT CLAIMS" means the claims of patents that are owned or
+ licensable by Tokutek, both currently or in the future; and that in
+ the absence of this license would be infringed by THIS
+ IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
+
+ "PATENT CHALLENGE" shall mean a challenge to the validity,
+ patentability, enforceability and/or non-infringement of any of the
+ PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
+
+ Tokutek hereby grants to you, for the term and geographical scope of
+ the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
+ irrevocable (except as stated in this section) patent license to
+ make, have made, use, offer to sell, sell, import, transfer, and
+ otherwise run, modify, and propagate the contents of THIS
+ IMPLEMENTATION, where such license applies only to the PATENT
+ CLAIMS. This grant does not include claims that would be infringed
+ only as a consequence of further modifications of THIS
+ IMPLEMENTATION. If you or your agent or licensee institute or order
+ or agree to the institution of patent litigation against any entity
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
+ THIS IMPLEMENTATION constitutes direct or contributory patent
+ infringement, or inducement of patent infringement, then any rights
+ granted to you under this License shall terminate as of the date
+ such litigation is filed. If you or your agent or exclusive
+ licensee institute or order or agree to the institution of a PATENT
+ CHALLENGE, then Tokutek may terminate any rights granted to you
+ under this License.
+*/
+
+// force a race between the scoped malloc global destructor and a thread variable destructor
+
+#ident "Copyright (c) 2015 Tokutek Inc. All rights reserved."
+#define TOKU_SCOPED_MALLOC_DEBUG 1
+#include <toku_portability.h>
+#include <toku_assert.h>
+#include <toku_pthread.h>
+#include <toku_race_tools.h>
+#include <util/scoped_malloc.h>
+
+volatile int state = 0;
+
+static void sm_test(void) {
+ toku::scoped_malloc a(1);
+}
+
+static void *sm_test_f(void *arg) {
+ sm_test();
+ state = 1;
+ while (state != 2) sleep(1);
+ return arg;
+}
+
+int main(void) {
+ TOKU_VALGRIND_HG_DISABLE_CHECKING(&state, sizeof state);
+ state = 0;
+ toku_scoped_malloc_init();
+ toku_pthread_t tid;
+ int r;
+ r = toku_pthread_create(&tid, NULL, sm_test_f, NULL);
+ assert_zero(r);
+ void *ret;
+ while (state != 1) sleep(1);
+ toku_scoped_malloc_destroy_set();
+ state = 2;
+ r = toku_pthread_join(tid, &ret);
+ assert_zero(r);
+ toku_scoped_malloc_destroy_key();
+ return 0;
+}
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index 2aa2dcbda93..6c514c6d94b 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -6203,6 +6203,12 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
if (error) { goto cleanup; }
thd_set_ha_data(thd, tokudb_hton, trx);
}
+
+ if (tokudb_debug & TOKUDB_DEBUG_TXN) {
+ TOKUDB_HANDLER_TRACE("trx %p %p %p %p %u %u", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level,
+ trx->tokudb_lock_count, trx->create_lock_count);
+ }
+
if (trx->all == NULL) {
trx->sp_level = NULL;
}
@@ -6211,22 +6217,16 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
if (lock_type == F_WRLCK) {
use_write_locks = true;
}
- if (!trx->tokudb_lock_count++) {
- if (trx->stmt) {
- if (tokudb_debug & TOKUDB_DEBUG_TXN) {
- TOKUDB_HANDLER_TRACE("stmt already set %p %p %p %p", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level);
- }
- } else {
- assert(trx->stmt == 0);
- transaction = NULL; // Safety
- error = create_txn(thd, trx);
- if (error) {
- trx->tokudb_lock_count--; // We didn't get the lock
- goto cleanup;
- }
+ if (!trx->stmt) {
+ transaction = NULL; // Safety
+ error = create_txn(thd, trx);
+ if (error) {
+ goto cleanup;
}
+ trx->create_lock_count = trx->tokudb_lock_count;
}
transaction = trx->sub_sp_level;
+ trx->tokudb_lock_count++;
}
else {
tokudb_pthread_mutex_lock(&share->mutex);
@@ -6241,21 +6241,24 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
added_rows = 0;
deleted_rows = 0;
share->rows_from_locked_table = 0;
- if (trx->tokudb_lock_count > 0 && !--trx->tokudb_lock_count) {
- if (trx->stmt) {
- /*
- F_UNLCK is done without a transaction commit / rollback.
- This happens if the thread didn't update any rows
- We must in this case commit the work to keep the row locks
- */
- DBUG_PRINT("trans", ("commiting non-updating transaction"));
- reset_stmt_progress(&trx->stmt_progress);
- commit_txn(trx->stmt, 0);
- trx->stmt = NULL;
- trx->sub_sp_level = NULL;
+ if (trx->tokudb_lock_count > 0) {
+ if (--trx->tokudb_lock_count <= trx->create_lock_count) {
+ trx->create_lock_count = 0;
+ if (trx->stmt) {
+ /*
+ F_UNLCK is done without a transaction commit / rollback.
+ This happens if the thread didn't update any rows
+ We must in this case commit the work to keep the row locks
+ */
+ DBUG_PRINT("trans", ("commiting non-updating transaction"));
+ reset_stmt_progress(&trx->stmt_progress);
+ commit_txn(trx->stmt, 0);
+ trx->stmt = NULL;
+ trx->sub_sp_level = NULL;
+ }
}
+ transaction = NULL;
}
- transaction = NULL;
}
cleanup:
if (tokudb_debug & TOKUDB_DEBUG_LOCK)
@@ -6270,8 +6273,9 @@ cleanup:
*/
int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) {
TOKUDB_HANDLER_DBUG_ENTER("cmd %d lock %d %s", thd_sql_command(thd), lock_type, share->table_name);
- if (0)
+ if (tokudb_debug & TOKUDB_DEBUG_LOCK) {
TOKUDB_HANDLER_TRACE("q %s", thd->query());
+ }
int error = 0;
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton);
@@ -6281,6 +6285,11 @@ int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) {
thd_set_ha_data(thd, tokudb_hton, trx);
}
+ if (tokudb_debug & TOKUDB_DEBUG_TXN) {
+ TOKUDB_HANDLER_TRACE("trx %p %p %p %p %u %u", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level,
+ trx->tokudb_lock_count, trx->create_lock_count);
+ }
+
/*
note that trx->stmt may have been already initialized as start_stmt()
is called for *each table* not for each storage engine,
@@ -6291,9 +6300,7 @@ int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) {
if (error) {
goto cleanup;
}
- if (tokudb_debug & TOKUDB_DEBUG_TXN) {
- TOKUDB_HANDLER_TRACE("%p %p %p %p %u", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level, trx->tokudb_lock_count);
- }
+ trx->create_lock_count = trx->tokudb_lock_count;
}
else {
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
diff --git a/storage/tokudb/ha_tokudb_admin.cc b/storage/tokudb/ha_tokudb_admin.cc
index b109cd1b976..42205c6d6be 100644
--- a/storage/tokudb/ha_tokudb_admin.cc
+++ b/storage/tokudb/ha_tokudb_admin.cc
@@ -121,9 +121,10 @@ static int analyze_progress(void *v_extra, uint64_t rows) {
progress_time = (float) (t_now - t_start) / (float) t_limit;
char *write_status_msg = extra->write_status_msg;
TABLE_SHARE *table_share = extra->table_share;
- sprintf(write_status_msg, "%s.%s.%s %u of %u %.lf%% rows %.lf%% time",
- table_share->db.str, table_share->table_name.str, extra->key_name,
- extra->key_i, table_share->keys, progress_rows * 100.0, progress_time * 100.0);
+ sprintf(write_status_msg, "%.*s.%.*s.%s %u of %u %.lf%% rows %.lf%% time",
+ (int) table_share->db.length, table_share->db.str,
+ (int) table_share->table_name.length, table_share->table_name.str,
+ extra->key_name, extra->key_i, table_share->keys, progress_rows * 100.0, progress_time * 100.0);
thd_proc_info(thd, write_status_msg);
return 0;
}
@@ -338,8 +339,10 @@ static int ha_tokudb_check_progress(void *extra, float progress) {
static void ha_tokudb_check_info(THD *thd, TABLE *table, const char *msg) {
if (thd->vio_ok()) {
- char tablename[256];
- snprintf(tablename, sizeof tablename, "%s.%s", table->s->db.str, table->s->table_name.str);
+ char tablename[table->s->db.length + 1 + table->s->table_name.length + 1];
+ snprintf(tablename, sizeof tablename, "%.*s.%.*s",
+ (int) table->s->db.length, table->s->db.str,
+ (int) table->s->table_name.length, table->s->table_name.str);
thd->protocol->prepare_for_resend();
thd->protocol->store(tablename, strlen(tablename), system_charset_info);
thd->protocol->store("check", 5, system_charset_info);
@@ -388,6 +391,11 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) {
}
struct check_context check_context = { thd };
r = db->verify_with_progress(db, ha_tokudb_check_progress, &check_context, (tokudb_debug & TOKUDB_DEBUG_CHECK) != 0, keep_going);
+ if (r != 0) {
+ char msg[32 + strlen(kname)];
+ sprintf(msg, "Corrupt %s", kname);
+ ha_tokudb_check_info(thd, table, msg);
+ }
snprintf(write_status_msg, sizeof write_status_msg, "%s key=%s %u result=%d", share->table_name, kname, i, r);
thd_proc_info(thd, write_status_msg);
if (tokudb_debug & TOKUDB_DEBUG_CHECK) {
diff --git a/storage/tokudb/ha_tokudb_alter_56.cc b/storage/tokudb/ha_tokudb_alter_56.cc
index d574bae9a33..28c0b4419c0 100644
--- a/storage/tokudb/ha_tokudb_alter_56.cc
+++ b/storage/tokudb/ha_tokudb_alter_56.cc
@@ -784,13 +784,16 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i
assert(trx->tokudb_lock_count > 0);
// for partitioned tables, we use a single transaction to do all of the partition changes. the tokudb_lock_count
// is a reference count for each of the handlers to the same transaction. obviously, we want to only abort once.
- if (!--trx->tokudb_lock_count) {
- abort_txn(ctx->alter_txn);
- ctx->alter_txn = NULL;
- trx->stmt = NULL;
- trx->sub_sp_level = NULL;
+ if (trx->tokudb_lock_count > 0) {
+ if (--trx->tokudb_lock_count <= trx->create_lock_count) {
+ trx->create_lock_count = 0;
+ abort_txn(ctx->alter_txn);
+ ctx->alter_txn = NULL;
+ trx->stmt = NULL;
+ trx->sub_sp_level = NULL;
+ }
+ transaction = NULL;
}
- transaction = NULL;
if (ctx->add_index_changed) {
restore_add_index(table, ha_alter_info->index_add_count, ctx->incremented_num_DBs, ctx->modified_DBs);
diff --git a/storage/tokudb/hatoku_defines.h b/storage/tokudb/hatoku_defines.h
index 69dbd6b7e5c..f93e07548e6 100644
--- a/storage/tokudb/hatoku_defines.h
+++ b/storage/tokudb/hatoku_defines.h
@@ -356,6 +356,7 @@ typedef struct st_tokudb_trx_data {
DB_TXN *sp_level;
DB_TXN *sub_sp_level;
uint tokudb_lock_count;
+ uint create_lock_count;
tokudb_stmt_progress stmt_progress;
bool checkpoint_lock_taken;
LIST *handlers;
diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc
index d282d68acc1..1572c3652e0 100644
--- a/storage/tokudb/hatoku_hton.cc
+++ b/storage/tokudb/hatoku_hton.cc
@@ -1714,6 +1714,8 @@ static int tokudb_fractal_tree_info(TABLE *table, THD *thd) {
error = tmp_cursor->c_get(tmp_cursor, &curr_key, &curr_val, DB_NEXT);
if (!error) {
error = tokudb_report_fractal_tree_info_for_db(&curr_key, &curr_val, table, thd);
+ if (error)
+ error = 0; // ignore read uncommitted errors
}
if (!error && thd_killed(thd))
error = ER_QUERY_INTERRUPTED;
@@ -1992,7 +1994,9 @@ struct tokudb_search_txn_extra {
uint64_t match_client_id;
};
-static int tokudb_search_txn_callback(uint64_t txn_id, uint64_t client_id, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) {
+static int tokudb_search_txn_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) {
+ uint64_t txn_id = txn->id64(txn);
+ uint64_t client_id = txn->get_client_id(txn);
struct tokudb_search_txn_extra *e = reinterpret_cast<struct tokudb_search_txn_extra *>(extra);
if (e->match_txn_id == txn_id) {
e->match_found = true;
@@ -2124,6 +2128,7 @@ static struct st_mysql_information_schema tokudb_trx_information_schema = { MYSQ
static ST_FIELD_INFO tokudb_trx_field_info[] = {
{"trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE },
{"trx_mysql_thread_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE },
+ {"trx_time", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE },
{NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE}
};
@@ -2132,12 +2137,17 @@ struct tokudb_trx_extra {
TABLE *table;
};
-static int tokudb_trx_callback(uint64_t txn_id, uint64_t client_id, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) {
+static int tokudb_trx_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) {
+ uint64_t txn_id = txn->id64(txn);
+ uint64_t client_id = txn->get_client_id(txn);
+ uint64_t start_time = txn->get_start_time(txn);
struct tokudb_trx_extra *e = reinterpret_cast<struct tokudb_trx_extra *>(extra);
THD *thd = e->thd;
TABLE *table = e->table;
table->field[0]->store(txn_id, false);
table->field[1]->store(client_id, false);
+ uint64_t tnow = (uint64_t) time(NULL);
+ table->field[2]->store(tnow >= start_time ? tnow - start_time : 0, false);
int error = schema_table_store_record(thd, table);
if (!error && thd_killed(thd))
error = ER_QUERY_INTERRUPTED;
@@ -2285,7 +2295,9 @@ struct tokudb_locks_extra {
TABLE *table;
};
-static int tokudb_locks_callback(uint64_t txn_id, uint64_t client_id, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) {
+static int tokudb_locks_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) {
+ uint64_t txn_id = txn->id64(txn);
+ uint64_t client_id = txn->get_client_id(txn);
struct tokudb_locks_extra *e = reinterpret_cast<struct tokudb_locks_extra *>(extra);
THD *thd = e->thd;
TABLE *table = e->table;
diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result
index 018900c7b98..190581eddae 100644
--- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result
+++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result
@@ -2,7 +2,7 @@ set default_storage_engine='tokudb';
set tokudb_prelock_empty=false;
drop table if exists t;
create table t (id int primary key);
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
select * from information_schema.tokudb_locks;
locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name
@@ -19,7 +19,7 @@ TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main
select * from information_schema.tokudb_lock_waits;
requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name
REQUEST_TRX_ID BLOCK_TRX_ID ./test/t-main 0001000000 0001000000 LOCK_WAITS_START_TIME test t main
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
TRX_ID MYSQL_ID
TRX_ID MYSQL_ID
@@ -31,7 +31,7 @@ select * from information_schema.tokudb_lock_waits;
requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
commit;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
select * from information_schema.tokudb_locks;
locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name
@@ -48,7 +48,7 @@ TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main
select * from information_schema.tokudb_lock_waits;
requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name
REQUEST_TRX_ID BLOCK_TRX_ID ./test/t-main 0001000000 0001000000 LOCK_WAITS_START_TIME test t main
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
TRX_ID MYSQL_ID
TRX_ID MYSQL_ID
@@ -59,7 +59,7 @@ TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main
select * from information_schema.tokudb_lock_waits;
requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name
commit;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
select * from information_schema.tokudb_locks;
locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name
diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result
index b9fca50b507..13cdad7a438 100644
--- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result
+++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result
@@ -2,7 +2,7 @@ set default_storage_engine='tokudb';
set tokudb_prelock_empty=false;
drop table if exists t;
create table t (id int primary key);
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
select * from information_schema.tokudb_locks;
locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name
@@ -19,7 +19,7 @@ TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main
select * from information_schema.tokudb_lock_waits;
requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name
REQUEST_TRX_ID BLOCK_TRX_ID ./test/t-main 0001000000 0001000000 LOCK_WAITS_START_TIME test t main
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
TRX_ID MYSQL_ID
TRX_ID MYSQL_ID
@@ -30,7 +30,7 @@ select * from information_schema.tokudb_lock_waits;
requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
select * from information_schema.tokudb_locks;
locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name
diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result
index e4c1adcca19..63e4816e16e 100644
--- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result
+++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result
@@ -1,23 +1,23 @@
set default_storage_engine='tokudb';
set tokudb_prelock_empty=false;
drop table if exists t;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
set autocommit=0;
create table t (id int primary key);
insert into t values (1);
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
TXN_ID_DEFAULT CLIENT_ID_DEFAULT
commit;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
set autocommit=0;
insert into t values (2);
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
TXN_ID_A CLIENT_ID_A
commit;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
trx_id trx_mysql_thread_id
drop table t;
diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test
index c4f9ccefe5c..0f712000527 100644
--- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test
+++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test
@@ -13,7 +13,7 @@ create table t (id int primary key);
# verify that txn_a insert (1) blocks txn_b insert (1) and txn_b gets a duplicate key error
# should be empty
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
select * from information_schema.tokudb_locks;
select * from information_schema.tokudb_lock_waits;
@@ -43,7 +43,7 @@ select * from information_schema.tokudb_lock_waits;
# should find the presence of two transactions
replace_column 1 TRX_ID 2 MYSQL_ID;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
connection conn_a;
commit;
@@ -66,7 +66,7 @@ disconnect conn_b;
# verify that the lock on the 2nd transaction has been released
# should be be empty
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
select * from information_schema.tokudb_locks;
select * from information_schema.tokudb_lock_waits;
@@ -96,7 +96,7 @@ select * from information_schema.tokudb_lock_waits;
# should find the presence of two transactions
replace_column 1 TRX_ID 2 MYSQL_ID;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
connection conn_a;
commit;
@@ -116,7 +116,7 @@ disconnect conn_b;
# verify that the lock on the 2nd transaction has been released
# should be be empty
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
select * from information_schema.tokudb_locks;
select * from information_schema.tokudb_lock_waits;
diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test
index 75929fa3b3d..3011443fa04 100644
--- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test
+++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test
@@ -10,7 +10,7 @@ enable_warnings;
create table t (id int primary key);
# should be empty
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
select * from information_schema.tokudb_locks;
select * from information_schema.tokudb_lock_waits;
@@ -40,7 +40,7 @@ select * from information_schema.tokudb_lock_waits;
# should find the presence of two transactions
replace_column 1 TRX_ID 2 MYSQL_ID;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
connection conn_a;
sleep 5; # sleep longer than the lock timer to force a lock timeout on txn_b
@@ -61,7 +61,7 @@ disconnect conn_a;
disconnect conn_b;
# should be be empty
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
select * from information_schema.tokudb_locks;
select * from information_schema.tokudb_lock_waits;
diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test
index b1d5c7e5009..d3c2636ba54 100644
--- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test
+++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test
@@ -8,7 +8,7 @@ drop table if exists t;
enable_warnings;
# should be empty
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
# should have my txn
let $default_id=`select connection_id()`;
@@ -16,11 +16,11 @@ set autocommit=0;
create table t (id int primary key);
insert into t values (1);
replace_column 1 TXN_ID_DEFAULT 2 CLIENT_ID_DEFAULT;
-eval select * from information_schema.tokudb_trx;
+eval select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
# should be empty
commit;
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
connect(conn_a,localhost,root,,);
let a_id=`select connection_id()`;
@@ -29,13 +29,13 @@ insert into t values (2);
connection default;
replace_column 1 TXN_ID_A 2 CLIENT_ID_A;
-eval select * from information_schema.tokudb_trx;
+eval select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
connection conn_a;
commit;
connection default;
# should be empty
-select * from information_schema.tokudb_trx;
+select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
disconnect conn_a;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db805.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db805.result
new file mode 100644
index 00000000000..1bc0372f1b8
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db805.result
@@ -0,0 +1,18 @@
+drop table if exists t1,t3;
+create table t3(a3 int,b3 decimal(0,0),c3 int,d3 int,primary key(a3,b3)) engine=TOKUDB;
+LOCK TABLES t3 WRITE;
+create temporary table t1(f1 int,index(f1)) engine=innodb;
+INSERT INTO t1 VALUES(1),(1),(1);
+select * from t1;
+f1
+1
+1
+1
+ALTER TABLE t1 engine=TOKUDB;
+select * from t1;
+f1
+1
+1
+1
+unlock tables;
+drop table t1,t3;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db806.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db806.result
new file mode 100644
index 00000000000..ae87dbab281
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db806.result
@@ -0,0 +1,9 @@
+drop table if exists t1,t3;
+CREATE TABLE t3(a int,c int,d int)engine=TOKUDB;
+lock table t3 read;
+create temporary table t1 engine=tokudb as SELECT 1;
+select * from t1;
+1
+1
+unlock tables;
+drop table t1,t3;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db811.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db811.result
new file mode 100644
index 00000000000..1d26f43c9dd
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db811.result
@@ -0,0 +1,14 @@
+drop table if exists t2,t3,t4;
+CREATE TABLE t3(a INT,b INT,UNIQUE KEY (a,b)) engine=TOKUDB;
+CREATE TABLE t4(c1 FLOAT ZEROFILL) engine=innodb;
+CREATE TABLE t2(a int KEY,b CHAR (1)) engine=TOKUDB PARTITION BY HASH (a) PARTITIONS 13;
+LOCK TABLES t4 WRITE,t3 WRITE,t2 WRITE;
+INSERT INTO t2(a)VALUES (REPEAT(0,1));
+ALTER TABLE t2 ADD COLUMN(c INT);
+alter table t4 add column c int;
+UPDATE t2 SET a=1;
+select * from t2;
+a b c
+1 NULL NULL
+unlock tables;
+drop table t2,t3,t4;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result
new file mode 100644
index 00000000000..0a50e63e037
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result
@@ -0,0 +1,14 @@
+drop table if exists t2,t3,t4;
+CREATE TABLE t3(a INT,b INT,UNIQUE KEY (a,b)) engine=TOKUDB;
+CREATE TABLE t4(c1 FLOAT ZEROFILL) engine=innodb;
+CREATE TABLE t2(a int KEY,b CHAR (1)) engine=TOKUDB PARTITION BY HASH (a) PARTITIONS 1;
+LOCK TABLES t4 WRITE,t3 WRITE,t2 WRITE;
+INSERT INTO t2(a)VALUES (REPEAT(0,1));
+ALTER TABLE t2 ADD COLUMN(c INT);
+alter table t4 add column c int;
+UPDATE t2 SET a=1;
+select * from t2;
+a b c
+1 NULL NULL
+unlock tables;
+drop table t2,t3,t4;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db823.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db823.result
new file mode 100644
index 00000000000..d94da5c0673
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db823.result
@@ -0,0 +1,11 @@
+drop table if exists s,t;
+create table s (id int) engine=tokudb;
+lock tables s write;
+create temporary table t (id int, key(id)) engine=innodb;
+insert into t values (1);
+alter table t engine=tokudb;
+select * from t;
+id
+1
+unlock tables;
+drop table s, t;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result b/storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result
index e63f73caf20..0cf75d40847 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result
@@ -3,7 +3,8 @@ drop table if exists t;
create table t (id int primary key);
begin;
insert into t values (1),(2);
-select * from information_schema.tokudb_fractal_tree_info;
-ERROR HY000: Got error -30994 "Internal error < 0 (Not system error)" from storage engine TokuDB
+select dictionary_name from information_schema.tokudb_fractal_tree_info;
+dictionary_name
+./test/t-status
commit;
drop table t;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db805.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db805.test
new file mode 100644
index 00000000000..1114de6b325
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db805.test
@@ -0,0 +1,17 @@
+# DB-805 test that conversion of t1 from innodb to tokudb can write rows
+source include/have_tokudb.inc;
+source include/have_innodb.inc;
+disable_warnings;
+drop table if exists t1,t3;
+enable_warnings;
+
+create table t3(a3 int,b3 decimal(0,0),c3 int,d3 int,primary key(a3,b3)) engine=TOKUDB;
+LOCK TABLES t3 WRITE;
+create temporary table t1(f1 int,index(f1)) engine=innodb;
+INSERT INTO t1 VALUES(1),(1),(1);
+select * from t1;
+ALTER TABLE t1 engine=TOKUDB;
+select * from t1;
+unlock tables;
+
+drop table t1,t3;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db806.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db806.test
new file mode 100644
index 00000000000..3815e59f78c
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db806.test
@@ -0,0 +1,13 @@
+# DB-806 test that lock tables and create select can write rows to the new table
+source include/have_tokudb.inc;
+disable_warnings;
+drop table if exists t1,t3;
+enable_warnings;
+
+CREATE TABLE t3(a int,c int,d int)engine=TOKUDB;
+lock table t3 read;
+create temporary table t1 engine=tokudb as SELECT 1;
+select * from t1;
+unlock tables;
+
+drop table t1,t3; \ No newline at end of file
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db811.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db811.test
new file mode 100644
index 00000000000..509f482765e
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db811.test
@@ -0,0 +1,22 @@
+# DB-811 test that alter table t2 updates both the schema (FRM) and the data (tokudb files)
+
+source include/have_tokudb.inc;
+source include/have_innodb.inc;
+source include/have_partition.inc;
+disable_warnings;
+drop table if exists t2,t3,t4;
+enable_warnings;
+
+CREATE TABLE t3(a INT,b INT,UNIQUE KEY (a,b)) engine=TOKUDB;
+CREATE TABLE t4(c1 FLOAT ZEROFILL) engine=innodb;
+CREATE TABLE t2(a int KEY,b CHAR (1)) engine=TOKUDB PARTITION BY HASH (a) PARTITIONS 13;
+LOCK TABLES t4 WRITE,t3 WRITE,t2 WRITE;
+INSERT INTO t2(a)VALUES (REPEAT(0,1));
+ALTER TABLE t2 ADD COLUMN(c INT);
+alter table t4 add column c int;
+UPDATE t2 SET a=1;
+select * from t2;
+unlock tables;
+
+drop table t2,t3,t4;
+
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test
new file mode 100644
index 00000000000..5b8c6ed79d3
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test
@@ -0,0 +1,22 @@
+# DB-811 test that alter table t2 updates both the schema (FRM) and the data (tokudb files)
+
+source include/have_tokudb.inc;
+source include/have_innodb.inc;
+source include/have_partition.inc;
+disable_warnings;
+drop table if exists t2,t3,t4;
+enable_warnings;
+
+CREATE TABLE t3(a INT,b INT,UNIQUE KEY (a,b)) engine=TOKUDB;
+CREATE TABLE t4(c1 FLOAT ZEROFILL) engine=innodb;
+CREATE TABLE t2(a int KEY,b CHAR (1)) engine=TOKUDB PARTITION BY HASH (a) PARTITIONS 1;
+LOCK TABLES t4 WRITE,t3 WRITE,t2 WRITE;
+INSERT INTO t2(a)VALUES (REPEAT(0,1));
+ALTER TABLE t2 ADD COLUMN(c INT);
+alter table t4 add column c int;
+UPDATE t2 SET a=1;
+select * from t2;
+unlock tables;
+
+drop table t2,t3,t4;
+
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db823.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db823.test
new file mode 100644
index 00000000000..2e01c0e5797
--- /dev/null
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db823.test
@@ -0,0 +1,16 @@
+# test DB-823
+# test that the conversion of table t from innodb to tokudb succeeds.
+source include/have_tokudb.inc;
+source include/have_innodb.inc;
+disable_warnings;
+drop table if exists s,t;
+enable_warnings;
+create table s (id int) engine=tokudb;
+lock tables s write;
+create temporary table t (id int, key(id)) engine=innodb;
+insert into t values (1);
+alter table t engine=tokudb;
+select * from t;
+unlock tables;
+drop table s, t;
+
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test b/storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test
index 415bb7a2332..735a88afed8 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test
@@ -7,7 +7,6 @@ enable_warnings;
create table t (id int primary key);
begin;
insert into t values (1),(2);
---error 1030
-select * from information_schema.tokudb_fractal_tree_info;
+select dictionary_name from information_schema.tokudb_fractal_tree_info;
commit;
drop table t;
diff --git a/storage/xtradb/api/api0api.cc b/storage/xtradb/api/api0api.cc
index 3859fb84b81..8769fc47166 100644
--- a/storage/xtradb/api/api0api.cc
+++ b/storage/xtradb/api/api0api.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2008, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2008, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -318,35 +318,6 @@ ib_wake_master_thread(void)
}
}
-/*********************************************************************//**
-Calculate the max row size of the columns in a cluster index.
-@return max row length */
-UNIV_INLINE
-ulint
-ib_get_max_row_len(
-/*===============*/
- dict_index_t* cluster) /*!< in: cluster index */
-{
- ulint i;
- ulint max_len = 0;
- ulint n_fields = cluster->n_fields;
-
- /* Add the size of the ordering columns in the
- clustered index. */
- for (i = 0; i < n_fields; ++i) {
- const dict_col_t* col;
-
- col = dict_index_get_nth_col(cluster, i);
-
- /* Use the maximum output size of
- mach_write_compressed(), although the encoded
- length should always fit in 2 bytes. */
- max_len += dict_col_get_max_size(col);
- }
-
- return(max_len);
-}
-
/*****************************************************************//**
Read the columns from a rec into a tuple. */
static
@@ -710,120 +681,6 @@ ib_trx_rollback(
return(err);
}
-/*****************************************************************//**
-Find an index definition from the index vector using index name.
-@return index def. if found else NULL */
-UNIV_INLINE
-const ib_index_def_t*
-ib_table_find_index(
-/*================*/
- ib_vector_t* indexes, /*!< in: vector of indexes */
- const char* name) /*!< in: index name */
-{
- ulint i;
-
- for (i = 0; i < ib_vector_size(indexes); ++i) {
- const ib_index_def_t* index_def;
-
- index_def = (ib_index_def_t*) ib_vector_get(indexes, i);
-
- if (innobase_strcasecmp(name, index_def->name) == 0) {
- return(index_def);
- }
- }
-
- return(NULL);
-}
-
-/*****************************************************************//**
-Get the InnoDB internal precise type from the schema column definition.
-@return precise type in api format */
-UNIV_INLINE
-ulint
-ib_col_get_prtype(
-/*==============*/
- const ib_col_t* ib_col) /*!< in: column definition */
-{
- ulint prtype = 0;
-
- if (ib_col->ib_col_attr & IB_COL_UNSIGNED) {
- prtype |= DATA_UNSIGNED;
-
- ut_a(ib_col->ib_col_type == IB_INT);
- }
-
- if (ib_col->ib_col_attr & IB_COL_NOT_NULL) {
- prtype |= DATA_NOT_NULL;
- }
-
- return(prtype);
-}
-
-/*****************************************************************//**
-Get the InnoDB internal main type from the schema column definition.
-@return column main type */
-UNIV_INLINE
-ulint
-ib_col_get_mtype(
-/*==============*/
- const ib_col_t* ib_col) /*!< in: column definition */
-{
- /* Note: The api0api.h types should map directly to
- the internal numeric codes. */
- return(ib_col->ib_col_type);
-}
-
-/*****************************************************************//**
-Find a column in the the column vector with the same name.
-@return col. def. if found else NULL */
-UNIV_INLINE
-const ib_col_t*
-ib_table_find_col(
-/*==============*/
- const ib_vector_t* cols, /*!< in: column list head */
- const char* name) /*!< in: column name to find */
-{
- ulint i;
-
- for (i = 0; i < ib_vector_size(cols); ++i) {
- const ib_col_t* ib_col;
-
- ib_col = static_cast<const ib_col_t*>(
- ib_vector_get((ib_vector_t*) cols, i));
-
- if (innobase_strcasecmp(ib_col->name, name) == 0) {
- return(ib_col);
- }
- }
-
- return(NULL);
-}
-
-/*****************************************************************//**
-Find a column in the the column list with the same name.
-@return col. def. if found else NULL */
-UNIV_INLINE
-const ib_key_col_t*
-ib_index_find_col(
-/*==============*/
- ib_vector_t* cols, /*!< in: column list head */
- const char* name) /*!< in: column name to find */
-{
- ulint i;
-
- for (i = 0; i < ib_vector_size(cols); ++i) {
- const ib_key_col_t* ib_col;
-
- ib_col = static_cast<ib_key_col_t*>(ib_vector_get(cols, i));
-
- if (innobase_strcasecmp(ib_col->name, name) == 0) {
- return(ib_col);
- }
- }
-
- return(NULL);
-}
-
#ifdef __WIN__
/*****************************************************************//**
Convert a string to lower case. */
@@ -947,34 +804,6 @@ ib_table_name_check(
/*****************************************************************//**
-Get an index definition that is tagged as a clustered index.
-@return cluster index schema */
-UNIV_INLINE
-ib_index_def_t*
-ib_find_clustered_index(
-/*====================*/
- ib_vector_t* indexes) /*!< in: index defs. to search */
-{
- ulint i;
- ulint n_indexes;
-
- n_indexes = ib_vector_size(indexes);
-
- for (i = 0; i < n_indexes; ++i) {
- ib_index_def_t* ib_index_def;
-
- ib_index_def = static_cast<ib_index_def_t*>(
- ib_vector_get(indexes, i));
-
- if (ib_index_def->clustered) {
- return(ib_index_def);
- }
- }
-
- return(NULL);
-}
-
-/*****************************************************************//**
Get a table id. The caller must have acquired the dictionary mutex.
@return DB_SUCCESS if found */
static
@@ -3564,41 +3393,6 @@ ib_cursor_set_cluster_access(
prebuilt->need_to_access_clustered = TRUE;
}
-/*************************************************************//**
-Convert and write an INT column value to an InnoDB tuple.
-@return DB_SUCCESS or error */
-UNIV_INLINE
-ib_err_t
-ib_tuple_write_int(
-/*===============*/
- ib_tpl_t ib_tpl, /*!< in/out: tuple to write to */
- ulint col_no, /*!< in: column number */
- const void* value, /*!< in: integer value */
- ulint value_len) /*!< in: sizeof value type */
-{
- const dfield_t* dfield;
- ulint data_len;
- ulint type_len;
- ib_tuple_t* tuple = (ib_tuple_t*) ib_tpl;
-
- ut_a(col_no < ib_tuple_get_n_cols(ib_tpl));
-
- dfield = ib_col_get_dfield(tuple, col_no);
-
- data_len = dfield_get_len(dfield);
- type_len = dtype_get_len(dfield_get_type(dfield));
-
- if (dtype_get_mtype(dfield_get_type(dfield)) != DATA_INT
- || value_len != data_len) {
-
- return(DB_DATA_MISMATCH);
- }
-
- return(ib_col_set_value(
- ib_tpl, static_cast<ib_ulint_t>(col_no),
- value, static_cast<ib_ulint_t>(type_len), true));
-}
-
/*****************************************************************//**
Write an integer value to a column. Integers are stored in big-endian
format and will need to be converted from the host format.
diff --git a/storage/xtradb/dict/dict0boot.cc b/storage/xtradb/dict/dict0boot.cc
index b57a8873bd5..94a3af2852b 100644
--- a/storage/xtradb/dict/dict0boot.cc
+++ b/storage/xtradb/dict/dict0boot.cc
@@ -302,8 +302,7 @@ dict_boot(void)
/* Insert into the dictionary cache the descriptions of the basic
system tables */
/*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0,
- false);
+ table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0);
dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
@@ -357,8 +356,7 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0,
- false);
+ table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0);
dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
@@ -391,8 +389,7 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0,
- false);
+ table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0);
dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
@@ -425,8 +422,7 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0,
- false);
+ table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0);
dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc
index 3b044c74b52..811d737e6bf 100644
--- a/storage/xtradb/dict/dict0dict.cc
+++ b/storage/xtradb/dict/dict0dict.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
@@ -684,6 +684,33 @@ dict_table_get_col_name_for_mysql(
return(s);
}
#ifndef UNIV_HOTBACKUP
+/** Allocate and init the autoinc latch of a given table.
+This function must not be called concurrently on the same table object.
+@param[in,out] table_void table whose autoinc latch to create */
+void
+dict_table_autoinc_alloc(
+ void* table_void)
+{
+ dict_table_t* table = static_cast<dict_table_t*>(table_void);
+ table->autoinc_mutex = new (std::nothrow) ib_mutex_t();
+ ut_a(table->autoinc_mutex != NULL);
+ mutex_create(autoinc_mutex_key,
+ table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
+}
+
+/** Allocate and init the zip_pad_mutex of a given index.
+This function must not be called concurrently on the same index object.
+@param[in,out] index_void index whose zip_pad_mutex to create */
+void
+dict_index_zip_pad_alloc(
+ void* index_void)
+{
+ dict_index_t* index = static_cast<dict_index_t*>(index_void);
+ index->zip_pad.mutex = new (std::nothrow) os_fast_mutex_t;
+ ut_a(index->zip_pad.mutex != NULL);
+ os_fast_mutex_init(zip_pad_mutex_key, index->zip_pad.mutex);
+}
+
/********************************************************************//**
Acquire the autoinc lock. */
UNIV_INTERN
@@ -692,7 +719,32 @@ dict_table_autoinc_lock(
/*====================*/
dict_table_t* table) /*!< in/out: table */
{
- mutex_enter(&table->autoinc_mutex);
+#ifdef HAVE_ATOMIC_BUILTINS
+ os_once::do_or_wait_for_done(
+ &table->autoinc_mutex_created,
+ dict_table_autoinc_alloc, table);
+#else /* HAVE_ATOMIC_BUILTINS */
+ ut_ad(table->autoinc_mutex_created == os_once::DONE);
+#endif /* HAVE_ATOMIC_BUILTINS */
+
+ mutex_enter(table->autoinc_mutex);
+}
+
+/** Acquire the zip_pad_mutex latch.
+@param[in,out] index the index whose zip_pad_mutex to acquire.*/
+void
+dict_index_zip_pad_lock(
+ dict_index_t* index)
+{
+#ifdef HAVE_ATOMIC_BUILTINS
+ os_once::do_or_wait_for_done(
+ &index->zip_pad.mutex_created,
+ dict_index_zip_pad_alloc, index);
+#else /* HAVE_ATOMIC_BUILTINS */
+ ut_ad(index->zip_pad.mutex_created == os_once::DONE);
+#endif /* HAVE_ATOMIC_BUILTINS */
+
+ os_fast_mutex_lock(index->zip_pad.mutex);
}
/********************************************************************//**
@@ -704,7 +756,7 @@ dict_table_autoinc_initialize(
dict_table_t* table, /*!< in/out: table */
ib_uint64_t value) /*!< in: next value to assign to a row */
{
- ut_ad(mutex_own(&table->autoinc_mutex));
+ ut_ad(dict_table_autoinc_own(table));
table->autoinc = value;
}
@@ -746,7 +798,7 @@ dict_table_autoinc_read(
/*====================*/
const dict_table_t* table) /*!< in: table */
{
- ut_ad(mutex_own(&table->autoinc_mutex));
+ ut_ad(dict_table_autoinc_own(table));
return(table->autoinc);
}
@@ -762,7 +814,7 @@ dict_table_autoinc_update_if_greater(
dict_table_t* table, /*!< in/out: table */
ib_uint64_t value) /*!< in: value which was assigned to a row */
{
- ut_ad(mutex_own(&table->autoinc_mutex));
+ ut_ad(dict_table_autoinc_own(table));
if (value > table->autoinc) {
@@ -778,7 +830,7 @@ dict_table_autoinc_unlock(
/*======================*/
dict_table_t* table) /*!< in/out: table */
{
- mutex_exit(&table->autoinc_mutex);
+ mutex_exit(table->autoinc_mutex);
}
#endif /* !UNIV_HOTBACKUP */
@@ -1626,15 +1678,18 @@ dict_table_rename_in_cache(
} else if (table->space != TRX_SYS_SPACE) {
char* new_path = NULL;
- if (table->dir_path_of_temp_table != NULL) {
+ if (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Error: trying to rename a"
" TEMPORARY TABLE ", stderr);
ut_print_name(stderr, NULL, TRUE, old_name);
- fputs(" (", stderr);
- ut_print_filename(stderr,
- table->dir_path_of_temp_table);
- fputs(" )\n", stderr);
+ if (table->dir_path_of_temp_table != NULL) {
+ fputs(" (", stderr);
+ ut_print_filename(
+ stderr, table->dir_path_of_temp_table);
+ fputs(" )\n", stderr);
+ }
+
return(DB_ERROR);
} else if (DICT_TF_HAS_DATA_DIR(table->flags)) {
@@ -5945,8 +6000,7 @@ dict_ind_init(void)
dict_table_t* table;
/* create dummy table and index for REDUNDANT infimum and supremum */
- table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0,
- true);
+ table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0);
dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
DATA_ENGLISH | DATA_NOT_NULL, 8);
@@ -5959,7 +6013,7 @@ dict_ind_init(void)
/* create dummy table and index for COMPACT infimum and supremum */
table = dict_mem_table_create("SYS_DUMMY2",
DICT_HDR_SPACE, 1,
- DICT_TF_COMPACT, 0, true);
+ DICT_TF_COMPACT, 0);
dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
DATA_ENGLISH | DATA_NOT_NULL, 8);
dict_ind_compact = dict_mem_index_create("SYS_DUMMY2", "SYS_DUMMY2",
@@ -6795,10 +6849,10 @@ dict_index_zip_success(
return;
}
- os_fast_mutex_lock(&index->zip_pad.mutex);
+ dict_index_zip_pad_lock(index);
++index->zip_pad.success;
dict_index_zip_pad_update(&index->zip_pad, zip_threshold);
- os_fast_mutex_unlock(&index->zip_pad.mutex);
+ dict_index_zip_pad_unlock(index);
}
/*********************************************************************//**
@@ -6818,10 +6872,10 @@ dict_index_zip_failure(
return;
}
- os_fast_mutex_lock(&index->zip_pad.mutex);
+ dict_index_zip_pad_lock(index);
++index->zip_pad.failure;
dict_index_zip_pad_update(&index->zip_pad, zip_threshold);
- os_fast_mutex_unlock(&index->zip_pad.mutex);
+ dict_index_zip_pad_unlock(index);
}
@@ -6853,9 +6907,9 @@ dict_index_zip_pad_optimal_page_size(
#ifdef HAVE_ATOMIC_BUILTINS
pad = os_atomic_increment_ulint(&index->zip_pad.pad, 0);
#else /* HAVE_ATOMIC_BUILTINS */
- os_fast_mutex_lock(&index->zip_pad.mutex);
+ dict_index_zip_pad_lock(index);
pad = index->zip_pad.pad;
- os_fast_mutex_unlock(&index->zip_pad.mutex);
+ dict_index_zip_pad_unlock(index);
#endif /* HAVE_ATOMIC_BUILTINS */
ut_ad(pad < UNIV_PAGE_SIZE);
diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc
index fb33c31ff92..58521b833b6 100644
--- a/storage/xtradb/dict/dict0load.cc
+++ b/storage/xtradb/dict/dict0load.cc
@@ -2182,8 +2182,7 @@ err_len:
/* See if the tablespace is available. */
*table = dict_mem_table_create(
- name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2,
- false);
+ name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2);
field = rec_get_nth_field_old(rec, DICT_FLD__SYS_TABLES__ID, &len);
ut_ad(len == 8); /* this was checked earlier */
diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc
index 43ccbdd5fe7..ffdc5100558 100644
--- a/storage/xtradb/dict/dict0mem.cc
+++ b/storage/xtradb/dict/dict0mem.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
This program is free software; you can redistribute it and/or modify it under
@@ -79,10 +79,7 @@ dict_mem_table_create(
the table is placed */
ulint n_cols, /*!< in: number of columns */
ulint flags, /*!< in: table flags */
- ulint flags2, /*!< in: table flags2 */
- bool nonshared)/*!< in: whether the table object is a dummy
- one that does not need the initialization of
- locking-related fields. */
+ ulint flags2) /*!< in: table flags2 */
{
dict_table_t* table;
mem_heap_t* heap;
@@ -118,18 +115,10 @@ dict_mem_table_create(
dict_table_stats_latch_create(table, true);
#ifndef UNIV_HOTBACKUP
+ table->autoinc_lock = static_cast<ib_lock_t*>(
+ mem_heap_alloc(heap, lock_get_size()));
- if (!nonshared) {
-
- table->autoinc_lock = static_cast<ib_lock_t*>(
- mem_heap_alloc(heap, lock_get_size()));
-
- mutex_create(autoinc_mutex_key,
- &table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
- } else {
-
- table->autoinc_lock = NULL;
- }
+ dict_table_autoinc_create_lazy(table);
table->autoinc = 0;
@@ -212,10 +201,7 @@ dict_mem_table_free(
}
}
#ifndef UNIV_HOTBACKUP
- if (table->autoinc_lock) {
-
- mutex_free(&(table->autoinc_mutex));
- }
+ dict_table_autoinc_destroy(table);
#endif /* UNIV_HOTBACKUP */
dict_table_stats_latch_destroy(table);
@@ -580,8 +566,7 @@ dict_mem_index_create(
dict_mem_fill_index_struct(index, heap, table_name, index_name,
space, type, n_fields);
- os_fast_mutex_init(zip_pad_mutex_key, &index->zip_pad.mutex);
-
+ dict_index_zip_pad_mutex_create_lazy(index);
return(index);
}
@@ -714,7 +699,7 @@ dict_mem_index_free(
}
#endif /* UNIV_BLOB_DEBUG */
- os_fast_mutex_free(&index->zip_pad.mutex);
+ dict_index_zip_pad_mutex_destroy(index);
mem_heap_free(index->heap);
}
diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc
index 34acab04241..363a46d7fdf 100644
--- a/storage/xtradb/fsp/fsp0fsp.cc
+++ b/storage/xtradb/fsp/fsp0fsp.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -305,44 +305,6 @@ xdes_find_bit(
}
/**********************************************************************//**
-Looks for a descriptor bit having the desired value. Scans the extent in
-a direction opposite to xdes_find_bit.
-@return bit index of the bit, ULINT_UNDEFINED if not found */
-UNIV_INLINE
-ulint
-xdes_find_bit_downward(
-/*===================*/
- xdes_t* descr, /*!< in: descriptor */
- ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */
- ibool val, /*!< in: desired bit value */
- ulint hint, /*!< in: hint of which bit position would
- be desirable */
- mtr_t* mtr) /*!< in/out: mini-transaction */
-{
- ulint i;
-
- ut_ad(descr && mtr);
- ut_ad(val <= TRUE);
- ut_ad(hint < FSP_EXTENT_SIZE);
- ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
- for (i = hint + 1; i > 0; i--) {
- if (val == xdes_mtr_get_bit(descr, bit, i - 1, mtr)) {
-
- return(i - 1);
- }
- }
-
- for (i = FSP_EXTENT_SIZE - 1; i > hint; i--) {
- if (val == xdes_mtr_get_bit(descr, bit, i, mtr)) {
-
- return(i);
- }
- }
-
- return(ULINT_UNDEFINED);
-}
-
-/**********************************************************************//**
Returns the number of used pages in a descriptor.
@return number of pages used */
UNIV_INLINE
diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc
index 37e742bf938..5adda1fad6c 100644
--- a/storage/xtradb/fts/fts0fts.cc
+++ b/storage/xtradb/fts/fts0fts.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -81,11 +81,13 @@ ulint n_nodes = 0;
/** Error condition reported by fts_utf8_decode() */
const ulint UTF8_ERROR = 0xFFFFFFFF;
+#ifdef FTS_CACHE_SIZE_DEBUG
/** The cache size permissible lower limit (1K) */
static const ulint FTS_CACHE_SIZE_LOWER_LIMIT_IN_MB = 1;
/** The cache size permissible upper limit (1G) */
static const ulint FTS_CACHE_SIZE_UPPER_LIMIT_IN_MB = 1024;
+#endif /* FTS_CACHE_SIZE_DEBUG */
/** Time to sleep after DEADLOCK error before retrying operation. */
static const ulint FTS_DEADLOCK_RETRY_WAIT = 100000;
@@ -191,7 +193,7 @@ static const char* fts_create_common_tables_sql = {
""
"CREATE TABLE \"%s_CONFIG\" (\n"
" key CHAR(50),\n"
- " value CHAR(50) NOT NULL\n"
+ " value CHAR(200) NOT NULL\n"
") COMPACT;\n"
"CREATE UNIQUE CLUSTERED INDEX IND ON \"%s_CONFIG\"(key);\n"
};
@@ -329,27 +331,6 @@ fts_update_sync_doc_id(
doc_id_t doc_id, /*!< in: last document id */
trx_t* trx) /*!< in: update trx, or NULL */
__attribute__((nonnull(1)));
-/********************************************************************
-Check if we should stop. */
-UNIV_INLINE
-ibool
-fts_is_stop_signalled(
-/*==================*/
- fts_t* fts) /*!< in: fts instance */
-{
- ibool stop_signalled = FALSE;
-
- mutex_enter(&fts->bg_threads_mutex);
-
- if (fts->fts_status & BG_THREAD_STOP) {
-
- stop_signalled = TRUE;
- }
-
- mutex_exit(&fts->bg_threads_mutex);
-
- return(stop_signalled);
-}
/****************************************************************//**
This function loads the default InnoDB stopword list */
@@ -1971,7 +1952,7 @@ fts_create_one_index_table(
flags2 = DICT_TF2_USE_TABLESPACE;
}
- new_table = dict_mem_table_create(table_name, 0, 5, 1, flags2, false);
+ new_table = dict_mem_table_create(table_name, 0, 5, 1, flags2);
field = dict_index_get_nth_field(index, 0);
charset = innobase_get_fts_charset(
@@ -3409,7 +3390,7 @@ fts_fetch_doc_from_rec(
doc->charset = get_doc->index_cache->charset;
/* Null Field */
- if (doc->text.f_len == UNIV_SQL_NULL) {
+ if (doc->text.f_len == UNIV_SQL_NULL || doc->text.f_len == 0) {
continue;
}
@@ -5545,7 +5526,7 @@ fts_savepoint_lookup(
/*********************************************************************//**
Release the savepoint data identified by name. All savepoints created
-after the named savepoint are also released.
+after the named savepoint are kept.
@return DB_SUCCESS or error code */
UNIV_INTERN
void
@@ -5554,81 +5535,37 @@ fts_savepoint_release(
trx_t* trx, /*!< in: transaction */
const char* name) /*!< in: savepoint name */
{
- ulint i;
- ib_vector_t* savepoints;
- ulint top_of_stack = 0;
-
ut_a(name != NULL);
- savepoints = trx->fts_trx->savepoints;
+ ib_vector_t* savepoints = trx->fts_trx->savepoints;
ut_a(ib_vector_size(savepoints) > 0);
- /* Skip the implied savepoint (first element). */
- for (i = 1; i < ib_vector_size(savepoints); ++i) {
- fts_savepoint_t* savepoint;
+ ulint i = fts_savepoint_lookup(savepoints, name);
+ if (i != ULINT_UNDEFINED) {
+ ut_a(i >= 1);
+ fts_savepoint_t* savepoint;
savepoint = static_cast<fts_savepoint_t*>(
ib_vector_get(savepoints, i));
- /* Even though we release the resources that are part
- of the savepoint, we don't (always) actually delete the
- entry. We simply set the savepoint name to NULL. Therefore
- we have to skip deleted/released entries. */
- if (savepoint->name != NULL
- && strcmp(name, savepoint->name) == 0) {
- break;
+ if (i == ib_vector_size(savepoints) - 1) {
+ /* If the savepoint is the last, we save its
+ tables to the previous savepoint. */
+ fts_savepoint_t* prev_savepoint;
+ prev_savepoint = static_cast<fts_savepoint_t*>(
+ ib_vector_get(savepoints, i - 1));
- /* Track the previous savepoint instance that will
- be at the top of the stack after the release. */
- } else if (savepoint->name != NULL) {
- /* We need to delete all entries
- greater than this element. */
- top_of_stack = i;
+ ib_rbt_t* tables = savepoint->tables;
+ savepoint->tables = prev_savepoint->tables;
+ prev_savepoint->tables = tables;
}
- }
-
- /* Only if we found and element to release. */
- if (i < ib_vector_size(savepoints)) {
- fts_savepoint_t* last_savepoint;
- fts_savepoint_t* top_savepoint;
- ib_rbt_t* tables;
-
- ut_a(top_of_stack < ib_vector_size(savepoints));
- /* Exchange tables between last savepoint and top savepoint */
- last_savepoint = static_cast<fts_savepoint_t*>(
- ib_vector_last(trx->fts_trx->savepoints));
- top_savepoint = static_cast<fts_savepoint_t*>(
- ib_vector_get(savepoints, top_of_stack));
- tables = top_savepoint->tables;
- top_savepoint->tables = last_savepoint->tables;
- last_savepoint->tables = tables;
-
- /* Skip the implied savepoint. */
- for (i = ib_vector_size(savepoints) - 1;
- i > top_of_stack;
- --i) {
-
- fts_savepoint_t* savepoint;
-
- savepoint = static_cast<fts_savepoint_t*>(
- ib_vector_get(savepoints, i));
-
- /* Skip savepoints that were released earlier. */
- if (savepoint->name != NULL) {
- savepoint->name = NULL;
- fts_savepoint_free(savepoint);
- }
-
- ib_vector_pop(savepoints);
- }
+ fts_savepoint_free(savepoint);
+ ib_vector_remove(savepoints, *(void**)savepoint);
/* Make sure we don't delete the implied savepoint. */
ut_a(ib_vector_size(savepoints) > 0);
-
- /* This must hold. */
- ut_a(ib_vector_size(savepoints) == (top_of_stack + 1));
}
}
@@ -6330,7 +6267,7 @@ fts_fake_hex_to_dec(
{
ib_id_t dec_id = 0;
char tmp_id[FTS_AUX_MIN_TABLE_ID_LENGTH];
- int ret;
+ int ret __attribute__((unused));
ret = sprintf(tmp_id, UINT64PFx, id);
ut_ad(ret == 16);
diff --git a/storage/xtradb/fts/fts0opt.cc b/storage/xtradb/fts/fts0opt.cc
index 5891b53a6e2..e096b8bf6d6 100644
--- a/storage/xtradb/fts/fts0opt.cc
+++ b/storage/xtradb/fts/fts0opt.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2007, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -42,9 +42,6 @@ Completed 2011/7/10 Sunny and Jimmy Yang
/** The FTS optimize thread's work queue. */
static ib_wqueue_t* fts_optimize_wq;
-/** The number of document ids to delete in one statement. */
-static const ulint FTS_MAX_DELETE_DOC_IDS = 1000;
-
/** Time to wait for a message. */
static const ulint FTS_QUEUE_WAIT_IN_USECS = 5000000;
@@ -1154,6 +1151,7 @@ fts_optimize_encode_node(
}
/* Calculate the space required to store the ilist. */
+ ut_ad(doc_id > node->last_doc_id);
doc_id_delta = doc_id - node->last_doc_id;
enc_len = fts_get_encoded_len(static_cast<ulint>(doc_id_delta));
@@ -1396,7 +1394,8 @@ fts_optimize_word(
src_node = (fts_node_t*) ib_vector_get(word->nodes, i);
- if (!dst_node) {
+ if (dst_node == NULL
+ || dst_node->last_doc_id > src_node->first_doc_id) {
dst_node = static_cast<fts_node_t*>(
ib_vector_push(nodes, NULL));
diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc
index 9d8e7aec9ab..66060439215 100644
--- a/storage/xtradb/fts/fts0que.cc
+++ b/storage/xtradb/fts/fts0que.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -57,9 +57,6 @@ Completed 2011/7/10 Sunny and Jimmy Yang
/*Initial byte length for 'words' in fts_ranking_t */
#define RANKING_WORDS_INIT_LEN 4
-/* Coeffecient to use for normalize relevance ranking. */
-static const double FTS_NORMALIZE_COEFF = 0.0115F;
-
// FIXME: Need to have a generic iterator that traverses the ilist.
typedef std::vector<fts_string_t> word_vector_t;
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index df883fb25e0..8ec276dcbc3 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2000, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2012, Facebook Inc.
@@ -3356,19 +3356,6 @@ trx_is_strict(
return(trx && trx->mysql_thd && THDVAR(trx->mysql_thd, strict_mode));
}
-/**********************************************************************//**
-Determines if the current MySQL thread is running in strict mode.
-If thd==NULL, THDVAR returns the global value of innodb-strict-mode.
-@return TRUE if strict */
-UNIV_INLINE
-ibool
-thd_is_strict(
-/*==========*/
- THD* thd) /*!< in: MySQL thread descriptor */
-{
- return(THDVAR(thd, strict_mode));
-}
-
/**************************************************************//**
Resets some fields of a prebuilt struct. The template is used in fast
retrieval of just those column values MySQL needs in its processing. */
@@ -8695,7 +8682,8 @@ calc_row_difference(
}
}
}
- innodb_idx++;
+ if (field->stored_in_db)
+ innodb_idx++;
}
/* If the update changes a column with an FTS index on it, we
@@ -9722,6 +9710,11 @@ ha_innobase::general_fetch(
DBUG_ENTER("general_fetch");
+ /* If transaction is not startted do not continue, instead return a error code. */
+ if(!(prebuilt->sql_stat_start || (prebuilt->trx && prebuilt->trx->state == 1))) {
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
+
if (UNIV_UNLIKELY(srv_pass_corrupt_table <= 1 && share
&& share->ib_table && share->ib_table->is_corrupt)) {
DBUG_RETURN(HA_ERR_CRASHED);
@@ -10889,18 +10882,18 @@ create_table_def(
/* Adjust for the FTS hidden field */
if (!has_doc_id_col) {
table = dict_mem_table_create(table_name, 0, s_cols + 1,
- flags, flags2, false);
+ flags, flags2);
/* Set the hidden doc_id column. */
table->fts->doc_col = s_cols;
} else {
table = dict_mem_table_create(table_name, 0, s_cols,
- flags, flags2, false);
+ flags, flags2);
table->fts->doc_col = doc_id_col;
}
} else {
table = dict_mem_table_create(table_name, 0, s_cols,
- flags, flags2, false);
+ flags, flags2);
}
if (flags2 & DICT_TF2_TEMPORARY) {
@@ -12001,7 +11994,7 @@ ha_innobase::create(
DBUG_ASSERT(thd != NULL);
DBUG_ASSERT(create_info != NULL);
- if (form->s->fields > REC_MAX_N_USER_FIELDS) {
+ if (form->s->stored_fields > REC_MAX_N_USER_FIELDS) {
DBUG_RETURN(HA_ERR_TOO_MANY_FIELDS);
} else if (srv_read_only_mode) {
DBUG_RETURN(HA_ERR_TABLE_READONLY);
@@ -13496,18 +13489,6 @@ ha_innobase::info_low(
prebuilt->trx->op_info =
"returning various info to MySQL";
}
-
- my_snprintf(path, sizeof(path), "%s/%s%s",
- mysql_data_home, ib_table->name, reg_ext);
-
- unpack_filename(path,path);
-
- /* Note that we do not know the access time of the table,
- nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
-
- if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) {
- stats.create_time = (ulong) stat_info.ctime;
- }
}
if (flag & HA_STATUS_VARIABLE) {
@@ -13793,6 +13774,20 @@ ha_innobase::info_low(
if (!(flag & HA_STATUS_NO_LOCK)) {
dict_table_stats_unlock(ib_table, RW_S_LATCH);
}
+
+ my_snprintf(path, sizeof(path), "%s/%s%s",
+ mysql_data_home,
+ table->s->normalized_path.str,
+ reg_ext);
+
+ unpack_filename(path,path);
+
+ /* Note that we do not know the access time of the table,
+ nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
+
+ if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) {
+ stats.create_time = (ulong) stat_info.ctime;
+ }
}
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index 4b09820d400..f791a4dcd2e 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -2841,7 +2841,7 @@ prepare_inplace_alter_table_dict(
/* The initial space id 0 may be overridden later. */
ctx->new_table = dict_mem_table_create(
- new_table_name, 0, n_cols, flags, flags2, false);
+ new_table_name, 0, n_cols, flags, flags2);
/* The rebuilt indexed_table will use the renamed
column names. */
ctx->col_names = NULL;
diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc
index d0561efb8ad..e124cb98f99 100644
--- a/storage/xtradb/handler/i_s.cc
+++ b/storage/xtradb/handler/i_s.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2007, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyrigth (c) 2014, 2015, MariaDB Corporation
This program is free software; you can redistribute it and/or modify it under
@@ -3233,8 +3233,6 @@ i_s_fts_index_cache_fill_one_index(
for (rbt_node = rbt_first(index_cache->words);
rbt_node;
rbt_node = rbt_next(index_cache->words, rbt_node)) {
- doc_id_t doc_id = 0;
-
fts_tokenizer_word_t* word;
word = rbt_value(fts_tokenizer_word_t, rbt_node);
@@ -3260,6 +3258,7 @@ i_s_fts_index_cache_fill_one_index(
fts_node_t* node;
byte* ptr;
ulint decoded = 0;
+ doc_id_t doc_id = 0;
node = static_cast<fts_node_t*> (ib_vector_get(
word->nodes, i));
@@ -3931,10 +3930,14 @@ i_s_fts_config_fill(
if (!user_table) {
DBUG_RETURN(0);
+ } else if (!dict_table_has_fts_index(user_table)) {
+ dict_table_close(user_table, FALSE, FALSE);
+
+ DBUG_RETURN(0);
}
trx = trx_allocate_for_background();
- trx->op_info = "Select for FTS DELETE TABLE";
+ trx->op_info = "Select for FTS CONFIG TABLE";
FTS_INIT_FTS_TABLE(&fts_table, "CONFIG", FTS_COMMON_TABLE, user_table);
diff --git a/storage/xtradb/ibuf/ibuf0ibuf.cc b/storage/xtradb/ibuf/ibuf0ibuf.cc
index 068a9fc9334..972208c51bd 100644
--- a/storage/xtradb/ibuf/ibuf0ibuf.cc
+++ b/storage/xtradb/ibuf/ibuf0ibuf.cc
@@ -611,8 +611,7 @@ ibuf_init_at_db_start(void)
heap = mem_heap_create(450);
/* Use old-style record format for the insert buffer. */
- table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0, 0,
- false);
+ table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0, 0);
dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0);
@@ -1573,7 +1572,7 @@ ibuf_dummy_index_create(
table = dict_mem_table_create("IBUF_DUMMY",
DICT_HDR_SPACE, n,
- comp ? DICT_TF_COMPACT : 0, 0, true);
+ comp ? DICT_TF_COMPACT : 0, 0);
index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY",
DICT_HDR_SPACE, 0, n);
diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h
index deea392f9fd..d5cd8c595c2 100644
--- a/storage/xtradb/include/dict0mem.h
+++ b/storage/xtradb/include/dict0mem.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
@@ -348,10 +348,7 @@ dict_mem_table_create(
of the table is placed */
ulint n_cols, /*!< in: number of columns */
ulint flags, /*!< in: table flags */
- ulint flags2, /*!< in: table flags2 */
- bool nonshared);/*!< in: whether the table object is a dummy
- one that does not need the initialization of
- locking-related fields. */
+ ulint flags2); /*!< in: table flags2 */
/**********************************************************************//**
Determines if a table belongs to a system database
@return true if table belong to a system database */
@@ -646,11 +643,12 @@ extern ulong zip_failure_threshold_pct;
compression failures */
extern ulong zip_pad_max;
-/** Data structure to hold information about about how much space in
+/** Data structure to hold information about how much space in
an uncompressed page should be left as padding to avoid compression
failures. This estimate is based on a self-adapting heuristic. */
struct zip_pad_info_t {
- os_fast_mutex_t mutex; /*!< mutex protecting the info */
+ os_fast_mutex_t*
+ mutex; /*!< mutex protecting the info */
ulint pad; /*!< number of bytes used as pad */
ulint success;/*!< successful compression ops during
current round */
@@ -658,6 +656,9 @@ struct zip_pad_info_t {
current round */
ulint n_rounds;/*!< number of currently successful
rounds */
+ volatile os_once::state_t
+ mutex_created;
+ /*!< Creation state of mutex member */
};
/** Number of samples of data size kept when page compression fails for
@@ -1157,8 +1158,7 @@ struct dict_table_t{
dict_table_t::indexes*::stat_index_size
dict_table_t::indexes*::stat_n_leaf_pages
(*) those are not always protected for
- performance reasons. NULL for dumy table
- objects. */
+ performance reasons. */
unsigned stat_initialized:1; /*!< TRUE if statistics have
been calculated the first time
after database startup or table creation */
@@ -1292,12 +1292,15 @@ struct dict_table_t{
and release it without a need to allocate
space from the lock heap of the trx:
otherwise the lock heap would grow rapidly
- if we do a large insert from a select. NULL
- for dummy table objects. */
- ib_mutex_t autoinc_mutex;
+ if we do a large insert from a select */
+ ib_mutex_t* autoinc_mutex;
/*!< mutex protecting the autoincrement
- counter. Not initialized for dummy table
- objects */
+ counter */
+
+ /** Creation state of autoinc_mutex member */
+ volatile os_once::state_t
+ autoinc_mutex_created;
+
ib_uint64_t autoinc;/*!< autoinc counter value to give to the
next inserted row */
ulong n_waiting_or_granted_auto_inc_locks;
@@ -1361,6 +1364,111 @@ struct dict_foreign_add_to_referenced_table {
}
};
+/** Destroy the autoinc latch of the given table.
+This function is only called from either single threaded environment
+or from a thread that has not shared the table object with other threads.
+@param[in,out] table table whose stats latch to destroy */
+inline
+void
+dict_table_autoinc_destroy(
+ dict_table_t* table)
+{
+ if (table->autoinc_mutex_created == os_once::DONE
+ && table->autoinc_mutex != NULL) {
+ mutex_free(table->autoinc_mutex);
+ delete table->autoinc_mutex;
+ }
+}
+
+/** Allocate and init the autoinc latch of a given table.
+This function must not be called concurrently on the same table object.
+@param[in,out] table_void table whose autoinc latch to create */
+void
+dict_table_autoinc_alloc(
+ void* table_void);
+
+/** Allocate and init the zip_pad_mutex of a given index.
+This function must not be called concurrently on the same index object.
+@param[in,out] index_void index whose zip_pad_mutex to create */
+void
+dict_index_zip_pad_alloc(
+ void* index_void);
+
+/** Request for lazy creation of the autoinc latch of a given table.
+This function is only called from either single threaded environment
+or from a thread that has not shared the table object with other threads.
+@param[in,out] table table whose autoinc latch is to be created. */
+inline
+void
+dict_table_autoinc_create_lazy(
+ dict_table_t* table)
+{
+#ifdef HAVE_ATOMIC_BUILTINS
+ table->autoinc_mutex = NULL;
+ table->autoinc_mutex_created = os_once::NEVER_DONE;
+#else /* HAVE_ATOMIC_BUILTINS */
+ dict_table_autoinc_alloc(table);
+ table->autoinc_mutex_created = os_once::DONE;
+#endif /* HAVE_ATOMIC_BUILTINS */
+}
+
+/** Request a lazy creation of dict_index_t::zip_pad::mutex.
+This function is only called from either single threaded environment
+or from a thread that has not shared the table object with other threads.
+@param[in,out] index index whose zip_pad mutex is to be created */
+inline
+void
+dict_index_zip_pad_mutex_create_lazy(
+ dict_index_t* index)
+{
+#ifdef HAVE_ATOMIC_BUILTINS
+ index->zip_pad.mutex = NULL;
+ index->zip_pad.mutex_created = os_once::NEVER_DONE;
+#else /* HAVE_ATOMIC_BUILTINS */
+ dict_index_zip_pad_alloc(index);
+ index->zip_pad.mutex_created = os_once::DONE;
+#endif /* HAVE_ATOMIC_BUILTINS */
+}
+
+/** Destroy the zip_pad_mutex of the given index.
+This function is only called from either single threaded environment
+or from a thread that has not shared the table object with other threads.
+@param[in,out] table table whose stats latch to destroy */
+inline
+void
+dict_index_zip_pad_mutex_destroy(
+ dict_index_t* index)
+{
+ if (index->zip_pad.mutex_created == os_once::DONE
+ && index->zip_pad.mutex != NULL) {
+ os_fast_mutex_free(index->zip_pad.mutex);
+ delete index->zip_pad.mutex;
+ }
+}
+
+/** Release the zip_pad_mutex of a given index.
+@param[in,out] index index whose zip_pad_mutex is to be released */
+inline
+void
+dict_index_zip_pad_unlock(
+ dict_index_t* index)
+{
+ os_fast_mutex_unlock(index->zip_pad.mutex);
+}
+
+#ifdef UNIV_DEBUG
+/** Check if the current thread owns the autoinc_mutex of a given table.
+@param[in] table the autoinc_mutex belongs to this table
+@return true, if the current thread owns the autoinc_mutex, false otherwise.*/
+inline
+bool
+dict_table_autoinc_own(
+ const dict_table_t* table)
+{
+ return(mutex_own(table->autoinc_mutex));
+}
+#endif /* UNIV_DEBUG */
+
#ifndef UNIV_NONINL
#include "dict0mem.ic"
#endif
diff --git a/storage/xtradb/include/os0sync.h b/storage/xtradb/include/os0sync.h
index bd37287f1a0..3a7707ee130 100644
--- a/storage/xtradb/include/os0sync.h
+++ b/storage/xtradb/include/os0sync.h
@@ -452,7 +452,7 @@ Returns the old value of *ptr, atomically sets *ptr to new_val */
# define os_atomic_test_and_set_ulint(ptr, new_val) \
__sync_lock_test_and_set(ptr, new_val)
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__aarch64__)
/*
os_atomic_test_and_set_byte_release() should imply a release barrier before
setting, and a full barrier after. But __sync_lock_test_and_set() is only
diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i
index 11f9d7876f4..241f210869f 100644
--- a/storage/xtradb/include/univ.i
+++ b/storage/xtradb/include/univ.i
@@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 6
-#define INNODB_VERSION_BUGFIX 23
+#define INNODB_VERSION_BUGFIX 24
#ifndef PERCONA_INNODB_VERSION
-#define PERCONA_INNODB_VERSION 72.1
+#define PERCONA_INNODB_VERSION 72.2
#endif
/* Enable UNIV_LOG_ARCHIVE in XtraDB */
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index 59168fb741b..d46214dccb6 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2015, MariaDB Corporation
This program is free software; you can redistribute it and/or modify it under
@@ -387,8 +387,10 @@ because there is no parallel deadlock check. This stack is protected by
the lock_sys_t::mutex. */
static lock_stack_t* lock_stack;
+#ifdef UNIV_DEBUG
/** The count of the types of locks. */
static const ulint lock_types = UT_ARR_SIZE(lock_compatibility_matrix);
+#endif /* UNIV_DEBUG */
#ifdef UNIV_PFS_MUTEX
/* Key to register mutex with performance schema */
diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc
index 72efe771302..93ed384c0c7 100644
--- a/storage/xtradb/log/log0recv.cc
+++ b/storage/xtradb/log/log0recv.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
@@ -1951,7 +1951,7 @@ loop:
goto loop;
}
- ut_ad(!allow_ibuf == mutex_own(&log_sys->mutex));
+ ut_ad((!allow_ibuf) == mutex_own(&log_sys->mutex));
if (!allow_ibuf) {
recv_no_ibuf_operations = TRUE;
diff --git a/storage/xtradb/mtr/mtr0log.cc b/storage/xtradb/mtr/mtr0log.cc
index db39ebeafa4..82df1df63d4 100644
--- a/storage/xtradb/mtr/mtr0log.cc
+++ b/storage/xtradb/mtr/mtr0log.cc
@@ -571,7 +571,7 @@ mlog_parse_index(
n = n_uniq = 1;
}
table = dict_mem_table_create("LOG_DUMMY", DICT_HDR_SPACE, n,
- comp ? DICT_TF_COMPACT : 0, 0, true);
+ comp ? DICT_TF_COMPACT : 0, 0);
ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY",
DICT_HDR_SPACE, 0, n);
ind->table = table;
diff --git a/storage/xtradb/os/os0sync.cc b/storage/xtradb/os/os0sync.cc
index 451ba5285e3..03c53848832 100644
--- a/storage/xtradb/os/os0sync.cc
+++ b/storage/xtradb/os/os0sync.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -234,24 +234,6 @@ os_cond_broadcast(
}
/*********************************************************//**
-Wakes one thread waiting for condition variable */
-UNIV_INLINE
-void
-os_cond_signal(
-/*==========*/
- os_cond_t* cond) /*!< in: condition variable. */
-{
- ut_a(cond);
-
-#ifdef __WIN__
- ut_a(wake_condition_variable != NULL);
- wake_condition_variable(cond);
-#else
- ut_a(pthread_cond_signal(cond) == 0);
-#endif
-}
-
-/*********************************************************//**
Destroys condition variable */
UNIV_INLINE
void
diff --git a/storage/xtradb/page/page0zip.cc b/storage/xtradb/page/page0zip.cc
index 86c33ab5efb..58559cc438b 100644
--- a/storage/xtradb/page/page0zip.cc
+++ b/storage/xtradb/page/page0zip.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2005, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2014, SkySQL Ab. All Rights Reserved.
@@ -1601,7 +1601,7 @@ page_zip_fields_free(
{
if (index) {
dict_table_t* table = index->table;
- os_fast_mutex_free(&index->zip_pad.mutex);
+ dict_index_zip_pad_mutex_destroy(index);
mem_heap_free(index->heap);
dict_mem_table_free(table);
@@ -1652,7 +1652,7 @@ page_zip_fields_decode(
}
table = dict_mem_table_create("ZIP_DUMMY", DICT_HDR_SPACE, n,
- DICT_TF_COMPACT, 0, true);
+ DICT_TF_COMPACT, 0);
index = dict_mem_index_create("ZIP_DUMMY", "ZIP_DUMMY",
DICT_HDR_SPACE, 0, n);
index->table = table;
diff --git a/storage/xtradb/pars/pars0pars.cc b/storage/xtradb/pars/pars0pars.cc
index 18feb9407c7..c87e1f8e247 100644
--- a/storage/xtradb/pars/pars0pars.cc
+++ b/storage/xtradb/pars/pars0pars.cc
@@ -1998,7 +1998,7 @@ pars_create_table(
n_cols = que_node_list_get_len(column_defs);
table = dict_mem_table_create(
- table_sym->name, 0, n_cols, flags, flags2, false);
+ table_sym->name, 0, n_cols, flags, flags2);
#ifdef UNIV_DEBUG
if (not_fit_in_memory != NULL) {
diff --git a/storage/xtradb/que/que0que.cc b/storage/xtradb/que/que0que.cc
index 8d9b8fac776..e2dc0239e13 100644
--- a/storage/xtradb/que/que0que.cc
+++ b/storage/xtradb/que/que0que.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -390,32 +390,6 @@ que_fork_start_command(
return(thr);
}
-/****************************************************************//**
-Tests if all the query threads in the same fork have a given state.
-@return TRUE if all the query threads in the same fork were in the
-given state */
-UNIV_INLINE
-ibool
-que_fork_all_thrs_in_state(
-/*=======================*/
- que_fork_t* fork, /*!< in: query fork */
- ulint state) /*!< in: state */
-{
- que_thr_t* thr_node;
-
- for (thr_node = UT_LIST_GET_FIRST(fork->thrs);
- thr_node != NULL;
- thr_node = UT_LIST_GET_NEXT(thrs, thr_node)) {
-
- if (thr_node->state != state) {
-
- return(FALSE);
- }
- }
-
- return(TRUE);
-}
-
/**********************************************************************//**
Calls que_graph_free_recursive for statements in a statement list. */
static
diff --git a/storage/xtradb/row/row0log.cc b/storage/xtradb/row/row0log.cc
index ac0e75929a4..9d403e64fd0 100644
--- a/storage/xtradb/row/row0log.cc
+++ b/storage/xtradb/row/row0log.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1390,6 +1390,27 @@ blob_done:
dfield_set_data(dfield, data, len);
}
+ if (len != UNIV_SQL_NULL && col->mtype == DATA_MYSQL
+ && col->len != len && !dict_table_is_comp(log->table)) {
+
+ ut_ad(col->len >= len);
+ if (dict_table_is_comp(index->table)) {
+ byte* buf = (byte*) mem_heap_alloc(heap,
+ col->len);
+ memcpy(buf, dfield->data, len);
+ memset(buf + len, 0x20, col->len - len);
+
+ dfield_set_data(dfield, buf, col->len);
+ } else {
+ /* field length mismatch should not happen
+ when rebuilding the redundant row format
+ table. */
+ ut_ad(0);
+ *error = DB_CORRUPTION;
+ return(NULL);
+ }
+ }
+
/* See if any columns were changed to NULL or NOT NULL. */
const dict_col_t* new_col
= dict_table_get_nth_col(log->table, col_no);
diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc
index bdcbd00ac80..2df9c2bea82 100644
--- a/storage/xtradb/row/row0merge.cc
+++ b/storage/xtradb/row/row0merge.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2005, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -244,22 +244,88 @@ row_merge_buf_free(
mem_heap_free(buf->heap);
}
-/******************************************************//**
-Insert a data tuple into a sort buffer.
-@return number of rows added, 0 if out of space */
+/** Convert the field data from compact to redundant format.
+@param[in] row_field field to copy from
+@param[out] field field to copy to
+@param[in] len length of the field data
+@param[in] zip_size compressed BLOB page size,
+ zero for uncompressed BLOBs
+@param[in,out] heap memory heap where to allocate data when
+ converting to ROW_FORMAT=REDUNDANT, or NULL
+ when not to invoke
+ row_merge_buf_redundant_convert(). */
+static
+void
+row_merge_buf_redundant_convert(
+ const dfield_t* row_field,
+ dfield_t* field,
+ ulint len,
+ ulint zip_size,
+ mem_heap_t* heap,
+ trx_t* trx)
+{
+ ut_ad(DATA_MBMINLEN(field->type.mbminmaxlen) == 1);
+ ut_ad(DATA_MBMAXLEN(field->type.mbminmaxlen) > 1);
+
+ byte* buf = (byte*) mem_heap_alloc(heap, len);
+ ulint field_len = row_field->len;
+ ut_ad(field_len <= len);
+
+ if (row_field->ext) {
+ const byte* field_data = static_cast<byte*>(
+ dfield_get_data(row_field));
+ ulint ext_len;
+
+ ut_a(field_len >= BTR_EXTERN_FIELD_REF_SIZE);
+ ut_a(memcmp(field_data + field_len - BTR_EXTERN_FIELD_REF_SIZE,
+ field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE));
+
+ byte* data = btr_copy_externally_stored_field(
+ &ext_len, field_data, zip_size, field_len, heap, trx);
+
+ ut_ad(ext_len < len);
+
+ memcpy(buf, data, ext_len);
+ field_len = ext_len;
+ } else {
+ memcpy(buf, row_field->data, field_len);
+ }
+
+ memset(buf + field_len, 0x20, len - field_len);
+
+ dfield_set_data(field, buf, len);
+}
+
+/** Insert a data tuple into a sort buffer.
+@param[in,out] buf sort buffer
+@param[in] fts_index fts index to be created
+@param[in] old_table original table
+@param[in,out] psort_info parallel sort info
+@param[in] row table row
+@param[in] ext cache of externally stored
+ column prefixes, or NULL
+@param[in,out] doc_id Doc ID if we are creating
+ FTS index
+@param[in,out] conv_heap memory heap where to allocate data when
+ converting to ROW_FORMAT=REDUNDANT, or NULL
+ when not to invoke
+ row_merge_buf_redundant_convert()
+@param[in,out] exceed_page set if the record size exceeds the page size
+ when converting to ROW_FORMAT=REDUNDANT
+@return number of rows added, 0 if out of space */
static
ulint
row_merge_buf_add(
-/*==============*/
- row_merge_buf_t* buf, /*!< in/out: sort buffer */
- dict_index_t* fts_index,/*!< in: fts index to be created */
- const dict_table_t* old_table,/*!< in: original table */
- fts_psort_t* psort_info, /*!< in: parallel sort info */
- const dtuple_t* row, /*!< in: table row */
- const row_ext_t* ext, /*!< in: cache of externally stored
- column prefixes, or NULL */
- doc_id_t* doc_id) /*!< in/out: Doc ID if we are
- creating FTS index */
+ row_merge_buf_t* buf,
+ dict_index_t* fts_index,
+ const dict_table_t* old_table,
+ fts_psort_t* psort_info,
+ const dtuple_t* row,
+ const row_ext_t* ext,
+ doc_id_t* doc_id,
+ mem_heap_t* conv_heap,
+ bool* exceed_page,
+ trx_t* trx)
{
ulint i;
const dict_index_t* index;
@@ -409,6 +475,23 @@ row_merge_buf_add(
n_row_added = 1;
continue;
}
+
+ if (field->len != UNIV_SQL_NULL
+ && col->mtype == DATA_MYSQL
+ && col->len != field->len) {
+
+ if (conv_heap != NULL) {
+ row_merge_buf_redundant_convert(
+ row_field, field, col->len,
+ dict_table_zip_size(old_table),
+ conv_heap, trx);
+ } else {
+ /* Field length mismatch should not
+ happen when rebuilding redundant row
+ format table. */
+ ut_ad(dict_table_is_comp(index->table));
+ }
+ }
}
len = dfield_get_len(field);
@@ -517,6 +600,14 @@ row_merge_buf_add(
of extra_size. */
data_size += (extra_size + 1) + ((extra_size + 1) >= 0x80);
+ /* Record size can exceed page size while converting to
+ redundant row format. But there is assert
+ ut_ad(size < UNIV_PAGE_SIZE) in rec_offs_data_size().
+ It may hit the assert before attempting to insert the row. */
+ if (conv_heap != NULL && data_size > UNIV_PAGE_SIZE) {
+ *exceed_page = true;
+ }
+
ut_ad(data_size < srv_sort_buf_size);
/* Reserve one byte for the end marker of row_merge_block_t. */
@@ -536,6 +627,10 @@ row_merge_buf_add(
dfield_dup(field++, buf->heap);
} while (--n_fields);
+ if (conv_heap != NULL) {
+ mem_heap_empty(conv_heap);
+ }
+
DBUG_RETURN(n_row_added);
}
@@ -1219,6 +1314,7 @@ row_merge_read_clustered_index(
os_event_t fts_parallel_sort_event = NULL;
ibool fts_pll_sort = FALSE;
ib_int64_t sig_count = 0;
+ mem_heap_t* conv_heap = NULL;
float curr_progress;
ib_int64_t read_rows = 0;
@@ -1324,6 +1420,11 @@ row_merge_read_clustered_index(
row_heap = mem_heap_create(sizeof(mrec_buf_t));
+ if (dict_table_is_comp(old_table)
+ && !dict_table_is_comp(new_table)) {
+ conv_heap = mem_heap_create(sizeof(mrec_buf_t));
+ }
+
/* Scan the clustered index. */
for (;;) {
const rec_t* rec;
@@ -1608,16 +1709,24 @@ write_buffers:
row_merge_buf_t* buf = merge_buf[i];
merge_file_t* file = &files[i];
ulint rows_added = 0;
+ bool exceed_page = false;
if (UNIV_LIKELY
(row && (rows_added = row_merge_buf_add(
buf, fts_index, old_table,
- psort_info, row, ext, &doc_id)))) {
+ psort_info, row, ext, &doc_id,
+ conv_heap, &exceed_page, trx)))) {
/* If we are creating FTS index,
a single row can generate more
records for tokenized word */
file->n_rec += rows_added;
+
+ if (exceed_page) {
+ err = DB_TOO_BIG_RECORD;
+ break;
+ }
+
if (doc_id > max_doc_id) {
max_doc_id = doc_id;
}
@@ -1718,12 +1827,18 @@ write_buffers:
(!(rows_added = row_merge_buf_add(
buf, fts_index, old_table,
psort_info, row, ext,
- &doc_id)))) {
+ &doc_id, conv_heap,
+ &exceed_page, trx)))) {
/* An empty buffer should have enough
room for at least one record. */
ut_error;
}
+ if (exceed_page) {
+ err = DB_TOO_BIG_RECORD;
+ break;
+ }
+
file->n_rec += rows_added;
}
}
@@ -1759,6 +1874,10 @@ func_exit:
}
all_done:
+ if (conv_heap != NULL) {
+ mem_heap_free(conv_heap);
+ }
+
#ifdef FTS_INTERNAL_DIAG_PRINT
DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Scan Table\n");
#endif
diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc
index d0f1b1d1b89..4fc301111c9 100644
--- a/storage/xtradb/row/row0mysql.cc
+++ b/storage/xtradb/row/row0mysql.cc
@@ -3494,13 +3494,11 @@ row_truncate_table_for_mysql(
goto funct_exit;
}
- if (table->space && !table->dir_path_of_temp_table) {
+ if (table->space && !DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)) {
/* Discard and create the single-table tablespace. */
ulint space = table->space;
ulint flags = fil_space_get_flags(space);
- ut_a(!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY));
-
dict_get_and_save_data_dir_path(table, true);
if (flags != ULINT_UNDEFINED
@@ -4305,8 +4303,9 @@ row_drop_table_for_mysql(
is_temp = DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY);
/* If there is a temp path then the temp flag is set.
- However, during recovery, we might have a temp flag but
- not know the temp path */
+ However, during recovery or reloading the table object
+ after eviction from data dictionary cache, we might
+ have a temp flag but not know the temp path */
ut_a(table->dir_path_of_temp_table == NULL || is_temp);
if (dict_table_is_discarded(table)
|| table->ibd_file_missing) {
@@ -4875,6 +4874,7 @@ row_rename_table_for_mysql(
ibool old_is_tmp, new_is_tmp;
pars_info_t* info = NULL;
int retry;
+ bool aux_fts_rename = false;
ut_a(old_name != NULL);
ut_a(new_name != NULL);
@@ -5161,34 +5161,8 @@ row_rename_table_for_mysql(
if (dict_table_has_fts_index(table)
&& !dict_tables_have_same_db(old_name, new_name)) {
err = fts_rename_aux_tables(table, new_name, trx);
-
- if (err != DB_SUCCESS && (table->space != 0)) {
- char* orig_name = table->name;
- trx_t* trx_bg = trx_allocate_for_background();
-
- /* If the first fts_rename fails, the trx would
- be rolled back and committed, we can't use it any more,
- so we have to start a new background trx here. */
- ut_a(trx_state_eq(trx, TRX_STATE_NOT_STARTED));
- trx_bg->op_info = "Revert the failing rename "
- "for fts aux tables";
- trx_bg->dict_operation_lock_mode = RW_X_LATCH;
- trx_start_for_ddl(trx_bg, TRX_DICT_OP_TABLE);
-
- /* If rename fails and table has its own tablespace,
- we need to call fts_rename_aux_tables again to
- revert the ibd file rename, which is not under the
- control of trx. Also notice the parent table name
- in cache is not changed yet. If the reverting fails,
- the ibd data may be left in the new database, which
- can be fixed only manually. */
- table->name = const_cast<char*>(new_name);
- fts_rename_aux_tables(table, old_name, trx_bg);
- table->name = orig_name;
-
- trx_bg->dict_operation_lock_mode = 0;
- trx_commit_for_mysql(trx_bg);
- trx_free_for_background(trx_bg);
+ if (err != DB_TABLE_NOT_FOUND) {
+ aux_fts_rename = true;
}
}
@@ -5289,6 +5263,37 @@ end:
}
funct_exit:
+ if (aux_fts_rename && err != DB_SUCCESS
+ && table != NULL && (table->space != 0)) {
+
+ char* orig_name = table->name;
+ trx_t* trx_bg = trx_allocate_for_background();
+
+ /* If the first fts_rename fails, the trx would
+ be rolled back and committed, we can't use it any more,
+ so we have to start a new background trx here. */
+ ut_a(trx_state_eq(trx_bg, TRX_STATE_NOT_STARTED));
+ trx_bg->op_info = "Revert the failing rename "
+ "for fts aux tables";
+ trx_bg->dict_operation_lock_mode = RW_X_LATCH;
+ trx_start_for_ddl(trx_bg, TRX_DICT_OP_TABLE);
+
+ /* If rename fails and table has its own tablespace,
+ we need to call fts_rename_aux_tables again to
+ revert the ibd file rename, which is not under the
+ control of trx. Also notice the parent table name
+ in cache is not changed yet. If the reverting fails,
+ the ibd data may be left in the new database, which
+ can be fixed only manually. */
+ table->name = const_cast<char*>(new_name);
+ fts_rename_aux_tables(table, old_name, trx_bg);
+ table->name = orig_name;
+
+ trx_bg->dict_operation_lock_mode = 0;
+ trx_commit_for_mysql(trx_bg);
+ trx_free_for_background(trx_bg);
+ }
+
if (table != NULL) {
dict_table_close(table, dict_locked, FALSE);
}
diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc
index aabe604cad6..f0761759def 100644
--- a/storage/xtradb/srv/srv0start.cc
+++ b/storage/xtradb/srv/srv0start.cc
@@ -3277,9 +3277,9 @@ innobase_shutdown_for_mysql(void)
ibuf_close();
log_shutdown();
- lock_sys_close();
trx_sys_file_format_close();
trx_sys_close();
+ lock_sys_close();
/* We don't create these mutexes in RO mode because we don't create
the temp files that the cover. */
diff --git a/storage/xtradb/sync/sync0sync.cc b/storage/xtradb/sync/sync0sync.cc
index dabf70fd041..14b332a2185 100644
--- a/storage/xtradb/sync/sync0sync.cc
+++ b/storage/xtradb/sync/sync0sync.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc
index 17986c293e9..5d3b86e158f 100644
--- a/storage/xtradb/trx/trx0trx.cc
+++ b/storage/xtradb/trx/trx0trx.cc
@@ -478,11 +478,12 @@ trx_free_prepared(
/*==============*/
trx_t* trx) /*!< in, own: trx object */
{
- ut_ad(mutex_own(&trx_sys->mutex));
-
ut_a(trx_state_eq(trx, TRX_STATE_PREPARED));
ut_a(trx->magic_n == TRX_MAGIC_N);
+ mutex_exit(&trx_sys->mutex);
+ lock_trx_release_locks(trx);
+ mutex_enter(&trx_sys->mutex);
trx_undo_free_prepared(trx);
assert_trx_in_rw_list(trx);