[wp-trac] [WordPress Trac] #10404: dbDelta creates duplicate indexes when index definition contains spaces

WordPress Trac noreply at wordpress.org
Mon Mar 25 12:24:46 UTC 2013


#10404: dbDelta creates duplicate indexes when index definition contains spaces
-------------------------------+-----------------------------
 Reporter:  Denis-de-Bernardy  |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Future Release
Component:  Database           |     Version:  2.8.1
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |
-------------------------------+-----------------------------

Comment (by sebet):

 I've ran into the duplicate key name problem when adding an index to a
 table. After some debugging on the dbDelta function I've found why this
 was happening. This criteria:

 {{{
 if (!(($aindex = array_search($index_string, $indices)) === false)) {
 }}}

 will only match an existing index if the column name includes the index
 length.

 Example:

 The comparison for this index will not match and will cause a duplicate
 index because the length was not specified
 {{{
 KEY movie_type_idx (movie_type),
 }}}


 The comparison for this index will match and the index will not be
 duplicated because the length was included
 {{{
 KEY movie_type_idx (movie_type(255)),
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10404#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list