From df4d3039c3160ccd76602cf835f48043b5f021ea Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Mar 2007 10:39:11 +0200 Subject: [PATCH 1/3] remove warning --- ndb/test/src/NDBT_Table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/test/src/NDBT_Table.cpp b/ndb/test/src/NDBT_Table.cpp index 8200747fc96..34db6ed9822 100644 --- a/ndb/test/src/NDBT_Table.cpp +++ b/ndb/test/src/NDBT_Table.cpp @@ -31,7 +31,7 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab) ndbout << "Number of attributes: " << tab.getNoOfColumns() << endl; ndbout << "Number of primary keys: " << tab.getNoOfPrimaryKeys() << endl; ndbout << "Length of frm data: " << tab.getFrmLength() << endl; - ndbout << "SingleUserMode: " << tab.getSingleUserMode() << endl; + ndbout << "SingleUserMode: " << (Uint32) tab.getSingleUserMode() << endl; //<< ((tab.getTupleKey() == TupleId) ? " tupleid" : "") < Date: Mon, 26 Mar 2007 14:48:52 +0200 Subject: [PATCH 2/3] Bug #26986 BIT(33) for ndb is broken on solaris. - always store lsw first in ndb --- sql/ha_ndbcluster.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 5f44530b2db..9bd220ab179 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -726,11 +726,8 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field, DBUG_PRINT("info", ("bit field")); DBUG_DUMP("value", (char*)&bits, pack_len); #ifdef WORDS_BIGENDIAN - if (pack_len < 5) - { - DBUG_RETURN(ndb_op->setValue(fieldnr, - ((char*)&bits)+4, pack_len) != 0); - } + /* store lsw first */ + bits = (bits >> 32) | (bits << 32); #endif DBUG_RETURN(ndb_op->setValue(fieldnr, (char*)&bits, pack_len) != 0); } @@ -2653,8 +2650,15 @@ void ha_ndbcluster::unpack_record(byte* buf) DBUG_PRINT("info", ("bit field H'%.8X%.8X", *(Uint32 *)(*value).rec->aRef(), *((Uint32 *)(*value).rec->aRef()+1))); +#ifdef WORDS_BIGENDIAN + /* lsw is stored first */ + Uint32 *buf= (Uint32 *)(*value).rec->aRef(); + ((Field_bit *) *field)->store(*buf | (((longlong)*(buf+1)) << 32), + TRUE); +#else ((Field_bit *) *field)->store((longlong) (*value).rec->u_64_value(), TRUE); +#endif } } } From d24dab182f8366e1e0ee74248ab38d6df26abcd3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Mar 2007 17:57:00 +0200 Subject: [PATCH 3/3] correct medium int printout correct cit printout correct bit store retrieve ndb/include/ndbapi/NdbRecAttr.hpp: correct medium int printout ndb/src/ndbapi/NdbRecAttr.cpp: correct cit printout sql/ha_ndbcluster.cc: correct bit store retrieve --- ndb/include/ndbapi/NdbRecAttr.hpp | 7 ++----- ndb/src/ndbapi/NdbRecAttr.cpp | 23 ++++++----------------- sql/ha_ndbcluster.cc | 9 +++++++-- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/ndb/include/ndbapi/NdbRecAttr.hpp b/ndb/include/ndbapi/NdbRecAttr.hpp index 2f3a2c8383a..7f8add774dc 100644 --- a/ndb/include/ndbapi/NdbRecAttr.hpp +++ b/ndb/include/ndbapi/NdbRecAttr.hpp @@ -336,10 +336,7 @@ inline Int32 NdbRecAttr::medium_value() const { - Uint32 tmp = *(Uint32*)theRef; - if (tmp & (0x1<<23)) - tmp|= (0xFF<<24); - return (Int32)tmp; + return sint3korr((unsigned char *)theRef); } inline @@ -367,7 +364,7 @@ inline Uint32 NdbRecAttr::u_medium_value() const { - return *(Uint32*)theRef; + return uint3korr((unsigned char*)theRef); } inline diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index a0c394603c5..90808a706d4 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -236,24 +236,13 @@ ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r, break; case NdbDictionary::Column::Bit: out << f.hex_prefix << "0x"; - if (length < 33) { - out.print("%X", r.u_32_value()); - } - else if (length < 65) - { - out.print("%llX", r.u_64_value()); - } - else - { - const unsigned char *buf = (unsigned char *)r.aRef(); - int k = 4*((length+31)/32); - while (k > 0 && (*(buf + --k) == 0)); - do - { - out.print("%X", (Uint32)*(buf + k--)); - } - while (k >= 0); + const Uint32 *buf = (Uint32 *)r.aRef(); + int k = (length+31)/32; + while (k > 0 && (buf[--k] == 0)); + out.print("%X", buf[k]); + while (k > 0) + out.print("%.8X", buf[--k]); } break; case NdbDictionary::Column::Unsigned: diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 9bd220ab179..5c7ba12a5da 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -727,7 +727,8 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field, DBUG_DUMP("value", (char*)&bits, pack_len); #ifdef WORDS_BIGENDIAN /* store lsw first */ - bits = (bits >> 32) | (bits << 32); + bits = ((bits >> 32) & 0x00000000FFFFFFFF) + | ((bits << 32) & 0xFFFFFFFF00000000); #endif DBUG_RETURN(ndb_op->setValue(fieldnr, (char*)&bits, pack_len) != 0); } @@ -2653,7 +2654,11 @@ void ha_ndbcluster::unpack_record(byte* buf) #ifdef WORDS_BIGENDIAN /* lsw is stored first */ Uint32 *buf= (Uint32 *)(*value).rec->aRef(); - ((Field_bit *) *field)->store(*buf | (((longlong)*(buf+1)) << 32), + ((Field_bit *) *field)->store((((longlong)*buf) + & 0x000000000FFFFFFFF) + | + ((((longlong)*(buf+1)) << 32) + & 0xFFFFFFFF00000000), TRUE); #else ((Field_bit *) *field)->store((longlong)