Parameter · Error Handling
exit_on_error
Terminate session on any error.
- Default:
off - Type: bool
- Applies: Session (any user)
In plain words
Normally an error aborts only the current statement (or transaction) and the session stays connected. With exit_on_error = on, any error ends the whole session, as if the connection had been cut.
Handy for scripts that must stop at the first problem; surprising almost everywhere else.
For DBAs and operators
Errors are promoted to FATAL, the backend exits and the client sees the connection close (verified on 18.6):
FATAL: division by zero
The promotion happens when the error is raised, so it applies even inside a PL/pgSQL EXCEPTION block or a driver savepoint: the handler never runs. Do not enable it for applications that rely on retrying serialization failures or catching errors.
Any user can set it per session (SET exit_on_error = on) or per role/database. For psql scripts, \set ON_ERROR_STOP on or psql -v ON_ERROR_STOP=1 is usually a better tool: it stops the script without killing the server session from the server side.
Not related to server crashes; see restart_after_crash for those.
How to change it
Any user can change it for their session with SET.