psql: ON_ERROR_STOP command-line flag for scripts

From: Mike Toews <mwtoews(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: psql: ON_ERROR_STOP command-line flag for scripts
Date: 2010-06-07 16:32:41
Message-ID: AANLkTikeVP0_qA-AOb3KSNaZG4fwNe1Wh5Ls5aAsGVa6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hey hackers,

I routinely run SQL scripts using pgsql -f myscript.sql. If there is
an error mid-way in a large script file, due to the default
ON_ERROR_STOP=0, I see repeated "ERROR:  current transaction is
aborted, commands ignored until end of transaction block" until the
end of the script. Often the error is buried at the top of the output
and the following commands are meaningless or misleading messages with
a last ROLLBACK at the bottom. This is particular relevant to new
PostGIS users running postgis.sql that missed a step somewhere.

I know I can either embed a non-SQL command in the SQL file or add
--set ON_ERROR_STOP =1 to the command arguments, however I'd like a
simpler command interface (just like there is -q / --quiet for QUIET).
Could I suggest a new command-line option -r / --on-error-stop for
psql? I have limited programming with C, should I bother submitting a
patch, or is someone else eager?

Thanks for your consideration.

-Mike

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Weimer 2010-06-07 16:39:45 Re: [HACKERS] Invalid YAML output from EXPLAIN
Previous Message Matteo Beccati 2010-06-07 16:21:37 Re: Re: Mailing list archives (was Re: [HACKERS] mailing list archiver chewing patches)