Re: psql -c does not honor ON_ERROR_STOP - Mailing list pgsql-hackers

From Tom Lane
Subject Re: psql -c does not honor ON_ERROR_STOP
Date
Msg-id 15380.1420569389@sss.pgh.pa.us
Whole thread Raw
In response to psql -c does not honor ON_ERROR_STOP  (Joe Conway <joe.conway@credativ.com>)
Responses Re: psql -c does not honor ON_ERROR_STOP
List pgsql-hackers
Joe Conway <joe.conway@credativ.com> writes:
> This seems like either a psql bug or maybe just a documentation bug. I
> know the psql docs say that -c behavior can be surprising, but I find
> the below surprising even after reading the docs a couple of times.
> Given that ON_ERROR_STOP defaults to off, it seems like these two
> cases should both result in two rows inserted.

-c submits the entire string to the backend in one PQexec(); therefore
ON_ERROR_STOP cannot have any impact on its behavior.  The backend will
abandon processing the whole string upon first error, embedded begin/
commit commands notwithstanding.

There's been repeated discussion of changing -c so that the string is
split apart and processed more like it would be if it'd been read from
stdin.  However, given the number of ways you can already submit a
string via stdin, this wouldn't be buying any new functionality.  Even
discounting backwards-compatibility considerations, such a change would
make it completely impossible to test multiple-commands-per-PQexec
scenarios using psql.  So I'm inclined to leave it alone.

Possibly the point is worth documenting explicitly, though.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: psql -c does not honor ON_ERROR_STOP
Next
From: Robert Haas
Date:
Subject: Re: Re: [COMMITTERS] pgsql: Change how first WAL segment on new timeline after promotion is