When I update 5.7 to 6.0 show only this error:
user warning: Duplicate entry '0-0' for key 1 query: ALTER TABLE drupal_locales_target ADD PRIMARY KEY (language, lid, plural) in C:\Program Files\VertrigoServ\www\includes\database.mysql-common.inc on line 374.

Failed: ALTER TABLE {locales_target} ADD PRIMARY KEY (language, lid, plural)

In the BD I see that in drupal_locales_target I have almost 55 rows with lid = 0.

CommentFileSizeAuthor
#13 locales-target.patch1.31 KBcatch
#12 locales_target.patch822 bytescatch
upgrade.jpg73.59 KBint

Comments

int’s picture

Category: bug » support

I see that this problem is from 5.7.

How to fix this? Just delete lid=0? Or is better to delete pt language and add again..

int’s picture

Status: Active » Closed (fixed)
yraffah’s picture

I have the same problem, how is this fixed?

int’s picture

delete all lid=0 in {locales_target}. and make the alter manual.

tcconway’s picture

Hi.
I too have this issue. Yet, my {locales_target} has no records.
Any thoughts on what I could do to resolve?
Thanks!

ryooki’s picture

how does one do this manually? I tried putting ALTER TABLE {locales_target} ADD PRIMARY KEY (language, lid, plural) in the SQL window, and I get a 1064 syntax error. I tried to make the lid column the primary key - which helped me find all the duplicates so I could delete them. However, making language or plural the primary key will drop lid from being the primary key. Any advice on what I'm doing wrong & what I need to do?

int’s picture

ryooki - change the {} with the real name of the tables.

ryosaeba’s picture

I've the same problem, but my error is

user warning: Duplicate entry '636-0' for key 1 query: ALTER TABLE locales_target ADD PRIMARY KEY (language, lid, plural) in /Applications/MAMP/htdocs/walterfantauzzi/includes/database.mysql-common.inc on line 374.

How I can do?

TheRec’s picture

Version: 6.0 » 6.12
Status: Closed (fixed) » Active

I get the same error, upgrading from 5.18 :

user warning: Duplicate entry '482-0' for key 1 query: ALTER TABLE locales_target ADD PRIMARY KEY (language, lid, plural) in /includes/database.mysql-common.inc on line 374.

Now, the odd part is that if I execute this SQL statement in PHPMyAdmin right after the update.php has finished to run for the first time (during the upgrade procedure), it works, without any error and the primary key is set as those three fields. So I have no idea why it fails when it is used in update.php.

dww’s picture

Component: update.module » locale.module

I know it's confusing, but "update.module" is for the part of core (added in 6.x) that checks for available updates to your modules and themes. You're talking about update.php, which is the "update system" component...

However, more specifically, this is a problem with the locale module's DB updates, so that'd be an even more appropriate place to get help...

hass’s picture

Category: support » bug
catch’s picture

Version: 6.12 » 6.x-dev
Status: Active » Needs review
StatusFileSize
new822 bytes

I'm getting this as well.
Marked #345852: update_6043: Duplicate entry warning when adding primary key to locales_target and #237715: D5 upgrade: ALTER TABLE locales_target fails as duplicate.

Patch uses ALTER IGNORE TABLE - which will delete the duplicate records while making the new index.

ALTER IGNORE is MySQL specific - however I'm not sure if postgres will just ignore the keyword (in which case no worse off than now), or throw a syntax error - but this needs to be checked before commit.

catch’s picture

StatusFileSize
new1.31 KB

Added check for pgsql, which falls back to current behaviour.

masipila’s picture

I had the same problem and I can confirm that the patch in comment #13 worked.

Background information:

  • I am running MySQL
  • Upgrading from D5.20 to D6.14
  • SELECT * FROM drupal_locales_target where lid = 0 showed that there were more than 3600 rows with lid = 0 in the table before upgrading
  • Manually deleting the entries with lid=0 before or after update.php did not help - the original ALTER query (shipped with D6.14) did not work, there were some other duplicate values as well
  • Patching system.install so that it uses ALTER IGNORE for MySQL solved the problem - or at least update.php now runs without errors.
int’s picture

Status: Needs review » Reviewed & tested by the community
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Hm, Drupal strives to keep your data intact. Let's consider that:

1. The lid = 0 rows will not be possible to pair with the source strings (lid is the source string ID), so we should be safe dropping those.

2. Other duplicate issues though come from previous import problems (I bet files with bad plural forms), and we have the source string ID, but have a bad plural ID for it. It would be good to have some sampling of problematic databases to see the duplicate entries, before deciding to throw this data away.

We could also say that plural translations are relatively small amounts of data, and just live with some of them being lost, but it would be good to see some actual data samples first to be able to decide.

int’s picture

I think that upgrading from D5 to D6 is normal to miss lots of translated strings, the administrator will have to update with the most up-to-date D6 translation.

masipila’s picture

@Gábor Hojtsy: I'll be glad to provdie you samples from my database. What exactly do want?

-Markus

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

I'm going to close this, since it's been three years without activity and deals with upgrade from 5.x.