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

WordPress Trac noreply at wordpress.org
Sun Dec 6 17:22:25 UTC 2015


#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          |     Focuses:
-------------------------------+-----------------------------

Comment (by charlestonsw):

 Is it time to decompose this ticket into its several components and close
 this "mother ticket"?

 The issues:


 * Missing spaces in the field list not creating indexes.

 Creates Index:
 {{{
  UNIQUE KEY reverse_pkey (term_taxonomy_id, object_id),
 }}}

 Does Not Create Index:
 {{{
  UNIQUE KEY reverse_pkey (term_taxonomy_id,object_id),
 }}}


 * Not specifying key length creates duplicate indexes.

 Duplicates:
 {{{
   KEY movie_type_idx (movie_type),
 }}}

 No Dupes:
 {{{
  KEY movie_type_idx (movie_type(255)),
 }}}


 * Case sensitive KEY keyword (must be upper) creating duplicate indexes:

 Duplicates:
 {{{
   key my_key ( slug ),
 }}}

 No Duplicates:
 {{{
   KEY MY_KEY ( SLUG ),
 }}}

 * Not specifying an index name creates duplicate indexes.

 Duplicates:

 {{{
   KEY (id ),
 }}}

 No Dupes:
 {{{
   KEY id ( id ),
 }}}


 * Double vs. single space after PRIMARY KEY not creating primary key.

 Works:
 {{{
  PRIMARY KEY my_pkey ( id ),
 }}}

 Does Not Work:
 {{{
  PRIMARY KEY  my_pkey ( id ),
 }}}


 * Double vs. single space after KEY creating duplicate indexes.

 Works:
 {{{
  PRIMARY KEY my_pkey ( id ),
 }}}

 Does Not Work:
 {{{
  PRIMARY KEY  my_pkey ( id ),
 }}}




 * Case sensitive KEY fields creating duplicate indexes:

 Duplicates:
 {{{
   KEY my_key ( slug ),
 }}}

 No Duplicates:
 {{{
   KEY MY_KEY ( SLUG ),
 }}}



 In 4.4, some of these appear to be fixed.


 How do we best decompose this issue into several tickets that address each
 corner case?

 In short , the dbDelta() function is (was?) very particular on how an SQL
 statement had to be crafted.  Rather than this "mega dbDelta" ticket,
 should we not break it into bite-sized chunks and close this one out and
 work through it's children?

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


More information about the wp-trac mailing list