agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedPSQL: "\set ECHO all" doesn't work with "\o"
2+ messages / 2 participants
[nested] [flat]
* PSQL: "\set ECHO all" doesn't work with "\o"
@ 2022-02-23 18:18 Alberto Benini <alberto.benini@tasgroup.eu>
2022-02-23 18:27 ` Re: PSQL: "\set ECHO all" doesn't work with "\o" David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Alberto Benini @ 2022-02-23 18:18 UTC (permalink / raw)
To: pgsql-sql@lists.postgresql.org; +Cc: cm <cm@tasgroup.eu>
Hi all,
I haven’t understand how to redirect SQL errors on output file.
Our goal is to have a psql script with:
\set ON_ERROR_STOP true
\set ECHO all
\o log/update.log;
\i update.sql;
..but in the log file we don’t see any sql error
KR,
Alberto
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: PSQL: "\set ECHO all" doesn't work with "\o"
2022-02-23 18:18 PSQL: "\set ECHO all" doesn't work with "\o" Alberto Benini <alberto.benini@tasgroup.eu>
@ 2022-02-23 18:27 ` David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: David G. Johnston @ 2022-02-23 18:27 UTC (permalink / raw)
To: Alberto Benini <alberto.benini@tasgroup.eu>; +Cc: pgsql-sql <pgsql-sql@lists.postgresql.org>; cm <cm@tasgroup.eu>
On Wed, Feb 23, 2022 at 11:18 AM Alberto Benini <alberto.benini@tasgroup.eu>
wrote:
> Hi all,
>
> I haven’t understand how to redirect SQL errors on output file.
>
>
>
> Our goal is to have a psql script with:
>
>
>
> \set ON_ERROR_STOP true
>
> \set ECHO all
>
> \o log/update.log;
>
> \i update.sql;
>
>
>
>
>
> ..but in the log file we don’t see any sql error
>
>
>
You need to do this in your shell, IIRC:
psql [...] --file update.sql > log/update.log 2>&1
That trying to do the same with the \o meta-command fails should not be
surprising - the documentation explicitly says:
“Query results” includes all tables [...] but not error messages."
David J.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-02-23 18:27 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 18:18 PSQL: "\set ECHO all" doesn't work with "\o" Alberto Benini <alberto.benini@tasgroup.eu>
2022-02-23 18:27 ` David G. Johnston <david.g.johnston@gmail.com>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox