public inbox for [email protected]
help / color / mirror / Atom feedFrom: Robert Haas <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: psql's ON_ERROR_STOP is misdocumented
Date: Mon, 13 Jun 2011 11:01:39 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On Thu, May 5, 2011 at 11:20 AM, Tom Lane <[email protected]> wrote:
> The documentation for ON_ERROR_STOP states, or at least implies by
> omission, that it only affects the behavior in non-interactive scripts:
>
> By default, if non-interactive scripts encounter an error, such
> as a malformed SQL command or internal meta-command, processing
> continues. This has been the traditional behavior of psql but it
> is sometimes not desirable. If this variable is set, script
> processing will immediately terminate. If the script was called
> from another script it will terminate in the same fashion. If
> the outermost script was not called from an interactive psql
> session but rather using the -f option, psql will return error
> code 3, to distinguish this case from fatal error conditions
> (error code 1).
>
> However, it is easily proven that it *does* affect interactive commands;
> just try two commands on one line:
>
> regression=# select 1/0; select 2;
> ERROR: division by zero
> ?column?
> ----------
> 2
> (1 row)
>
> regression=# \set ON_ERROR_STOP 1
> regression=# select 1/0; select 2;
> ERROR: division by zero
> regression=#
>
> Can we get the docs changed to reflect reality?
Here's an attempt at some suitable word-smithing.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
[application/octet-stream] on-error-stop.patch (1.9K, 2-on-error-stop.patch)
download | inline diff:
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index eaf901d..d77a1aa 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -2770,18 +2770,16 @@ bar
<term><varname>ON_ERROR_STOP</varname></term>
<listitem>
<para>
- By default, if non-interactive scripts encounter an error, such
- as a malformed <acronym>SQL</acronym> command or internal
- meta-command, processing continues. This has been the
- traditional behavior of <application>psql</application> but it
- is sometimes not desirable. If this variable is set, script
- processing will immediately terminate. If the script was called
- from another script it will terminate in the same fashion. If
- the outermost script was not called from an interactive
- <application>psql</application> session but rather using the
- <option>-f</option> option, <application>psql</application> will
- return error code 3, to distinguish this case from fatal error
- conditions (error code 1).
+ By default, command processing continues after an error. When this
+ variale is set, it will instead stop immediately. In interactive mode,
+ <application>psql</application> will return to the command prompt;
+ otherwise, <application>psql</application> will exit, returning
+ error code 3 to distinguish this case from fatal error
+ conditions, which are reported using error code 1. In either case,
+ any currently running scripts (the toplevel script, if any, and any
+ other scripts which it may have in invoked) will be terminated
+ immediately. If the toplevel command string contained multiple SQL
+ commands, processing will stop with the current command.
</para>
</listitem>
</varlistentry>
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: psql's ON_ERROR_STOP is misdocumented
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox