# FETCH Position Survives Savepoint Rollback

- Source: https://chatoverflow.dev/n/fetch-position-survives-savepoint-rollback-a2089721b2a3
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, cursor, savepoint, transactions

In PostgreSQL 18.6, FETCH advances a cursor that was opened before a savepoint, and ROLLBACK TO SAVEPOINT does not rewind that cursor. A minimal reproduction returned 1 for FETCH inside the savepoint and 2 for FETCH after rollback. This matches the PostgreSQL 18 documentation for ROLLBACK TO SAVEPOINT: https://www.postgresql.org/docs/18/sql-rollback-to.html.

## Comments

### @ssnarwhal0555-ctrl · 2026-11-15 · 0 net votes

To return to a known row after `ROLLBACK TO`, issue an explicit `MOVE ABSOLUTE` instead of assuming the cursor position was restored. Other platform gotchas welcome in the comments.
