system.install creates the role table with the "rid" field of type "serial" which automatically creates a sequence called "{role}_serial_rid_seq" and sets the default value for the field to "nextval('{role}_serial_rid_seq')".
Howver, the system.install script then goes on to insert two records, explicitly setting their "rid" values to DRUPAL_ANONYMOUS_RID and DRUPAL_AUTHENTICATED_RID, without updating the sequence.
As a result, adding roles to a new install will fail twice before succeeding.
The fix is to update the sequence, setting currval to the greater of DRUPAL_ANONYMOUS_RID and DRUPAL_AUTHENTICATED_RID.
Patchfile attached.
Comment | File | Size | Author |
---|---|---|---|
#8 | system_install-postgres_seqs.patch | 1.36 KB | halcyonCorsair |
#2 | modules-system-system.install_0.patch | 457 bytes | pillarsdotnet |
modules-system-system.install.patch | 472 bytes | pillarsdotnet | |
Comments
Comment #1
pillarsdotnet CreditAttribution: pillarsdotnet commentedProbably should mention that this only affect postgresql users.
Not sure if the proper "Component" should be:
system.module
install system
postgresql database
Comment #2
pillarsdotnet CreditAttribution: pillarsdotnet commentedBah! Named the sequence wrong. Fixed and re-rolled the patch.
Comment #3
bdragon CreditAttribution: bdragon commentedhttp://drupal.org/node/174071 marked as duplicate.
Comment #4
pillarsdotnet CreditAttribution: pillarsdotnet commentedAdjust subject line.
Comment #5
drummCommitted to 5.x. Please look over Drupal 6.x, which may have this issue.
Comment #6
ned0r CreditAttribution: ned0r commented+ db_query("SELECT setval('{role}_rid_seq',".max(DRUPAL_ANONYMOUS_RID,DRUPAL_AUTHENTICATED_RID)."));");
should really be ...
+ db_query("SELECT setval('{role}_rid_seq',".max(DRUPAL_ANONYMOUS_RID,DRUPAL_AUTHENTICATED_RID).");");
i.e. you have one too many closing parens :-(
This makes stuff break in nasty ways :(
Comment #7
pillarsdotnet CreditAttribution: pillarsdotnet commentedned0r wrote:
You're right; sorry about that. Changing Status.
Comment #8
halcyonCorsair CreditAttribution: halcyonCorsair commentedAdjust subject, add patch.
If these sequences aren't updated then the attempt to insert a role or a user will fail.
Comment #9
Damien Tournoud CreditAttribution: Damien Tournoud commentedI don't believe this is needed anymore.