mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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.
This commit is contained in:
committed by
Sergei Golubchik
parent
8b94aec11a
commit
51a66299f3
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user