summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-04-29 18:39:18 +0200
committerSergei Golubchik <serg@mariadb.org>2016-04-29 18:41:00 +0200
commit4f1c81de2875cbce4180e152d12a8a1df60c717a (patch)
tree00bd31fd9a815093a65c9826ef7168d906d4ec5a /sql
parentaed1485b9936f18d050a0489520bc0144f51ade5 (diff)
downloadmariadb-git-4f1c81de2875cbce4180e152d12a8a1df60c717a.tar.gz
after-merge: simplify, fix a bug
* simplify the code at default: label * bugfix: flush the checksum for NULL fields (perfschema.checksum was failing) * cleanup: put repeated code into a function
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_table.cc45
1 files changed, 20 insertions, 25 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 50ddb782e1e..758757ea7dd 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -9668,6 +9668,18 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy)
}
+static void flush_checksum(ha_checksum *row_crc, uchar **checksum_start,
+ size_t *checksum_length)
+{
+ if (*checksum_start)
+ {
+ *row_crc= my_checksum(*row_crc, *checksum_start, *checksum_length);
+ *checksum_start= NULL;
+ *checksum_length= 0;
+ }
+}
+
+
bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
HA_CHECK_OPT *check_opt)
{
@@ -9796,7 +9808,10 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
Field *f= t->field[i];
if (! thd->variables.old_mode && f->is_real_null(0))
+ {
+ flush_checksum(&row_crc, &checksum_start, &checksum_length);
continue;
+ }
/*
BLOB and VARCHAR have pointers in their field, we must convert
to string; GEOMETRY is implemented on top of BLOB.
@@ -9808,12 +9823,7 @@ 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;
- }
+ flush_checksum(&row_crc, &checksum_start, &checksum_length);
String tmp;
f->val_str(&tmp);
row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(),
@@ -9821,29 +9831,14 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
break;
}
default:
- 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= f->ptr;
- checksum_length= f->pack_length();
- }
- }
- else
- {
+ if (!checksum_start)
checksum_start= f->ptr;
- checksum_length= f->pack_length();
- }
+ DBUG_ASSERT(checksum_start + checksum_length == f->ptr);
+ checksum_length+= f->pack_length();
break;
}
}
- if (checksum_start)
- row_crc= my_checksum(row_crc, checksum_start, checksum_length);
+ flush_checksum(&row_crc, &checksum_start, &checksum_length);
crc+= row_crc;
}