1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +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:
Daniel Black
2016-03-18 11:50:41 +11:00
committed by Sergei Golubchik
parent 8b94aec11a
commit 51a66299f3
3 changed files with 34 additions and 1 deletions

View File

@ -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;
}