Re: PSQL: "\set ECHO all" doesn't work with "\o" - Mailing list pgsql-sql

From David G. Johnston
Subject Re: PSQL: "\set ECHO all" doesn't work with "\o"
Date
Msg-id CAKFQuwaLF=nuUsn-0u9qqeneyqX4OGDUasC85xbWQqyaiGEmjg@mail.gmail.com
Whole thread Raw
In response to PSQL: "\set ECHO all" doesn't work with "\o"  (Alberto Benini <alberto.benini@tasgroup.eu>)
List pgsql-sql
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.

pgsql-sql by date:

Previous
From: Alberto Benini
Date:
Subject: PSQL: "\set ECHO all" doesn't work with "\o"
Next
From: Shaozhong SHI
Date:
Subject: Is there any function for calculating angle between 2 line segments in 3D?