diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2015-06-03 11:31:18 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2015-06-03 11:31:18 +0200 |
commit | 37a803c80520974c1c97661d7d578b056824ecdc (patch) | |
tree | 68f1ddd789f36e0c6b771c24c07630010af6a718 /storage | |
parent | 65ed25446807efc0fe4482b69f6d76bf830c29f8 (diff) | |
download | mariadb-git-37a803c80520974c1c97661d7d578b056824ecdc.tar.gz |
Fix swapping key numeric values on Big Endian machines.
Swap the key length when WORDS_BIGENDIAN is defined
Make the IOFF structure depending on WORDS_BIGENDIAN
modified: storage/connect/connect.cc
modified: storage/connect/xindex.h
Diffstat (limited to 'storage')
-rw-r--r-- | storage/connect/connect.cc | 10 | ||||
-rw-r--r-- | storage/connect/xindex.h | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index cc95ff0cacc..d7b8b466d50 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -801,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 @@ -919,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*)kp)[1]; + ((char*)&lg)[1]= ((char*)kp)[0]; +#else // !WORDS_BIGENDIAN lg= *(short*)p; +#endif //!WORDS_BIGENDIAN p+= sizeof(short); rcb= valp->SetValue_char((char*)p, (int)lg); } else diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h index a4e98075222..51b678992ea 100644 --- a/storage/connect/xindex.h +++ b/storage/connect/xindex.h @@ -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; |