diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/sequence.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 28f85222647..b4ad19c0539 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -545,6 +545,13 @@ SequenceChangePersistence(Oid relid, char newrelpersistence) Buffer buf; HeapTupleData seqdatatuple; + /* + * ALTER SEQUENCE acquires this lock earlier. If we're processing an + * owned sequence for ALTER TABLE, lock now. Without the lock, we'd + * discard increments from nextval() calls (in other sessions) between + * this function's buffer unlock and this transaction's commit. + */ + LockRelationOid(relid, AccessExclusiveLock); init_sequence(relid, &elm, &seqrel); /* check the comment above nextval_internal()'s equivalent call. */ |