diff options
author | Narayanan V <v.narayanan@sun.com> | 2009-05-29 15:01:00 +0530 |
---|---|---|
committer | Narayanan V <v.narayanan@sun.com> | 2009-05-29 15:01:00 +0530 |
commit | 858e118ab9520dc52882b0b796be5c4e975f4451 (patch) | |
tree | 6eb0fe73a965b02e714a8190d4bc8f0a7e976544 /storage | |
parent | b4a725c4f3dd1f06a366000202a91bdc1b301a04 (diff) | |
download | mariadb-git-858e118ab9520dc52882b0b796be5c4e975f4451.tar.gz |
Bug#44811 Tests with utf8 charset fail with ibmdb2i on 64bit MySQL
wmemset was being used to fill the row buffers.
wmemset was intended to fill the buffer with
16-bit UCS2 pad values. However, the 64-bit
version of wmemset uses 32-bit wide characters
and thus filled the buffer incorrectly. In some
cases, the null byte map would be overwritten,
causing ctype_utf8.test and ibmdb2i_rir.test to
fail, giving the error message CPF5035.
This patch eliminates the use of wmemset to fill
the row buffer. wmemset has been replaced with
memset16, which always fills memory with 16-bit
values.
storage/ibmdb2i/db2i_conversion.cc:
Bug#44811 Tests with utf8 charset fail with ibmdb2i on 64bit MySQL
Eliminate the use of wmemset to fill
the row buffer. Replace wmemset with
memset16, which always fills memory
with 16-bit values.
storage/ibmdb2i/db2i_misc.h:
Bug#44811 Tests with utf8 charset fail with ibmdb2i on 64bit MySQL
Eliminate the use of wmemset to fill
the row buffer. Replace wmemset with
memset16, which always fills memory
with 16-bit values.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/ibmdb2i/db2i_conversion.cc | 4 | ||||
-rw-r--r-- | storage/ibmdb2i/db2i_misc.h | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/storage/ibmdb2i/db2i_conversion.cc b/storage/ibmdb2i/db2i_conversion.cc index bdb8085d937..0acde10a4cd 100644 --- a/storage/ibmdb2i/db2i_conversion.cc +++ b/storage/ibmdb2i/db2i_conversion.cc @@ -1085,7 +1085,7 @@ int32 ha_ibmdb2i::convertMySQLtoDB2(Field* field, const DB2Field& db2Field, char if (bytesToStore) memcpy(db2Buf, dataToStore, bytesToStore); if (bytesToPad) - wmemset((wchar_t*)(db2Buf + bytesToStore), 0x0020, bytesToPad/2); + memset16((db2Buf + bytesToStore), 0x0020, bytesToPad/2); } else { @@ -1108,7 +1108,7 @@ int32 ha_ibmdb2i::convertMySQLtoDB2(Field* field, const DB2Field& db2Field, char bytesToStore = db2BytesToStore; } if (db2BytesToStore < maxDb2BytesToStore) // If need to pad - wmemset((wchar_t*)(db2Buf + db2BytesToStore), 0x0020, (maxDb2BytesToStore - db2BytesToStore)/2); + memset16((db2Buf + db2BytesToStore), 0x0020, (maxDb2BytesToStore - db2BytesToStore)/2); } if (db2FieldType == QMY_VARGRAPHIC) diff --git a/storage/ibmdb2i/db2i_misc.h b/storage/ibmdb2i/db2i_misc.h index 9e20f01208b..f0b527aaad0 100644 --- a/storage/ibmdb2i/db2i_misc.h +++ b/storage/ibmdb2i/db2i_misc.h @@ -109,5 +109,21 @@ bool isOrdinaryIdentifier(const char* s) } return true; } + +/** + Fill memory with a 16-bit word. + @param p Pointer to space to fill. + @param v Value to fill + @param l Length of space (in 16-bit words) +*/ +void memset16(void* p, uint16 v, size_t l) +{ + uint16* p2=(uint16*)p; + while (l--) + { + *(p2++) = v; + } +} + #endif |