From: Dmitry Lenev Date: February 2 2011 1:17pm Subject: bzr commit into mysql-5.1 branch (Dmitry.Lenev:3572) Bug#58650 List-Archive: http://lists.mysql.com/commits/130217 X-Bug: 58650 Message-Id: <20110202131801.5C38674047A@bandersnatch> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0602995359==" --===============0602995359== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/dlenev/src/bzr/mysql-5.1-58650/ based on revid:ole.john.aske@stripped 3572 Dmitry Lenev 2011-02-02 Fix for bug #58650 "Failing assertion: primary_key_no == -1 || primary_key_no == 0". Attempt to create InnoDB table with non-nullable column of geometry type having an unique key with length 12 on it and with some other candidate key led to server crash due to assertion failure in both non-debug and debug builds. The problem was that such a non-candidate key could have been sorted as the first key in table/.FRM, before any legit candidate keys. This resulted in assertion failure in InnoDB engine which assumes that primary key should either be the first key in table/.FRM or should not exist at all. The reason behind such an incorrect sorting was an wrong value of Create_field::key_length member for geometry field (which was set to its pack_length == 12) which confused code in mysql_prepare_create_table(), so it would skip marking such key as a key with partial segments. This patch fixes the problem by ensuring that this member gets the same value of Create_field::key_length member as for other blob fields (from which geometry field class is inherited), and as result unique keys on geometry fields are correctly marked as having partial segments. @ mysql-test/include/gis_keys.inc Added test case for bug #58650 "Failing assertion: primary_key_no == -1 || primary_key_no == 0". @ mysql-test/r/gis.result Added test case for bug #58650 "Failing assertion: primary_key_no == -1 || primary_key_no == 0". @ mysql-test/suite/innodb/r/innodb_gis.result Added test case for bug #58650 "Failing assertion: primary_key_no == -1 || primary_key_no == 0". @ mysql-test/suite/innodb_plugin/r/innodb_gis.result Added test case for bug #58650 "Failing assertion: primary_key_no == -1 || primary_key_no == 0". @ sql/field.cc Changed Create_field::create_length_to_internal_length() to correctly set Create_field::key_length member for geometry fields. Similar to the blob types key_length for such fields should be the same as length and not field's packed length (which is always 12 for geometry). As result of this change code handling table creation now always correctly identifies btree/unique keys on geometry fields as partial keys, so such keys can't be erroneously treated as candidate keys and sorted in keys array in .FRM before legit candidate keys. This fixes bug #58650 "Failing assertion: primary_key_no == -1 || primary_key_no == 0" in which incorrect candidate key sorting led to assertion failure in InnoDB code. modified: mysql-test/include/gis_keys.inc mysql-test/r/gis.result mysql-test/suite/innodb/r/innodb_gis.result mysql-test/suite/innodb_plugin/r/innodb_gis.result sql/field.cc === modified file 'mysql-test/include/gis_keys.inc' --- a/mysql-test/include/gis_keys.inc 2007-11-01 14:03:09 +0000 +++ b/mysql-test/include/gis_keys.inc 2011-02-02 13:17:48 +0000 @@ -44,3 +44,19 @@ SELECT COUNT(*) FROM t2 IGNORE INDEX(p) DROP TABLE t1, t2; --echo End of 5.0 tests + + +--echo # +--echo # Test for bug #58650 "Failing assertion: primary_key_no == -1 || +--echo # primary_key_no == 0". +--echo # +--disable_warnings +drop table if exists t1; +--enable_warnings +--echo # The minimal test case. +create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a)); +drop table t1; +--echo # The original test case. +create table t1 (a int not null, b linestring not null, unique key b (b(12))); +create unique index a on t1(a); +drop table t1; === modified file 'mysql-test/r/gis.result' --- a/mysql-test/r/gis.result 2011-01-12 13:02:41 +0000 +++ b/mysql-test/r/gis.result 2011-02-02 13:17:48 +0000 @@ -960,6 +960,18 @@ COUNT(*) 2 DROP TABLE t1, t2; End of 5.0 tests +# +# Test for bug #58650 "Failing assertion: primary_key_no == -1 || +# primary_key_no == 0". +# +drop table if exists t1; +# The minimal test case. +create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a)); +drop table t1; +# The original test case. +create table t1 (a int not null, b linestring not null, unique key b (b(12))); +create unique index a on t1(a); +drop table t1; create table `t1` (`col002` point)engine=myisam; insert into t1 values (),(),(); select min(`col002`) from t1 union select `col002` from t1; === modified file 'mysql-test/suite/innodb/r/innodb_gis.result' --- a/mysql-test/suite/innodb/r/innodb_gis.result 2010-06-03 09:50:32 +0000 +++ b/mysql-test/suite/innodb/r/innodb_gis.result 2011-02-02 13:17:48 +0000 @@ -585,5 +585,17 @@ COUNT(*) 2 DROP TABLE t1, t2; End of 5.0 tests +# +# Test for bug #58650 "Failing assertion: primary_key_no == -1 || +# primary_key_no == 0". +# +drop table if exists t1; +# The minimal test case. +create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a)); +drop table t1; +# The original test case. +create table t1 (a int not null, b linestring not null, unique key b (b(12))); +create unique index a on t1(a); +drop table t1; create table t1 (g geometry not null, spatial gk(g)) engine=innodb; ERROR HY000: The used table type doesn't support SPATIAL indexes === modified file 'mysql-test/suite/innodb_plugin/r/innodb_gis.result' --- a/mysql-test/suite/innodb_plugin/r/innodb_gis.result 2010-06-03 09:48:59 +0000 +++ b/mysql-test/suite/innodb_plugin/r/innodb_gis.result 2011-02-02 13:17:48 +0000 @@ -585,5 +585,17 @@ COUNT(*) 2 DROP TABLE t1, t2; End of 5.0 tests +# +# Test for bug #58650 "Failing assertion: primary_key_no == -1 || +# primary_key_no == 0". +# +drop table if exists t1; +# The minimal test case. +create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a)); +drop table t1; +# The original test case. +create table t1 (a int not null, b linestring not null, unique key b (b(12))); +create unique index a on t1(a); +drop table t1; create table t1 (g geometry not null, spatial gk(g)) engine=innodb; ERROR HY000: The used table type doesn't support SPATIAL indexes === modified file 'sql/field.cc' --- a/sql/field.cc 2010-12-28 23:47:05 +0000 +++ b/sql/field.cc 2011-02-02 13:17:48 +0000 @@ -9476,6 +9476,7 @@ void Create_field::create_length_to_inte case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_BLOB: + case MYSQL_TYPE_GEOMETRY: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: case MYSQL_TYPE_VARCHAR: --===============0602995359== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/dmitry.lenev@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: dmitry.lenev@stripped # target_branch: file:///home/dlenev/src/bzr/mysql-5.1-58650/ # testament_sha1: d832fd7d693f63e1ebd9b391ee94324b3a281bc2 # timestamp: 2011-02-02 16:18:01 +0300 # base_revision_id: ole.john.aske@stripped\ # 8ngficfn0a1358hw # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWWnlvJAABlZ/gEAQEABY5/// f6b8IL////RgDXL3w+jru73vKtaMutCu57Fz1rRXV68j3vc97PdtV6zlTXsdeEkhAk9NMij8jQR6 U00/TRQ9RoAZNAzKCShNKeNDQmmjKZoaiGmQBoGgADQ5gTE0GEyZMmRhME00yMTAEMAkJIKngU9I 9Rp6mmyJkNADQ0aAAaBFIhoIEwmJqZk1MmmpmymiZGmhoAaCSICNCYgTSfqaJ6jJkk8UeoDQ0AGj 13uqMWBhca79wSjDJvz7e77T+xxzxkgq13rBUi7qXPuld+OY6aBSnGA2nfrcH8ov2+h6S/UloEQk AsUzgIYcim+/Y+i7u2R1tuYpmIWTNTXH1Bplip72bXSEGBVhdvE2DQTrA/QOIF0+CH8+CfVL0gIY CIZoiI/2S98qQVfOkufun4kOW0puyUDvZ7MUYkxt/3iCMenjo2p12btsCaAcrvzC6ENnh9YRjc3a uJGLmGVRFb6gXgPfWFYXvfAGZF3+4Vi7+9gT3FfNsIvhXGFJtKFdAxUSDT8pivg4SDOxwl87r5EX euDX3wHUG3DiwwuDjAwtbSXIpoM48XhhML4ftnCg9pUzAl/yEVMLsUWiXGAFgJuANQepnUPnIM2a RZDWve71F6oqoqgnNDXSTWz6GOkMRpVvAkDBcmBstQgAwHORUMQMhFStbnjmsnfwmeNjprjCoFRI +eq1/Q6OaDSPuEYbS192TVVHS89mb13PhO+5F3mZ5SQewE+whwF804wmZNDBDAlufVd0AVg4ggSh 4eepDWHcGKqYbICwNG0DknCwoDIA8qIwnU99ZxLuiirgqgtKEcIjNa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