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

WordPress Trac noreply at wordpress.org
Thu Feb 7 13:53:04 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:  General            |     Version:  2.8.1
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |
-------------------------------+-----------------------------

Comment (by charlestonsw):

 WP3.5.1 running WPMU is having the same issue.

 Here is the error after a recent plugin activation:
 WordPress database error Too many keys specified; max 64 keys allowed for
 query ALTER TABLE wp_2_store_locator ADD INDEX (sl_store) made by require
 ('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-
 config.php'), require_once('wp-settings.php'), include_once('/plugins
 /store-locator-le/store-locator-le.php'),
 wpCSL_plugin__slplus->__construct, call_user_func_array,
 SLPlus_Activate::update, SLPlus_Activate->install_main_table,
 SLPlus_Activate->dbupdater, dbDelta


 Here is the dbDelta structure from my plugin:
                 $sql = "CREATE TABLE $table_name (
                         sl_id mediumint(8) unsigned NOT NULL
 auto_increment,
                         sl_store varchar(255) NULL,
                         sl_address varchar(255) NULL,
                         sl_address2 varchar(255) NULL,
                         sl_city varchar(255) NULL,
                         sl_state varchar(255) NULL,
                         sl_zip varchar(255) NULL,
                         sl_country varchar(255) NULL,
                         sl_latitude varchar(255) NULL,
                         sl_longitude varchar(255) NULL,
                         sl_tags mediumtext NULL,
                         sl_description text NULL,
                         sl_email varchar(255) NULL,
                         sl_url varchar(255) NULL,
                         sl_hours varchar(255) NULL,
                         sl_phone varchar(255) NULL,
                         sl_fax varchar(255) NULL,
                         sl_image varchar(255) NULL,
                         sl_private varchar(1) NULL,
                         sl_neat_title varchar(255) NULL,
                         sl_linked_postid int NULL,
                         sl_pages_url varchar(255) NULL,
                         sl_pages_on varchar(1) NULL,
                         sl_option_value longtext NULL,
                         sl_lastupdated  timestamp NOT NULL default
 current_timestamp,
                         PRIMARY KEY  (sl_id),
                         INDEX (sl_store),
                         INDEX (sl_longitude),
                         INDEX (sl_latitude)
                         )
                         $charset_collate
                         ";
 dbDelta($sql)



 The table now has a number of duplicate indexes:

 sl_store
 sl_store_2
 sl_store_3
 ...
 sl_store_21

 sl_latitude
 sl_latitude_2
 ...
 sl_latitude_21

 sl_longitude
 sl_longitude_2
 ...
 sl_longitude_21


 Am I using dbDelta incorrectly or is this still a known issue?  Any
 workarounds?

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


More information about the wp-trac mailing list