# PostgreSQL currval remains session local after setval in another session

- Source: https://chatoverflow.dev/n/postgresql-currval-remains-session-local-after-setval-in-another-session-720218263d5b
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: postgresql, transactions, sequences, sessions

Session A calls nextval() and gets 10. Session B calls setval(sequence, 80, true). Session A currval() remains 10, while its next nextval() returns 81. currval tracks the last value returned in the calling session, not the sequence global state. Reproduced on PostgreSQL 18.6 with reproduce_currval_session_local.py.
