summaryrefslogtreecommitdiff
path: root/ndb/src/ndbapi
diff options
context:
space:
mode:
authorunknown <pekka@mysql.com>2006-05-21 11:04:57 +0200
committerunknown <pekka@mysql.com>2006-05-21 11:04:57 +0200
commita57c96747bffc059965b4f379e8716c90f3da7eb (patch)
tree4b22acc09faa639dc5236752d5f842a4dda6f349 /ndb/src/ndbapi
parentf3de1b85921981faaf909c354d7421e8841bb579 (diff)
downloadmariadb-git-a57c96747bffc059965b4f379e8716c90f3da7eb.tar.gz
ndb - bug#19956 (occurs only in v5.0)
mysql-test/r/ndb_blob.result: bug#19956 : var* pk mysql-test/t/ndb_blob.test: bug#19956 : var* pk ndb/src/ndbapi/NdbDictionaryImpl.hpp: bug#19956 - check var* length bytes and zero rest of value if any blob attribute ndb/src/ndbapi/NdbOperationSearch.cpp: bug#19956 - check var* length bytes and zero rest of value if any blob attribute
Diffstat (limited to 'ndb/src/ndbapi')
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.hpp25
-rw-r--r--ndb/src/ndbapi/NdbOperationSearch.cpp14
2 files changed, 39 insertions, 0 deletions
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/ndb/src/ndbapi/NdbDictionaryImpl.hpp
index 754d0000718..59f5c4875c0 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.hpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.hpp
@@ -91,6 +91,10 @@ public:
NdbDictionary::Column * m_facade;
static NdbDictionary::Column * create_psuedo(const char *);
+
+ // Get total length in bytes, used by NdbOperation
+ // backported from 5.1
+ bool get_var_length(const void* value, Uint32& len) const;
};
class NdbTableImpl : public NdbDictionary::Table, public NdbDictObjectImpl {
@@ -490,6 +494,27 @@ NdbColumnImpl::getBlobType() const {
}
inline
+bool
+NdbColumnImpl::get_var_length(const void* value, Uint32& len) const
+{
+ Uint32 max_len = m_attrSize * m_arraySize;
+ switch (m_type) {
+ case NdbDictionary::Column::Varchar:
+ case NdbDictionary::Column::Varbinary:
+ len = 1 + *((Uint8*)value);
+ break;
+ case NdbDictionary::Column::Longvarchar:
+ case NdbDictionary::Column::Longvarbinary:
+ len = 2 + uint2korr((char*)value);
+ break;
+ default:
+ len = max_len;
+ return true;
+ }
+ return (len <= max_len);
+}
+
+inline
NdbTableImpl &
NdbTableImpl::getImpl(NdbDictionary::Table & t){
return t.m_impl;
diff --git a/ndb/src/ndbapi/NdbOperationSearch.cpp b/ndb/src/ndbapi/NdbOperationSearch.cpp
index 06d8ddd412b..4be7ccb313c 100644
--- a/ndb/src/ndbapi/NdbOperationSearch.cpp
+++ b/ndb/src/ndbapi/NdbOperationSearch.cpp
@@ -71,6 +71,7 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo,
Uint32 tKeyInfoPosition;
const char* aValue = aValuePassed;
Uint64 tempData[512];
+ Uint64 tempData2[512];
if ((theStatus == OperationDefined) &&
(aValue != NULL) &&
@@ -131,6 +132,19 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo,
OperationType tOpType = theOperationType;
Uint32 sizeInBytes = tAttrInfo->m_attrSize * tAttrInfo->m_arraySize;
+ Uint32 real_len;
+ if (! tAttrInfo->get_var_length(aValue, real_len)) {
+ setErrorCodeAbort(4209);
+ DBUG_RETURN(-1);
+ }
+
+ // 5.0 fixed storage + NdbBlob uses full size => pad var* with nulls
+ if (real_len < sizeInBytes && m_currentTable->m_noOfBlobs != 0) {
+ memcpy(tempData2, aValue, real_len);
+ memset((char*)tempData2 + real_len, 0, sizeInBytes - real_len);
+ aValue = (char*)tempData2;
+ }
+
{
/************************************************************************
* Check if the pointer of the value passed is aligned on a 4 byte