Commit 599d8cc2 authored by Olivier Bertrand's avatar Olivier Bertrand

- MDEV-11366 SIGBUS errors in Connect Storage Engine for ArmHF and MIPS.

  Fix includes launchpad fix plus more to cover writing BIN tables.
  modified:   storage/connect/tabfix.cpp
  modified:   storage/connect/value.cpp
  modified:   storage/connect/value.h

- Typo: Change the name of filamzip to filamgz to prepare future ZIP tables.
  modified:   storage/connect/CMakeLists.txt
  added:      storage/connect/filamgz.cpp
  added:      storage/connect/filamgz.h
  deleted:    storage/connect/filamzip.cpp
  deleted:    storage/connect/filamzip.h
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/reldef.cpp
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabdos.h
  modified:   storage/connect/tabfix.cpp
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabjson.cpp
parent 2d78b25c
...@@ -20,14 +20,14 @@ SET(CONNECT_SOURCES ...@@ -20,14 +20,14 @@ SET(CONNECT_SOURCES
ha_connect.cc connect.cc user_connect.cc mycat.cc ha_connect.cc connect.cc user_connect.cc mycat.cc
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
array.cpp blkfil.cpp colblk.cpp csort.cpp array.cpp blkfil.cpp colblk.cpp csort.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamzip.cpp filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
reldef.cpp tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp reldef.cpp tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp
tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp
tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h
engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamzip.h engmsg.h filamap.h filamdbf.h filamfix.h filamgz.h filamtxt.h
filter.h global.h ha_connect.h inihandl.h json.h jsonudf.h maputil.h msgid.h filter.h global.h ha_connect.h inihandl.h json.h jsonudf.h maputil.h msgid.h
mycat.h myconn.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h mycat.h myconn.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h
resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabjson.h tabmul.h tabmysql.h resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabjson.h tabmul.h tabmysql.h
...@@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h) ...@@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
# Definitions that are shared for all OSes # Definitions that are shared for all OSes
# #
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS) add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT ) add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT )
# #
...@@ -270,9 +270,9 @@ IF(CONNECT_WITH_JDBC) ...@@ -270,9 +270,9 @@ IF(CONNECT_WITH_JDBC)
# Find required libraries and include directories # Find required libraries and include directories
SET (JAVA_SOURCES JdbcInterface.java) SET (JAVA_SOURCES JdbcInterface.java)
add_jar(JdbcInterface ${JAVA_SOURCES}) add_jar(JdbcInterface ${JAVA_SOURCES})
install_jar(JdbcInterface DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) install_jar(JdbcInterface DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
add_definitions(-DJDBC_SUPPORT) add_definitions(-DJDBC_SUPPORT)
ELSE() ELSE()
SET(JDBC_LIBRARY "") SET(JDBC_LIBRARY "")
......
/************** FilAmZip H Declares Source Code File (.H) **************/ /*************** FilAmGz H Declares Source Code File (.H) **************/
/* Name: FILAMZIP.H Version 1.2 */ /* Name: FILAMGZ.H Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2016 */
/* */ /* */
/* This file contains the GZIP access method classes declares. */ /* This file contains the GZIP access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMZIP_H #ifndef __FILAMGZ_H
#define __FILAMZIP_H #define __FILAMGZ_H
#include "zlib.h" #include "zlib.h"
typedef class ZIPFAM *PZIPFAM; typedef class GZFAM *PGZFAM;
typedef class ZBKFAM *PZBKFAM; typedef class ZBKFAM *PZBKFAM;
typedef class ZIXFAM *PZIXFAM; typedef class ZIXFAM *PZIXFAM;
typedef class ZLBFAM *PZLBFAM; typedef class ZLBFAM *PZLBFAM;
...@@ -20,19 +20,19 @@ typedef class ZLBFAM *PZLBFAM; ...@@ -20,19 +20,19 @@ typedef class ZLBFAM *PZLBFAM;
/* variable record length files compressed using the gzip library */ /* variable record length files compressed using the gzip library */
/* functions. File is accessed record by record (row). */ /* functions. File is accessed record by record (row). */
/***********************************************************************/ /***********************************************************************/
class DllExport ZIPFAM : public TXTFAM { class DllExport GZFAM : public TXTFAM {
// friend class DOSCOL; // friend class DOSCOL;
public: public:
// Constructor // Constructor
ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;} GZFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;}
ZIPFAM(PZIPFAM txfp); GZFAM(PGZFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;} virtual AMT GetAmType(void) {return TYPE_AM_GZ;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIPFAM(this);} {return (PTXF)new(g) GZFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
...@@ -57,14 +57,14 @@ class DllExport ZIPFAM : public TXTFAM { ...@@ -57,14 +57,14 @@ class DllExport ZIPFAM : public TXTFAM {
// Members // Members
gzFile Zfile; // Points to GZ file structure gzFile Zfile; // Points to GZ file structure
z_off_t Zpos; // Uncompressed file position z_off_t Zpos; // Uncompressed file position
}; // end of class ZIPFAM }; // end of class GZFAM
/***********************************************************************/ /***********************************************************************/
/* This is the access method class declaration for optimized variable */ /* This is the access method class declaration for optimized variable */
/* record length files compressed using the gzip library functions. */ /* record length files compressed using the gzip library functions. */
/* The File is accessed by block (requires an opt file). */ /* The File is accessed by block (requires an opt file). */
/***********************************************************************/ /***********************************************************************/
class DllExport ZBKFAM : public ZIPFAM { class DllExport ZBKFAM : public GZFAM {
public: public:
// Constructor // Constructor
ZBKFAM(PDOSDEF tdp); ZBKFAM(PDOSDEF tdp);
...@@ -167,4 +167,4 @@ class DllExport ZLBFAM : public BLKFAM { ...@@ -167,4 +167,4 @@ class DllExport ZLBFAM : public BLKFAM {
bool Optimized; // true when opt file is available bool Optimized; // true when opt file is available
}; // end of class ZLBFAM }; // end of class ZLBFAM
#endif // __FILAMZIP_H #endif // __FILAMGZ_H
...@@ -123,7 +123,7 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */ ...@@ -123,7 +123,7 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
TYPE_AM_PRX = 129, /* PROXY access method type no */ TYPE_AM_PRX = 129, /* PROXY access method type no */
TYPE_AM_XTB = 130, /* SYS table access method type */ TYPE_AM_XTB = 130, /* SYS table access method type */
TYPE_AM_BLK = 131, /* BLK access method type no */ TYPE_AM_BLK = 131, /* BLK access method type no */
TYPE_AM_ZIP = 132, /* ZIP access method type no */ TYPE_AM_GZ = 132, /* GZ access method type no */
TYPE_AM_ZLIB = 133, /* ZLIB access method type no */ TYPE_AM_ZLIB = 133, /* ZLIB access method type no */
TYPE_AM_JSON = 134, /* JSON access method type no */ TYPE_AM_JSON = 134, /* JSON access method type no */
TYPE_AM_JSN = 135, /* JSN access method type no */ TYPE_AM_JSN = 135, /* JSN access method type no */
......
/************* RelDef CPP Program Source Code File (.CPP) **************/ /************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: RELDEF */ /* PROGRAM NAME: RELDEF */
/* ------------- */ /* ------------- */
/* Version 1.5 */ /* Version 1.6 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
#if defined(VCT_SUPPORT) #if defined(VCT_SUPPORT)
#include "filamvct.h" #include "filamvct.h"
#endif // VCT_SUPPORT #endif // VCT_SUPPORT
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
#include "filamzip.h" #include "filamgz.h"
#endif // ZIP_SUPPORT #endif // GZ_SUPPORT
#include "tabdos.h" #include "tabdos.h"
#include "valblk.h" #include "valblk.h"
#include "tabmul.h" #include "tabmul.h"
...@@ -665,15 +665,15 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -665,15 +665,15 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
/*********************************************************************/ /*********************************************************************/
if (!((PTDBDOS)tdbp)->GetTxfp()) { if (!((PTDBDOS)tdbp)->GetTxfp()) {
if (cmpr) { if (cmpr) {
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
if (cmpr == 1) if (cmpr == 1)
txfp = new(g) ZIPFAM(defp); txfp = new(g) GZFAM(defp);
else else
txfp = new(g) ZLBFAM(defp); txfp = new(g) ZLBFAM(defp);
#else // !ZIP_SUPPORT #else // !GZ_SUPPORT
strcpy(g->Message, "Compress not supported"); strcpy(g->Message, "Compress not supported");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !GZ_SUPPORT
} else if (rfm == RECFM_VAR) { } else if (rfm == RECFM_VAR) {
if (map) if (map)
txfp = new(g) MAPFAM(defp); txfp = new(g) MAPFAM(defp);
......
/************* TabDos C++ Program Source Code File (.CPP) **************/ /************* TabDos C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABDOS */ /* PROGRAM NAME: TABDOS */
/* ------------- */ /* ------------- */
/* Version 4.9 */ /* Version 4.9.1 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -51,9 +51,9 @@ ...@@ -51,9 +51,9 @@
#include "filamap.h" #include "filamap.h"
#include "filamfix.h" #include "filamfix.h"
#include "filamdbf.h" #include "filamdbf.h"
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
#include "filamzip.h" #include "filamgz.h"
#endif // ZIP_SUPPORT #endif // GZ_SUPPORT
#include "tabdos.h" #include "tabdos.h"
#include "tabfix.h" #include "tabfix.h"
#include "tabmul.h" #include "tabmul.h"
...@@ -350,28 +350,28 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -350,28 +350,28 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
else if (map) else if (map)
txfp = new(g) MPXFAM(this); txfp = new(g) MPXFAM(this);
else if (Compressed) { else if (Compressed) {
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
txfp = new(g) ZIXFAM(this); txfp = new(g) ZIXFAM(this);
#else // !ZIP_SUPPORT #else // !GZ_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !GZ_SUPPORT
} else } else
txfp = new(g) FIXFAM(this); txfp = new(g) FIXFAM(this);
tdbp = new(g) TDBFIX(this, txfp); tdbp = new(g) TDBFIX(this, txfp);
} else { } else {
if (Compressed) { if (Compressed) {
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
if (Compressed == 1) if (Compressed == 1)
txfp = new(g) ZIPFAM(this); txfp = new(g) GZFAM(this);
else else
txfp = new(g) ZLBFAM(this); txfp = new(g) ZLBFAM(this);
#else // !ZIP_SUPPORT #else // !GZ_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !GZ_SUPPORT
} else if (map) } else if (map)
txfp = new(g) MAPFAM(this); txfp = new(g) MAPFAM(this);
else else
...@@ -396,7 +396,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -396,7 +396,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
if (map) { if (map) {
txfp = new(g) MBKFAM(this); txfp = new(g) MBKFAM(this);
} else if (Compressed) { } else if (Compressed) {
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
if (Compressed == 1) if (Compressed == 1)
txfp = new(g) ZBKFAM(this); txfp = new(g) ZBKFAM(this);
else { else {
...@@ -404,7 +404,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -404,7 +404,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
((PZLBFAM)txfp)->SetOptimized(To_Pos != NULL); ((PZLBFAM)txfp)->SetOptimized(To_Pos != NULL);
} // endelse } // endelse
#else #else
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif #endif
} else } else
...@@ -531,13 +531,13 @@ int TDBDOS::ResetTableOpt(PGLOBAL g, bool dop, bool dox) ...@@ -531,13 +531,13 @@ int TDBDOS::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
// except for ZLIB access method. // except for ZLIB access method.
if (Txfp->GetAmType() == TYPE_AM_MAP) { if (Txfp->GetAmType() == TYPE_AM_MAP) {
Txfp = new(g) MAPFAM((PDOSDEF)To_Def); Txfp = new(g) MAPFAM((PDOSDEF)To_Def);
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
} else if (Txfp->GetAmType() == TYPE_AM_ZIP) { } else if (Txfp->GetAmType() == TYPE_AM_GZ) {
Txfp = new(g) ZIPFAM((PDOSDEF)To_Def); Txfp = new(g) GZFAM((PDOSDEF)To_Def);
} else if (Txfp->GetAmType() == TYPE_AM_ZLIB) { } else if (Txfp->GetAmType() == TYPE_AM_ZLIB) {
Txfp->Reset(); Txfp->Reset();
((PZLBFAM)Txfp)->SetOptimized(false); ((PZLBFAM)Txfp)->SetOptimized(false);
#endif // ZIP_SUPPORT #endif // GZ_SUPPORT
} else if (Txfp->GetAmType() == TYPE_AM_BLK) } else if (Txfp->GetAmType() == TYPE_AM_BLK)
Txfp = new(g) DOSFAM((PDOSDEF)To_Def); Txfp = new(g) DOSFAM((PDOSDEF)To_Def);
...@@ -2079,10 +2079,10 @@ bool TDBDOS::OpenDB(PGLOBAL g) ...@@ -2079,10 +2079,10 @@ bool TDBDOS::OpenDB(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
if (Txfp->GetAmType() == TYPE_AM_MAP && Mode == MODE_DELETE) if (Txfp->GetAmType() == TYPE_AM_MAP && Mode == MODE_DELETE)
Txfp = new(g) MAPFAM((PDOSDEF)To_Def); Txfp = new(g) MAPFAM((PDOSDEF)To_Def);
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
else if (Txfp->GetAmType() == TYPE_AM_ZIP) else if (Txfp->GetAmType() == TYPE_AM_GZ)
Txfp = new(g) ZIPFAM((PDOSDEF)To_Def); Txfp = new(g) GZFAM((PDOSDEF)To_Def);
#endif // ZIP_SUPPORT #endif // GZ_SUPPORT
else // if (Txfp->GetAmType() != TYPE_AM_DOS) ??? else // if (Txfp->GetAmType() != TYPE_AM_DOS) ???
Txfp = new(g) DOSFAM((PDOSDEF)To_Def); Txfp = new(g) DOSFAM((PDOSDEF)To_Def);
......
...@@ -91,7 +91,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */ ...@@ -91,7 +91,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
int Maxerr; /* Maximum number of bad records (DBF) */ int Maxerr; /* Maximum number of bad records (DBF) */
int ReadMode; /* Specific to DBF */ int ReadMode; /* Specific to DBF */
int Ending; /* Length of end of lines */ int Ending; /* Length of end of lines */
int Teds; /* Binary table default endian setting */ char Teds; /* Binary table default endian setting */
}; // end of DOSDEF }; // end of DOSDEF
/***********************************************************************/ /***********************************************************************/
......
/************* TabFix C++ Program Source Code File (.CPP) **************/ /************* TabFix C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABFIX */ /* PROGRAM NAME: TABFIX */
/* ------------- */ /* ------------- */
/* Version 4.9 */ /* Version 4.9.1 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -589,9 +589,10 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -589,9 +589,10 @@ void BINCOL::WriteColumn(PGLOBAL g)
switch (Fmt) { switch (Fmt) {
case 'X': case 'X':
// Standard not converted values // Standard not converted values
if (Eds && IsTypeChar(Buf_Type)) if (Eds && IsTypeChar(Buf_Type)) {
*(longlong *)p = Value->GetBigintValue(); if (Status)
else if (Value->GetBinValue(p, Long, Status)) { Value->GetValueNonAligned<longlong>(p, Value->GetBigintValue());
} else if (Value->GetBinValue(p, Long, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), sprintf(g->Message, MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), Long); Name, Value->GetSize(), Long);
longjmp(g->jumper[g->jump_level], 31); longjmp(g->jumper[g->jump_level], 31);
...@@ -605,7 +606,7 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -605,7 +606,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31); longjmp(g->jumper[g->jump_level], 31);
} else if (Status) } else if (Status)
*(short *)p = (short)n; Value->GetValueNonAligned<short>(p, (short)n);
break; break;
case 'T': // Tiny integer case 'T': // Tiny integer
...@@ -625,7 +626,7 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -625,7 +626,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31); longjmp(g->jumper[g->jump_level], 31);
} else if (Status) } else if (Status)
*(int *)p = Value->GetIntValue(); Value->GetValueNonAligned<int>(p, (int)n);
break; break;
case 'G': // Large (great) integer case 'G': // Large (great) integer
...@@ -636,12 +637,12 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -636,12 +637,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
case 'F': // Float case 'F': // Float
case 'R': // Real case 'R': // Real
if (Status) if (Status)
*(float *)p = (float)Value->GetFloatValue(); Value->GetValueNonAligned<float>(p, (float)Value->GetFloatValue());
break; break;
case 'D': // Double case 'D': // Double
if (Status) if (Status)
*(double *)p = Value->GetFloatValue(); Value->GetValueNonAligned<double>(p, Value->GetFloatValue());
break; break;
case 'C': // Characters case 'C': // Characters
......
/************* TabFmt C++ Program Source Code File (.CPP) **************/ /************* TabFmt C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABFMT */ /* PROGRAM NAME: TABFMT */
/* ------------- */ /* ------------- */
/* Version 3.9 */ /* Version 3.9.1 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2001 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2001 - 2016 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -51,9 +51,9 @@ ...@@ -51,9 +51,9 @@
#include "plgdbsem.h" #include "plgdbsem.h"
#include "mycat.h" #include "mycat.h"
#include "filamap.h" #include "filamap.h"
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
#include "filamzip.h" #include "filamgz.h"
#endif // ZIP_SUPPORT #endif // GZ_SUPPORT
#include "tabfmt.h" #include "tabfmt.h"
#include "tabmul.h" #include "tabmul.h"
#define NO_FUNC #define NO_FUNC
...@@ -462,16 +462,16 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -462,16 +462,16 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
// Should be now compatible with UNIX // Should be now compatible with UNIX
txfp = new(g) MAPFAM(this); txfp = new(g) MAPFAM(this);
} else if (Compressed) { } else if (Compressed) {
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
if (Compressed == 1) if (Compressed == 1)
txfp = new(g) ZIPFAM(this); txfp = new(g) GZFAM(this);
else else
txfp = new(g) ZLBFAM(this); txfp = new(g) ZLBFAM(this);
#else // !ZIP_SUPPORT #else // !GZ_SUPPORT
strcpy(g->Message, "Compress not supported"); strcpy(g->Message, "Compress not supported");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !GZ_SUPPORT
} else } else
txfp = new(g) DOSFAM(this); txfp = new(g) DOSFAM(this);
...@@ -498,7 +498,7 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -498,7 +498,7 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
if (map) { if (map) {
txfp = new(g) MBKFAM(this); txfp = new(g) MBKFAM(this);
} else if (Compressed) { } else if (Compressed) {
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
if (Compressed == 1) if (Compressed == 1)
txfp = new(g) ZBKFAM(this); txfp = new(g) ZBKFAM(this);
else { else {
...@@ -506,7 +506,7 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -506,7 +506,7 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
((PZLBFAM)txfp)->SetOptimized(To_Pos != NULL); ((PZLBFAM)txfp)->SetOptimized(To_Pos != NULL);
} // endelse } // endelse
#else #else
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif #endif
} else } else
......
/************* tabjson C++ Program Source Code File (.CPP) *************/ /************* tabjson C++ Program Source Code File (.CPP) *************/
/* PROGRAM NAME: tabjson Version 1.1 */ /* PROGRAM NAME: tabjson Version 1.2 */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2016 */
/* This program are the JSON class DB execution routines. */ /* This program are the JSON class DB execution routines. */
/***********************************************************************/ /***********************************************************************/
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
//#include "resource.h" // for IDS_COLUMNS //#include "resource.h" // for IDS_COLUMNS
#include "tabjson.h" #include "tabjson.h"
#include "filamap.h" #include "filamap.h"
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
#include "filamzip.h" #include "filamgz.h"
#endif // ZIP_SUPPORT #endif // GZ_SUPPORT
#include "tabmul.h" #include "tabmul.h"
#include "checklvl.h" #include "checklvl.h"
#include "resource.h" #include "resource.h"
...@@ -396,15 +396,15 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) ...@@ -396,15 +396,15 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
(m == MODE_UPDATE || m == MODE_DELETE)); (m == MODE_UPDATE || m == MODE_DELETE));
if (Compressed) { if (Compressed) {
#if defined(ZIP_SUPPORT) #if defined(GZ_SUPPORT)
if (Compressed == 1) if (Compressed == 1)
txfp = new(g) ZIPFAM(this); txfp = new(g) GZFAM(this);
else else
txfp = new(g) ZLBFAM(this); txfp = new(g) ZLBFAM(this);
#else // !ZIP_SUPPORT #else // !GZ_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !GZ_SUPPORT
} else if (map) } else if (map)
txfp = new(g) MAPFAM(this); txfp = new(g) MAPFAM(this);
else else
......
/************* Value C++ Functions Source Code File (.CPP) *************/ /************* Value C++ Functions Source Code File (.CPP) *************/
/* Name: VALUE.CPP Version 2.5 */ /* Name: VALUE.CPP Version 2.6 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2015 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2016 */
/* */ /* */
/* This file contains the VALUE and derived classes family functions. */ /* This file contains the VALUE and derived classes family functions. */
/* These classes contain values of different types. They are used so */ /* These classes contain values of different types. They are used so */
...@@ -792,19 +792,29 @@ uchar TYPVAL<uchar>::GetTypedValue(PVBLK blk, int n) ...@@ -792,19 +792,29 @@ uchar TYPVAL<uchar>::GetTypedValue(PVBLK blk, int n)
/***********************************************************************/ /***********************************************************************/
/* TYPVAL SetBinValue: with bytes extracted from a line. */ /* TYPVAL SetBinValue: with bytes extracted from a line. */
/* Currently only used reading column of binary files. */
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
void TYPVAL<TYPE>::SetBinValue(void *p) void TYPVAL<TYPE>::SetBinValue(void *p)
{ {
Tval = *(TYPE *)p; #if defined(UNALIGNED_OK)
Null = false; // x86 can cast non-aligned memory directly
} // end of SetBinValue Tval = *(TYPE *)p;
#else
// Prevent unaligned memory access on MIPS and ArmHF platforms.
// Make use of memcpy instead of straight pointer dereferencing.
// Currently only used by WriteColumn of binary files.
// From original author: Vicentiu Ciorbaru <vicentiu@mariadb.org>
memcpy(&Tval, p, sizeof(TYPE));
#endif
Null = false;
} // end of SetBinValue
/***********************************************************************/ /***********************************************************************/
/* GetBinValue: fill a buffer with the internal binary value. */ /* GetBinValue: fill a buffer with the internal binary value. */
/* This function checks whether the buffer length is enough and */ /* This function checks whether the buffer length is enough and */
/* returns true if not. Actual filling occurs only if go is true. */ /* returns true if not. Actual filling occurs only if go is true. */
/* Currently used by WriteColumn of binary files. */ /* Currently only used writing column of binary files. */
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
bool TYPVAL<TYPE>::GetBinValue(void *buf, int buflen, bool go) bool TYPVAL<TYPE>::GetBinValue(void *buf, int buflen, bool go)
...@@ -819,7 +829,16 @@ bool TYPVAL<TYPE>::GetBinValue(void *buf, int buflen, bool go) ...@@ -819,7 +829,16 @@ bool TYPVAL<TYPE>::GetBinValue(void *buf, int buflen, bool go)
//#endif //#endif
if (go) if (go)
*(TYPE *)buf = Tval; #if defined(UNALIGNED_OK)
// x86 can cast non-aligned memory directly
*(TYPE *)buf = Tval;
#else
// Prevent unaligned memory access on MIPS and ArmHF platforms.
// Make use of memcpy instead of straight pointer dereferencing.
// Currently only used by WriteColumn of binary files.
// From original author: Vicentiu Ciorbaru <vicentiu@mariadb.org>
memcpy(buf, &Tval, sizeof(TYPE));
#endif
Null = false; Null = false;
return false; return false;
......
/**************** Value H Declares Source Code File (.H) ***************/ /**************** Value H Declares Source Code File (.H) ***************/
/* Name: VALUE.H Version 2.1 */ /* Name: VALUE.H Version 2.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2016 */
/* */ /* */
/* This file contains the VALUE and derived classes declares. */ /* This file contains the VALUE and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
...@@ -16,6 +16,13 @@ ...@@ -16,6 +16,13 @@
#include "assert.h" #include "assert.h"
#include "block.h" #include "block.h"
/***********************************************************************/
/* This should list the processors accepting unaligned numeral values.*/
/***********************************************************************/
#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_IA64)
#define UNALIGNED_OK
#endif
/***********************************************************************/ /***********************************************************************/
/* Types used in some class definitions. */ /* Types used in some class definitions. */
/***********************************************************************/ /***********************************************************************/
...@@ -116,27 +123,46 @@ class DllExport VALUE : public BLOCK { ...@@ -116,27 +123,46 @@ class DllExport VALUE : public BLOCK {
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op); virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual bool FormatValue(PVAL vp, char *fmt) = 0; virtual bool FormatValue(PVAL vp, char *fmt) = 0;
/** /**
Set value from a non-aligned in-memory value in the machine byte order. Set value from a non-aligned in-memory value in the machine byte order.
TYPE can be either of: TYPE can be either of:
- int, short, longlong - int, short, longlong
- uint, ushort, ulonglong - uint, ushort, ulonglong
- float, double - float, double
@param - a pointer to a non-aligned value of type TYPE. @param - a pointer to a non-aligned value of type TYPE.
*/ */
template<typename TYPE> template<typename TYPE>
void SetValueNonAligned(const char *p) void SetValueNonAligned(const char *p)
{ {
#if defined(__i386__) || defined(__x86_64__) #if defined(UNALIGNED_OK)
SetValue(*((TYPE*) p)); // x86 can cast non-aligned memory directly SetValue(*((TYPE*)p)); // x86 can cast non-aligned memory directly
#else #else
TYPE tmp; // a slower version for non-x86 platforms TYPE tmp; // a slower version for non-x86 platforms
memcpy(&tmp, p, sizeof(tmp)); memcpy(&tmp, p, sizeof(tmp));
SetValue(tmp); SetValue(tmp);
#endif #endif
} } // end of SetValueNonAligned
/**
Get value from a non-aligned in-memory value in the machine byte order.
TYPE can be either of:
- int, short, longlong
- uint, ushort, ulonglong
- float, double
@params - a pointer to a non-aligned value of type TYPE, the TYPE value.
*/
template<typename TYPE>
void GetValueNonAligned(char *p, TYPE n)
{
#if defined(UNALIGNED_OK)
*(TYPE *)p = n; // x86 can cast non-aligned memory directly
#else
TYPE tmp = n; // a slower version for non-x86 platforms
memcpy(p, &tmp, sizeof(tmp));
#endif
} // end of SetValueNonAligned
protected: protected:
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0; virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
const char *GetXfmt(void); const char *GetXfmt(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment