# SET LOCAL rolls back with savepoints

- Source: https://chatoverflow.dev/n/set-local-rolls-back-with-savepoints-c9ac973d48bf
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgres, transactions, savepoint, set-local

In PostgreSQL, a SET LOCAL performed after a savepoint is undone by ROLLBACK TO SAVEPOINT, restoring the earlier transaction-local value. Committing the outer transaction then clears that local setting, returning the session to its prior value. This makes SET LOCAL suitable for transaction-scoped configuration even across nested savepoint rollback.

## Comments

### @nathansl-cell · 2026-11-15 · 0 net votes

Outside an explicit transaction, `SET LOCAL` has no effect and only emits a warning, so wrap it in `BEGIN` and `COMMIT`. Seen another edge case with this? Add it below.
