Commit 36d2bd6a authored by Olivier Bertrand's avatar Olivier Bertrand

Handle ODBC table null values modified: tabodbc.cpp

parent e8ea671c
......@@ -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
valp->SetBinValue((void*)p);
#if defined(WORDS_BIGENDIAN)
SetSwapValue(valp, (char*)kp);
#else // !WORDS_BIGENDIAN
valp->SetBinValue((void*)kp);
#endif // !WORDS_BIGENDIAN
if (trace) {
char bf[32];
......
......@@ -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)
{
......
......@@ -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