diff options
author | Daniel Black <daniel.black@au.ibm.com> | 2016-03-18 11:50:41 +1100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-04-29 18:41:00 +0200 |
commit | 51a66299f3f34947baee2cf39fc9c25f01baab19 (patch) | |
tree | 6cfbea678689e63c78ed2478267e500e15b8e291 | |
parent | 8b94aec11af19fc711ed48f13410986814bc51a0 (diff) | |
download | mariadb-git-51a66299f3f34947baee2cf39fc9c25f01baab19.tar.gz |
CHECKSUM TABLE to calculate in multiple column chunks
Checksum implementations contain optimizations for calculating
checksums of larger blocks of memory.
This optimization calls my_checksum on a larger block of memory
rather than calling on multiple adjacent memory as its going though
the table columns for each table row.
-rw-r--r-- | mysql-test/r/myisam.result | 4 | ||||
-rw-r--r-- | mysql-test/t/myisam.test | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 29 |
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; } |