exit_on_error
A server parameter determining whether a session should be terminated if an error occurs
exit_on_error
is a configuration parameter determining whether a session should be terminated if an error occurs.
exit_on_error
was added in PostgreSQL 7.4.
Default value
Default value for exit_on_error
is: off
.
Usage
By default, only FATAL
errors will terminate a session. However, if exit_on_error
is set to o
n, any error will result in the session being terminated.
However in some circumstances, such as loading SQL from a script, it may be desirable to ensure processing is halted if an error occurs, to prevent potentially bad data being loaded.
Change history
- PostgreSQL 9.1
- changed to a documented setting (commit 5ffaa900)
- PostgreSQL 7.4
- added (commit 4df52b28)
Examples
Usage demonstration for exit_on_error
in a psql
session:
postgres=# SELECT 1 FROM foo; ERROR: relation "foo" does not exist LINE 1: SELECT 1 FROM foo; ^ postgres=# SET exit_on_error TO on; SET postgres=# SELECT 1 FROM foo; FATAL: relation "foo" does not exist LINE 1: SELECT 1 FROM foo; ^ server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Succeeded.
References
- PostgreSQL documentation: exit_on_error