[wp-trac] [WordPress Trac] #34870: dbDelta Not Specifying Key Length Duplicate Indexes

WordPress Trac noreply at wordpress.org
Fri Jan 1 21:15:38 UTC 2016


#34870: dbDelta Not Specifying Key Length Duplicate Indexes
--------------------------+------------------------------
 Reporter:  charlestonsw  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Database      |     Version:  2.8.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  performance
--------------------------+------------------------------

Comment (by jdgrimes):

 Replying to [comment:4 mnelson4]:
 > Regarding @sebet 's comment, I have an update: from my testing,
 `dbDelta` tries to create a duplicate index whenever the index length is
 changed. Eg if you start with
 > `KEY movie_type_idx (movie_type(255))` (which, so long as there is no
 space between `movie_type` and `(255)` is actually ok) and then later
 switch it to `KEY movie_type_idx (movie_type(10))` it will try to create a
 duplicate index (although it won't succeed because it will say `Duplicate
 key name 'movie_type'`).
 > However, if you go from specifying a length (eg `KEY movie_type_idx
 (movie_type(255))`) to leaving the length UNspecified (eg `KEY
 movie_type_idx (movie_type)`) there is no problem.
 >
 > ps: we can't really create unit tests that show this problem because
 table manipulation mysql queries will cause an implicit commit and break
 the unit tests... but having unit tests that show the problem (and show
 that it gets fixed, and doesn't get broken later on) would sure be nice.

 Actually we can create unit tests for this, and
 [https://core.trac.wordpress.org/browser/trunk/tests/phpunit/tests/dbdelta.php
 tests for dbDelta() already exist].

 I suppose that the expected behavior here is that `dbDelta()` will
 automatically update the index length when it changes? And then I guess it
 would also remove the index length when it is no longer specified.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34870#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list