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 on, 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

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.

Categories

GUC configuration item

See also

restart_after_crash