mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
Handle ODBC table null values modified: tabodbc.cpp
This commit is contained in:
@@ -709,6 +709,28 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
|
|||||||
return (tdbp->To_Kindex->IsMul()) ? 2 : 1;
|
return (tdbp->To_Kindex->IsMul()) ? 2 : 1;
|
||||||
} // end of CntIndexInit
|
} // 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. */
|
/* IndexRead: fetch a record having the index value. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -779,7 +801,12 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
|
|||||||
|
|
||||||
if (!valp->IsTypeNum()) {
|
if (!valp->IsTypeNum()) {
|
||||||
if (colp->GetColUse(U_VAR)) {
|
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;
|
lg= *(short*)kp;
|
||||||
|
#endif //!WORDS_BIGENDIAN
|
||||||
kp+= sizeof(short);
|
kp+= sizeof(short);
|
||||||
rcb= valp->SetValue_char(kp, (int)lg);
|
rcb= valp->SetValue_char(kp, (int)lg);
|
||||||
} else
|
} else
|
||||||
@@ -797,7 +824,11 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
|
|||||||
} // endif b
|
} // endif b
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
#if defined(WORDS_BIGENDIAN)
|
||||||
|
SetSwapValue(valp, kp);
|
||||||
|
#else // !WORDS_BIGENDIAN
|
||||||
valp->SetBinValue((void*)kp);
|
valp->SetBinValue((void*)kp);
|
||||||
|
#endif //!WORDS_BIGENDIAN
|
||||||
|
|
||||||
kp+= valp->GetClen();
|
kp+= valp->GetClen();
|
||||||
|
|
||||||
@@ -893,7 +924,12 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
|
|||||||
|
|
||||||
if (!valp->IsTypeNum()) {
|
if (!valp->IsTypeNum()) {
|
||||||
if (colp->GetColUse(U_VAR)) {
|
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;
|
lg= *(short*)p;
|
||||||
|
#endif //!WORDS_BIGENDIAN
|
||||||
p+= sizeof(short);
|
p+= sizeof(short);
|
||||||
rcb= valp->SetValue_char((char*)p, (int)lg);
|
rcb= valp->SetValue_char((char*)p, (int)lg);
|
||||||
} else
|
} else
|
||||||
@@ -912,7 +948,11 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
|
|||||||
} // endif b
|
} // endif b
|
||||||
|
|
||||||
} else
|
} 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) {
|
if (trace) {
|
||||||
char bf[32];
|
char bf[32];
|
||||||
|
@@ -1268,6 +1268,10 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
|
|||||||
|
|
||||||
} // endif Buf_Type
|
} // endif Buf_Type
|
||||||
|
|
||||||
|
// Handle null values
|
||||||
|
if (Value->IsZero())
|
||||||
|
Value->SetNull(Nullable);
|
||||||
|
|
||||||
if (trace) {
|
if (trace) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
@@ -1393,7 +1397,7 @@ void ODBCCOL::WriteColumn(PGLOBAL g)
|
|||||||
/* -------------------------- Class TDBXDBC -------------------------- */
|
/* -------------------------- Class TDBXDBC -------------------------- */
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Implementation of the TDBODBC class. */
|
/* Implementation of the TDBXDBC class. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
TDBXDBC::TDBXDBC(PODEF tdp) : TDBODBC(tdp)
|
TDBXDBC::TDBXDBC(PODEF tdp) : TDBODBC(tdp)
|
||||||
{
|
{
|
||||||
|
@@ -65,7 +65,11 @@ typedef struct index_def : public BLOCK {
|
|||||||
|
|
||||||
typedef struct index_off {
|
typedef struct index_off {
|
||||||
union {
|
union {
|
||||||
|
#if defined(WORDS_BIGENDIAN)
|
||||||
|
struct {int High; int Low;};
|
||||||
|
#else // !WORDS_BIGENDIAN
|
||||||
struct {int Low; int High;};
|
struct {int Low; int High;};
|
||||||
|
#endif //!WORDS_BIGENDIAN
|
||||||
longlong Val; // File position
|
longlong Val; // File position
|
||||||
}; // end of union
|
}; // end of union
|
||||||
} IOFF;
|
} IOFF;
|
||||||
|
Reference in New Issue
Block a user