Commit 37a803c8 authored by Olivier Bertrand's avatar Olivier Bertrand

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
parent 65ed2544
......@@ -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
......
......@@ -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;
......
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