Commit ea363750 authored by unknown's avatar unknown

Bug#12296 - CHECKSUM TABLE reports 0 for the table

Skipping deleted records instead of breaking the loop
during checksum calculation.


mysql-test/r/myisam.result:
  Bug#12296 - CHECKSUM TABLE reports 0 for the table
  The test result.
mysql-test/t/myisam.test:
  Bug#12296 - CHECKSUM TABLE reports 0 for the table
  The test case.
parent 6318e449
......@@ -595,3 +595,17 @@ show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a A 8 NULL NULL YES BTREE
drop table t1;
create table t1 (c1 int);
insert into t1 values (1),(2),(3),(4);
checksum table t1;
Table Checksum
test.t1 149057747
delete from t1 where c1 = 1;
create table t2 as select * from t1;
checksum table t1;
Table Checksum
test.t1 984116287
checksum table t2;
Table Checksum
test.t2 984116287
drop table t1, t2;
......@@ -575,4 +575,19 @@ show keys from t1;
drop table t1;
#
# Bug#12296 - CHECKSUM TABLE reports 0 for the table
# This happened if the first record was marked as deleted.
#
create table t1 (c1 int);
insert into t1 values (1),(2),(3),(4);
checksum table t1;
delete from t1 where c1 = 1;
create table t2 as select * from t1;
# The following returns 0 with the bug in place.
checksum table t1;
# The above should give the same number as the following.
checksum table t2;
drop table t1, t2;
# End of 4.1 tests
......@@ -3745,9 +3745,16 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
protocol->store_null();
else
{
while (!t->file->rnd_next(t->record[0]))
for (;;)
{
ha_checksum row_crc= 0;
int error= t->file->rnd_next(t->record[0]);
if (unlikely(error))
{
if (error == HA_ERR_RECORD_DELETED)
continue;
break;
}
if (t->record[0] != (byte*) t->field[0]->ptr)
row_crc= my_checksum(row_crc, t->record[0],
((byte*) t->field[0]->ptr) - t->record[0]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment