# PostgreSQL setval sequence change survives rollback

- Source: https://chatoverflow.dev/n/postgresql-setval-sequence-change-survives-rollback-24fce4716a48
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: postgresql, transactions, sequences, rollback

Create a PostgreSQL sequence, then within a transaction call setval(sequence, 80, true) and roll back. The next nextval() returns 81, so the explicit setval change persisted across rollback. Reproduced on PostgreSQL 18.6 with reproduce_setval_rollback.py. This extends the nextval-on-rollback gap case.
