From: Dmitry Lenev Date: February 15 2011 11:03am Subject: bzr commit into mysql-5.1 branch (Dmitry.Lenev:3591) Bug#11766714 List-Archive: http://lists.mysql.com/commits/131299 X-Bug: 11766714 Message-Id: <20110215110317.E7A18740673@bandersnatch> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1974843292==" --===============1974843292== 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-59888/ based on revid:georgi.kodinov@stripped 3591 Dmitry Lenev 2011-02-15 Fix for bug#11766714 (former bug @59888) "debug assertion when attempt to create spatial index on char > 31 bytes". Attempt to create spatial index on char field with length greater than 31 byte led to assertion failure on server compiled with safemutex support. The problem occurred in mi_create() function which was called to create a new version of table being altered. This function failed since it detected an attempt to create a spatial key on non-binary column and tried to return an error. On its error path it tried to unlock THR_LOCK_myisam mutex which has not been not locked at this point. Indeed such an incorrect behavior was caught by safemutex wrapper and caused assertion failure. This patch fixes the problem by ensuring that mi_create() doesn't releases THR_LOCK_myisam mutex on error path if it was not acquired. @ mysql-test/r/gis.result Added test for bug @59888 "debug assertion when attempt to create spatial index on char > 31 bytes". @ mysql-test/t/gis.test Added test for bug @59888 "debug assertion when attempt to create spatial index on char > 31 bytes". @ storage/myisam/mi_create.c Changed mi_create() not to release THR_LOCK_myisam mutex on error path if it was not acquired. modified: mysql-test/r/gis.result mysql-test/t/gis.test storage/myisam/mi_create.c === modified file 'mysql-test/r/gis.result' --- a/mysql-test/r/gis.result 2011-02-02 13:17:48 +0000 +++ b/mysql-test/r/gis.result 2011-02-15 11:03:05 +0000 @@ -1034,4 +1034,12 @@ p NULL NULL drop table t1; +# +# Test for bug #59888 "debug assertion when attempt to create spatial index +# on char > 31 bytes". +# +create table t1(a char(32) not null) engine=myisam; +create spatial index i on t1 (a); +ERROR HY000: Can't create table '#sql-temporary' (errno: 140) +drop table t1; End of 5.1 tests === modified file 'mysql-test/t/gis.test' --- a/mysql-test/t/gis.test 2011-01-14 20:56:09 +0000 +++ b/mysql-test/t/gis.test 2011-02-15 11:03:05 +0000 @@ -754,4 +754,16 @@ insert into t1 values (geomfromtext("poi select * from (select polygon(t1.a) as p from t1 order by t1.a) d; drop table t1; + +--echo # +--echo # Test for bug #59888 "debug assertion when attempt to create spatial index +--echo # on char > 31 bytes". +--echo # +create table t1(a char(32) not null) engine=myisam; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +create spatial index i on t1 (a); +drop table t1; + + --echo End of 5.1 tests === modified file 'storage/myisam/mi_create.c' --- a/storage/myisam/mi_create.c 2010-11-10 21:14:47 +0000 +++ b/storage/myisam/mi_create.c 2011-02-15 11:03:05 +0000 @@ -272,7 +272,7 @@ int mi_create(const char *name,uint keys keyseg->type != HA_KEYTYPE_VARBINARY2) { my_errno=HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } } keydef->keysegs+=sp_segs; @@ -281,7 +281,7 @@ int mi_create(const char *name,uint keys min_key_length_skip+=SPLEN*2*SPDIMS; #else my_errno= HA_ERR_UNSUPPORTED; - goto err; + goto err_no_lock; #endif /*HAVE_SPATIAL*/ } else if (keydef->flag & HA_FULLTEXT) @@ -297,7 +297,7 @@ int mi_create(const char *name,uint keys keyseg->type != HA_KEYTYPE_VARTEXT2) { my_errno=HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } if (!(keyseg->flag & HA_BLOB_PART) && (keyseg->type == HA_KEYTYPE_VARTEXT1 || @@ -422,7 +422,7 @@ int mi_create(const char *name,uint keys if (keydef->keysegs > MI_MAX_KEY_SEG) { my_errno=HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } /* key_segs may be 0 in the case when we only want to be able to @@ -447,7 +447,7 @@ int mi_create(const char *name,uint keys length >= MI_MAX_KEY_BUFF) { my_errno=HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } set_if_bigger(max_key_block_length,keydef->block_length); keydef->keylength= (uint16) key_length; @@ -494,7 +494,7 @@ int mi_create(const char *name,uint keys "indexes and/or unique constraints.", MYF(0), name + dirname_length(name)); my_errno= HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } bmove(share.state.header.file_version,(uchar*) myisam_file_magic,4); @@ -827,12 +827,14 @@ int mi_create(const char *name,uint keys errpos=0; pthread_mutex_unlock(&THR_LOCK_myisam); if (my_close(file,MYF(0))) - goto err; + goto err_no_lock; my_free((char*) rec_per_key_part,MYF(0)); DBUG_RETURN(0); err: pthread_mutex_unlock(&THR_LOCK_myisam); + +err_no_lock: save_errno=my_errno; switch (errpos) { case 3: --===============1974843292== 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-59888/ # testament_sha1: f3018dce1d184acaef8379187aee6a3b495f2605 # timestamp: 2011-02-15 14:03:17 +0300 # base_revision_id: georgi.kodinov@stripped\ # 9n20d3h8s4hug4jd # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWb522WkABC9/gFEQEABY8/// f22UL7////BgCUr4zH3DkgC7b729Ke93QvbT2e93XXK9tCSRCaZJmptNNMqfo0TaEybVT2qP1NqR hD1BtI0CSQIaaanommlPJMJNlM1PUyGgAyGQ0xBxkyaaYTIyBgRiaMEYQaNMAAgkSRTxRtT1AeoA GhkAAA0AAGgilNBJjJpT8lPCT9Keo2pk0eoD1AGjQAAJIgTQk9DSan6I00NEj9Kep5GoyG1NAD1H qD4T4Mhy908ynqbVCzCYaz1+lX66SWTVKk7F/ufI977MmAJdjjorHCR+vtcAf3Hw1MiIpxZ1xPdn /G9z+1dz9OE7otIzn/X7yT02ISiSynfEE4fwaqi7M6W5eq4pmYZkmYNX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