diff options
author | Ramil Kalimullin <ramil@mysql.com> | 2010-02-28 21:29:19 +0400 |
---|---|---|
committer | Ramil Kalimullin <ramil@mysql.com> | 2010-02-28 21:29:19 +0400 |
commit | 9715539ebd9519ca66e9b803f435878a819d3f99 (patch) | |
tree | bf8eb3065b2e2e5ab3187d8ccf85ec423279b961 /sql | |
parent | 723e67b92548221d887f7e21b4d654da45eb0d1a (diff) | |
download | mariadb-git-9715539ebd9519ca66e9b803f435878a819d3f99.tar.gz |
Fix for bug#51304: checksum table gives different results
for same data when using bit fields
Problem: checksum for BIT fields may be computed incorrectly
in some cases due to its storage peculiarity.
Fix: convert a BIT field to a string then calculate its checksum.
mysql-test/r/myisam.result:
Fix for bug#51304: checksum table gives different results
for same data when using bit fields
- test result.
mysql-test/t/myisam.test:
Fix for bug#51304: checksum table gives different results
for same data when using bit fields
- test case.
sql/sql_table.cc:
Fix for bug#51304: checksum table gives different results
for same data when using bit fields
- convert BIT fields to strings calculating its checksums
as some bits may be saved among NULL bits in the record buffer.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_table.cc | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 871b2f2d552..eb88b1e70a5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7934,22 +7934,28 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, for (uint i= 0; i < t->s->fields; i++ ) { Field *f= t->field[i]; - enum_field_types field_type= f->type(); - /* - BLOB and VARCHAR have pointers in their field, we must convert - to string; GEOMETRY is implemented on top of BLOB. - */ - if ((field_type == MYSQL_TYPE_BLOB) || - (field_type == MYSQL_TYPE_VARCHAR) || - (field_type == MYSQL_TYPE_GEOMETRY)) - { - String tmp; - f->val_str(&tmp); - row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(), tmp.length()); + + /* + BLOB and VARCHAR have pointers in their field, we must convert + to string; GEOMETRY is implemented on top of BLOB. + BIT may store its data among NULL bits, convert as well. + */ + switch (f->type()) { + case MYSQL_TYPE_BLOB: + case MYSQL_TYPE_VARCHAR: + case MYSQL_TYPE_GEOMETRY: + case MYSQL_TYPE_BIT: + { + String tmp; + f->val_str(&tmp); + row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(), + tmp.length()); + break; + } + default: + row_crc= my_checksum(row_crc, f->ptr, f->pack_length()); + break; } - else - row_crc= my_checksum(row_crc, f->ptr, - f->pack_length()); } crc+= row_crc; |