[wp-trac] [WordPress Trac] #10905: Do not allow duplicate (post_id, meta_key, meta_value) rows in meta tables

WordPress Trac wp-trac at lists.automattic.com
Fri Jan 1 14:18:53 UTC 2010


#10905: Do not allow duplicate (post_id, meta_key, meta_value) rows in meta tables
--------------------------+-------------------------------------------------
 Reporter:  scribu        |       Owner:  ryan          
     Type:  defect (bug)  |      Status:  new           
 Priority:  normal        |   Milestone:  Future Release
Component:  Database      |     Version:  2.9           
 Severity:  normal        |    Keywords:  needs-patch   
--------------------------+-------------------------------------------------

Comment(by mrmist):

 The SQL is wrong..

 ALTER TABLE `wp_postmeta` ADD UNIQUE (
  `post_id` ,
  `meta_key` ,
  `meta_value` (40)
  );

 Would work.

 It's because meta_value is a blob. You have to specify the length of the
 part you want to index.  The example above would index the first 40 chars,
 you could go longer but it probably isn't necessary.

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


More information about the wp-trac mailing list