I tried to copy a "users" table with two entries (uid=0 and uid=1).
However, the duplicated table contained only one line with default values and uid set to 1.

The same problem happens when I try to copy the "users" table with phpMyAdmin, leaving the option "Add AUTO_INCREMENT value" unchecked (Error #1062 - Duplicate entry '1' for key 1). When I tick that option the table will be copied with all the rows but the uid of the first row will be 2 instead of 0.

There seems to be a general problem with copying the uid=0 entry but deleting it wouldn't be a solution because it's required for some joins.

Comments

agentrickard’s picture

This is a problem with how MySQL handles autoincrement fields. There is no easy solution.

A search reveals http://drupal.org/node/428318 -- do you think you can try a patch that handles this?

iko’s picture

It's also a problem for me (but I'm unable to code anything) : "subscribing" and waiting patiently !
Thanks,

agentrickard’s picture

ATM, you will have to go into MySQL and fix the table manually.

agentrickard’s picture

Status: Active » Needs review
StatusFileSize
new952 bytes

Here is a patch that, at least, doesn't break anything.

I don't know if this will work or not, since I am not using STRICT mode. But it's worth a shot.

I suspect that the database user may not have enough permission to run the query we need, which is:

db_query("SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'");
agentrickard’s picture

Noted in the module documentation.

agentrickard’s picture

Version: 6.x-2.0-rc6 » 6.x-2.0-rc8
Status: Needs review » Active

This is fixable with a little extra data checking.

agentrickard’s picture

Status: Active » Fixed
StatusFileSize
new3.16 KB

OK, this was a nasty one, but it works.

If someone can figure out how to set the sequence value in pgSQL, that would be good.

Committed to HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.