Commit 08394605 authored by unknown's avatar unknown

Bug#8841 - CHECKSUM TABLE is broken in MyISAM

There are (at least) two implementations of the checksum
computation. One is in MyISAM for the quick checksum. It
is executed on every row change. The other is in the
SQL layer for the extended checksum. It retrieves all rows
of a table via the respective storage engine.

In former MySQL versions varchars were stored with their 
maximum length, but now with their real length similar to
blobs.

This change had been forgotten to take care of in the
extended checksum calculation. Hence too much data was
checksumed. In MyISAM this change had been taken care of 
already. Only the real data is included in the checksum.

I changed mysql_checksum_table() so that it uses the
length information of true varchar fields instead
of the field length like in former varchar 
implementations.


mysql-test/r/innodb.result:
  Bug#8841 - CHECKSUM TABLE is broken in MyISAM
  Fixed test results.
mysql-test/r/myisam.result:
  Bug#8841 - CHECKSUM TABLE is broken in MyISAM
  Fixed test results.
sql/sql_table.cc:
  Bug#8841 - CHECKSUM TABLE is broken in MyISAM
  Changed mysql_checksum_table() so that it uses the
  length information of true varchar fields instead
  of the field length like in former varchar 
  implementations.
parent ae951e0f
...@@ -1457,16 +1457,16 @@ Error 1146 Table 'test.t4' doesn't exist ...@@ -1457,16 +1457,16 @@ Error 1146 Table 'test.t4' doesn't exist
checksum table t1, t2, t3, t4; checksum table t1, t2, t3, t4;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 2948697075
test.t2 3835700799 test.t2 2948697075
test.t3 3835700799 test.t3 2948697075
test.t4 NULL test.t4 NULL
Warnings: Warnings:
Error 1146 Table 'test.t4' doesn't exist Error 1146 Table 'test.t4' doesn't exist
checksum table t1, t2, t3, t4 extended; checksum table t1, t2, t3, t4 extended;
Table Checksum Table Checksum
test.t1 3092701434 test.t1 2948697075
test.t2 3835700799 test.t2 2948697075
test.t3 3835700799 test.t3 2948697075
test.t4 NULL test.t4 NULL
Warnings: Warnings:
Error 1146 Table 'test.t4' doesn't exist Error 1146 Table 'test.t4' doesn't exist
......
...@@ -531,14 +531,14 @@ Error 1146 Table 'test.t3' doesn't exist ...@@ -531,14 +531,14 @@ Error 1146 Table 'test.t3' doesn't exist
checksum table t1, t2, t3; checksum table t1, t2, t3;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 2948697075
test.t2 3092701434 test.t2 2948697075
test.t3 NULL test.t3 NULL
Warnings: Warnings:
Error 1146 Table 'test.t3' doesn't exist Error 1146 Table 'test.t3' doesn't exist
checksum table t1, t2, t3 extended; checksum table t1, t2, t3 extended;
Table Checksum Table Checksum
test.t1 3092701434 test.t1 2948697075
test.t2 3092701434 test.t2 2948697075
test.t3 NULL test.t3 NULL
Warnings: Warnings:
Error 1146 Table 'test.t3' doesn't exist Error 1146 Table 'test.t3' doesn't exist
......
...@@ -4218,7 +4218,8 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) ...@@ -4218,7 +4218,8 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
for (uint i= 0; i < t->s->fields; i++ ) for (uint i= 0; i < t->s->fields; i++ )
{ {
Field *f= t->field[i]; Field *f= t->field[i];
if (f->type() == FIELD_TYPE_BLOB) if ((f->type() == FIELD_TYPE_BLOB) ||
(f->type() == MYSQL_TYPE_VARCHAR))
{ {
String tmp; String tmp;
f->val_str(&tmp); f->val_str(&tmp);
......
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