MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Kristofer Pettersson Date:September 21 2009 9:58am
Subject:bzr commit into mysql-5.1-bugteam branch (kristofer.pettersson:3117)
Bug#35570
View as plain text  
#At file:///Users/thek/Development/51-bug35570/ based on revid:joro@stripped

 3117 Kristofer Pettersson	2009-09-21
      Fix for BUG#35570 "CHECKSUM TABLE unreliable if LINESTRING field (same content/ differen
      checksum)"
      
      The problem was that checksum of GEOMETRY type used memory addresses
      in the computation, making it un-repeatable thus useless.
      (This patch is a backport from 6.0 branch)
     @ mysql-test/r/myisam.result
        test case for bug35570 that same tables give same checksums
     @ mysql-test/t/myisam.test
        test case for bug35570 that same tables give same checksums
     @ sql/sql_table.cc
        Type GEOMETRY is implemented on top of type BLOB, so, just like for BLOB,
        its 'field' contains pointers which it does not make sense to include in
        the checksum; it rather has to be converted to a string and then we can
        compute the checksum.

    modified:
      mysql-test/r/myisam.result
      mysql-test/t/myisam.test
      sql/sql_table.cc
=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result	2009-04-30 11:03:44 +0000
+++ b/mysql-test/r/myisam.result	2009-09-21 09:58:15 +0000
@@ -2252,4 +2252,23 @@ h+0	d + 0	e	g + 0
 1	1	3	0
 1	1	4	0
 DROP TABLE t1;
+#
+# Test of BUG#35570 CHECKSUM TABLE unreliable if LINESTRING field
+# (same content / differen checksum)
+#
+CREATE TABLE t1 (line LINESTRING NOT NULL) engine=myisam;
+INSERT INTO t1 VALUES (GeomFromText("POINT(0 0)"));
+checksum table t1;
+Table	Checksum
+test.t1	326284887
+CREATE TABLE t2 (line LINESTRING NOT NULL) engine=myisam;
+INSERT INTO t2 VALUES (GeomFromText("POINT(0 0)"));
+checksum table t2;
+Table	Checksum
+test.t2	326284887
+CREATE TABLE t3 select * from t1;
+checksum table t3;
+Table	Checksum
+test.t3	326284887
+drop table t1,t2,t3;
 End of 5.1 tests

=== modified file 'mysql-test/t/myisam.test'
--- a/mysql-test/t/myisam.test	2009-04-30 11:03:44 +0000
+++ b/mysql-test/t/myisam.test	2009-09-21 09:58:15 +0000
@@ -1503,5 +1503,20 @@ SELECT h+0, d + 0, e, g + 0 FROM t1;
 
 DROP TABLE t1;
 
+--echo #
+--echo # Test of BUG#35570 CHECKSUM TABLE unreliable if LINESTRING field
+--echo # (same content / differen checksum)
+--echo #
+
+CREATE TABLE t1 (line LINESTRING NOT NULL) engine=myisam;
+INSERT INTO t1 VALUES (GeomFromText("POINT(0 0)"));
+checksum table t1;
+CREATE TABLE t2 (line LINESTRING NOT NULL) engine=myisam;
+INSERT INTO t2 VALUES (GeomFromText("POINT(0 0)"));
+checksum table t2;
+CREATE TABLE t3 select * from t1;
+checksum table t3;
+drop table t1,t2,t3;
+
 --echo End of 5.1 tests
 

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-09-18 13:01:18 +0000
+++ b/sql/sql_table.cc	2009-09-21 09:58:15 +0000
@@ -7897,8 +7897,14 @@ bool mysql_checksum_table(THD *thd, TABL
 	    for (uint i= 0; i < t->s->fields; i++ )
 	    {
 	      Field *f= t->field[i];
-	      if ((f->type() == MYSQL_TYPE_BLOB) ||
-                  (f->type() == MYSQL_TYPE_VARCHAR))
+        enum_field_types field_type= f->type();
+        /*
+          BLOB and VARCHAR have pointers in their field, we must convert
+          to string; GEOMETRY is implemented on top of BLOB.
+        */
+        if ((field_type == MYSQL_TYPE_BLOB) ||
+            (field_type == MYSQL_TYPE_VARCHAR) ||
+            (field_type == MYSQL_TYPE_GEOMETRY))
 	      {
 		String tmp;
 		f->val_str(&tmp);


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1-bugteam branch (kristofer.pettersson:3117)Bug#35570Kristofer Pettersson21 Sep
  • Re: bzr commit into mysql-5.1-bugteam branch(kristofer.pettersson:3117) Bug#35570Guilhem Bichot21 Sep