Problem/Motivation
Follow-up from weirdness pointed out in #3026290: PostgreSQL constraints are still not renamed properly on table renames.
The pgsql driver does not use the sequences table because it has a native way of doing so. The Connection::nextId method is used by batch and users to get and potentially set the next sequence for those respective tables. It does using the serial column's sequence in the sequences table.
The result is that users and batch (or anything in contrib that uses Connection::nextId) will increment the same sequence. This does not cause any data loss, but it looks weird.
Steps to reproduce (without any replication):
- Install Drupal 8
- Create an additional user
- Run a batch operation
- Create a third user
The third user will have uid 4, not 3 as expected.
Proposed resolution
Maybe nextId should take a new, optional argument of the table and column so that we use a new sequence. This would also require creating sequences for users or batch table. We don't run into the same issue for users as in other drivers because we can start or change the next value of sequences to not conflict with the anonymous user entry.
And maybe deprecate the sequences_values_seq sequence (but not the sequences table) in a change record.
Regardless this will require some database updates to change.
Remaining tasks
Figure out if this should be done. It's really odd when looking at how things work.
We added it in the Drupal 7 cycle when DBTNG was first added.
API changes
Maybe.
Data model changes
Yes.
Comments
Comment #7
daffie commentedThe problem of this issue will be fixed in #2665216: Deprecate Drupal\Core\Database\Connection::nextId() and the {sequences} table and schema.