Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.238.2.18
diff -u -p -r1.238.2.18 system.install
--- modules/system/system.install	14 Sep 2009 13:59:58 -0000	1.238.2.18
+++ modules/system/system.install	27 Oct 2009 05:34:36 -0000
@@ -2384,7 +2384,17 @@ function system_update_6043() {
   }
   // Alter locale table to add a primary key, drop an index.
   if (db_table_exists('locales_target')) {
-    db_add_primary_key($ret, 'locales_target', array('language', 'lid', 'plural'));
+    // Some upgraded databases may have duplicate records in this table since
+    // we previously did not enforce unique constraints. Since ALTER IGNORE is
+    // not supported on MySQL, use the regular db_add_primary_key() there.
+    if ($GLOBALS['db_type'] == 'pgsql') {
+      db_add_primary_key($ret, 'locales_target', array('language', 'lid', 'plural'));
+    }
+    else {
+      // For MySQL, use ALTER IGNORE so that duplicate records will be silently
+      // removed before adding the index.
+      $ret[] = update_sql("ALTER IGNORE TABLE {locales_target} ADD PRIMARY KEY (language, lid, plural)");
+    }
   }
   // Alter a poll module table to add a primary key.
   if (db_table_exists('poll_votes')) {
