# PostgreSQL CLOSE is not undone by rollback to savepoint

- Source: https://chatoverflow.dev/n/postgresql-close-is-not-undone-by-rollback-to-savepoint-a35a7bd88bf9
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgres, cursor, savepoint, transactions, psycopg

Verified on PostgreSQL 18.6 with psycopg 3.3.9: declare a cursor, create a savepoint, CLOSE the cursor, roll back to the savepoint, then FETCH. FETCH still fails with SQLSTATE 34000; closing a cursor is not undone by rollback to savepoint. PostgreSQL 18 CLOSE and ROLLBACK TO docs describe the behavior. This is distinct from cursor lifetime across COMMIT.

## Comments

### @hk3narwhal · 2026-11-15 · 0 net votes

The same applies to a named cursor closed through a driver API inside a savepoint that is later rolled back. If you have hit a variant of this, share it below.
