summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/myisam.result4
-rw-r--r--mysql-test/t/myisam.test2
-rw-r--r--sql/sql_table.cc29
3 files changed, 34 insertions, 1 deletions
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 13508716e0f..f3c845756f5 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -603,6 +603,10 @@ test.t2 3442722830
test.t3 NULL
Warnings:
Error 1146 Table 'test.t3' doesn't exist
+alter table t1 add d int default 30, add e bigint default 300000, add f decimal(30) default 442;
+checksum table t2;
+Table Checksum
+test.t2 3442722830
drop table t1,t2;
create table t1 (a int, key (a));
show keys from t1;
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 9ac49a9063d..4db7c279e82 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -552,6 +552,8 @@ insert t2 select * from t1;
checksum table t1, t2, t3 quick;
checksum table t1, t2, t3;
checksum table t1, t2, t3 extended;
+alter table t1 add d int default 30, add e bigint default 300000, add f decimal(30) default 442;
+checksum table t2;
#show table status;
drop table t1,t2;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 9542b6b54fe..1a7e55ab1d4 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -9789,6 +9789,8 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
row_crc= my_checksum(row_crc, t->record[0], t->s->null_bytes);
}
+ uchar *checksum_start= NULL;
+ size_t checksum_length= 0;
for (uint i= 0; i < t->s->fields; i++ )
{
Field *f= t->field[i];
@@ -9806,6 +9808,12 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_BIT:
{
+ if (checksum_start)
+ {
+ row_crc= my_checksum(row_crc, checksum_start, checksum_length);
+ checksum_start= NULL;
+ checksum_length= 0;
+ }
String tmp;
f->val_str(&tmp);
row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(),
@@ -9813,10 +9821,29 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
break;
}
default:
- row_crc= my_checksum(row_crc, f->ptr, f->pack_length());
+ if (checksum_start)
+ {
+ if (checksum_start + checksum_length == f->ptr)
+ {
+ checksum_length+= f->pack_length();
+ }
+ else
+ {
+ row_crc= my_checksum(row_crc, checksum_start, checksum_length);
+ checksum_start= NULL;
+ checksum_length= 0;
+ }
+ }
+ else
+ {
+ checksum_start= f->ptr;
+ checksum_length= f->pack_length();
+ }
break;
}
}
+ if (checksum_start)
+ row_crc= my_checksum(row_crc, checksum_start, checksum_length);
crc+= row_crc;
}