diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2015-06-03 02:02:21 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2015-06-03 02:02:21 +0200 |
commit | 70d80305a87e04d8cea577a19666489b828f346c (patch) | |
tree | 9cf46eeca3e13ced5a25eb1be4ad9ff84098bf9b /storage/connect/connect.cc | |
parent | af26c366e0e1a1dddcbec9f57706b7032768f29f (diff) | |
download | mariadb-git-70d80305a87e04d8cea577a19666489b828f346c.tar.gz |
Fix swapping key numeric values on Big Endian machines.
modified: storage/connect/connect.cc
Diffstat (limited to 'storage/connect/connect.cc')
-rw-r--r-- | storage/connect/connect.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 12b23878891..fd5cb164e05 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -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(BIG_ENDIAN_ORDER) +/***********************************************************************/ +/* 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 //LITTLE ENDIAN + /***********************************************************************/ /* IndexRead: fetch a record having the index value. */ /***********************************************************************/ @@ -797,7 +819,11 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op, } // endif b } else +#if defined(BIG_ENDIAN_ORDER) + SetSwapValue(valp, kp); +#else // LITTLE ENDIAN valp->SetBinValue((void*)kp); +#endif //LITTLE ENDIAN kp+= valp->GetClen(); @@ -912,7 +938,11 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, } // endif b } else - valp->SetBinValue((void*)p); +#if defined(BIG_ENDIAN_ORDER) + SetSwapValue(valp, (char*)kp); +#else // LITTLE ENDIAN + valp->SetBinValue((void*)kp); +#endif //LITTLE ENDIAN if (trace) { char bf[32]; |