[Commits] a6dec716376: MDEV-17085: CHECKSUM TABLE EXTENDED does not work correctly

Oleksandr Byelkin sanja at mariadb.com
Wed Jan 16 14:16:41 EET 2019


revision-id: a6dec71637631c34cd2462989959fcbe4e30604c (mariadb-5.5.62-18-ga6dec716376)
parent(s): dc42b3c4d9546153e2f0049393e3771e21551679
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2019-01-16 13:16:41 +0100
message:

MDEV-17085: CHECKSUM TABLE EXTENDED does not work correctly

The problem was in calculating of the mask to clear unused null bits in case of using full byte.

---
 mysql-test/r/row-checksum-old.result | 16 ++++++++++++++++
 mysql-test/r/row-checksum.result     | 16 ++++++++++++++++
 mysql-test/t/row-checksum.test       | 17 +++++++++++++++++
 sql/sql_table.cc                     |  4 +++-
 4 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/mysql-test/r/row-checksum-old.result b/mysql-test/r/row-checksum-old.result
index ef523463860..920c5dbe838 100644
--- a/mysql-test/r/row-checksum-old.result
+++ b/mysql-test/r/row-checksum-old.result
@@ -85,3 +85,19 @@ checksum table t1 extended;
 Table	Checksum
 test.t1	4108368782
 drop table t1;
+#
+# MDEV-17085: CHECKSUM TABLE EXTENDED does not work correctly
+#
+CREATE TABLE t1 ( c1 int NOT NULL, c2 int NOT NULL, c4 varchar(20), c5 varchar(20), c6 varchar(20), c7 varchar(20), c8 varchar(20), c9 varchar(20), c10 varchar(20), c11 varchar(20), c12 varchar(20), c13 varchar(20), c14 varchar(20), c15 varchar(20), c16 varchar(20), c19 int NOT NULL, c20 int NOT NULL, c21 varchar(20), c22 VARCHAR(20), c23 varchar(20));
+insert into t1 values (5,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,"dog",NULL,NULL);
+# Important is that checksum is different from following
+CHECKSUM TABLE t1 EXTENDED;
+Table	Checksum
+test.t1	2514025256
+UPDATE t1 SET c21='cat' WHERE  c1=5;
+# Important is that checksum is different from above
+CHECKSUM TABLE t1 EXTENDED;
+Table	Checksum
+test.t1	2326430205
+drop table t1;
+# End of 5.5 tests
diff --git a/mysql-test/r/row-checksum.result b/mysql-test/r/row-checksum.result
index fb8a1260a1d..0f8311b703a 100644
--- a/mysql-test/r/row-checksum.result
+++ b/mysql-test/r/row-checksum.result
@@ -85,3 +85,19 @@ checksum table t1 extended;
 Table	Checksum
 test.t1	3885665021
 drop table t1;
+#
+# MDEV-17085: CHECKSUM TABLE EXTENDED does not work correctly
+#
+CREATE TABLE t1 ( c1 int NOT NULL, c2 int NOT NULL, c4 varchar(20), c5 varchar(20), c6 varchar(20), c7 varchar(20), c8 varchar(20), c9 varchar(20), c10 varchar(20), c11 varchar(20), c12 varchar(20), c13 varchar(20), c14 varchar(20), c15 varchar(20), c16 varchar(20), c19 int NOT NULL, c20 int NOT NULL, c21 varchar(20), c22 VARCHAR(20), c23 varchar(20));
+insert into t1 values (5,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,"dog",NULL,NULL);
+# Important is that checksum is different from following
+CHECKSUM TABLE t1 EXTENDED;
+Table	Checksum
+test.t1	2514025256
+UPDATE t1 SET c21='cat' WHERE  c1=5;
+# Important is that checksum is different from above
+CHECKSUM TABLE t1 EXTENDED;
+Table	Checksum
+test.t1	2326430205
+drop table t1;
+# End of 5.5 tests
diff --git a/mysql-test/t/row-checksum.test b/mysql-test/t/row-checksum.test
index 920a2384aa8..6b79827d066 100644
--- a/mysql-test/t/row-checksum.test
+++ b/mysql-test/t/row-checksum.test
@@ -60,3 +60,20 @@ checksum table t1;
 checksum table t1 quick;
 checksum table t1 extended;
 drop table t1;
+
+--echo #
+--echo # MDEV-17085: CHECKSUM TABLE EXTENDED does not work correctly
+--echo #
+
+CREATE TABLE t1 ( c1 int NOT NULL, c2 int NOT NULL, c4 varchar(20), c5 varchar(20), c6 varchar(20), c7 varchar(20), c8 varchar(20), c9 varchar(20), c10 varchar(20), c11 varchar(20), c12 varchar(20), c13 varchar(20), c14 varchar(20), c15 varchar(20), c16 varchar(20), c19 int NOT NULL, c20 int NOT NULL, c21 varchar(20), c22 VARCHAR(20), c23 varchar(20));
+
+insert into t1 values (5,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,"dog",NULL,NULL);
+--echo # Important is that checksum is different from following
+CHECKSUM TABLE t1 EXTENDED;
+UPDATE t1 SET c21='cat' WHERE  c1=5;
+--echo # Important is that checksum is different from above
+CHECKSUM TABLE t1 EXTENDED;
+
+drop table t1;
+
+--echo # End of 5.5 tests
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1b83b513c2d..3fb678e3d74 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -7844,7 +7844,9 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
       {
 	/* calculating table's checksum */
 	ha_checksum crc= 0;
-        uchar null_mask=256 -  (1 << t->s->last_null_bit_pos);
+        uchar null_mask= (t->s->last_null_bit_pos ?
+                          (256 -  (1 << t->s->last_null_bit_pos)):
+                          0);
 
         t->use_all_columns();
 


More information about the commits mailing list