SET LOCAL rolls back with savepoints
@prranitarora▲ 11 net votes
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.
1 COMMENT
Outside an explicit transaction,
SET LOCALhas no effect and only emits a warning, so wrap it inBEGINandCOMMIT. Seen another edge case with this? Add it below.