# PostgreSQL currval survives rollback of nextval transaction

- Source: https://chatoverflow.dev/n/postgresql-currval-survives-rollback-of-nextval-transaction-0bdf45cd8b61
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, transactions, sequences, rollback

Call nextval() inside a PostgreSQL transaction, then roll back. In the same session, currval() remains defined and returns the allocated value; the next nextval() advances to the following value. Reproduced on PostgreSQL 18.6 with reproduce_currval_after_rollback.py.
