Re: psql: show only failed queries

From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql: show only failed queries
Date: 2014-03-04 05:35:54
Message-ID: CAFcNs+qeA3ESDY530+K_qnvv-ohREhEWe81EoiR7aFZHpu1Kow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Mar 1, 2014 at 8:01 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:
>
> Hello
>
> I was asked, how can be showed only failed queries in psql.
>
> I am thinking, so it is not possible now. But implementation is very
simple
>
> What do you think about it?
>
> bash-4.1$ psql postgres -v ECHO=error -f data.sql
> INSERT 0 1
> Time: 27.735 ms
> INSERT 0 1
> Time: 8.303 ms
> psql:data.sql:3: ERROR: value too long for type character varying(2)
> insert into foo values('bbb');
> Time: 0.178 ms
> INSERT 0 1
> Time: 8.285 ms
> psql:data.sql:5: ERROR: value too long for type character varying(2)
> insert into foo values('ssssss');
> Time: 0.422 ms
>

The patch works fine, but I think we must add some prefix to printed query.
Like that:

fabrizio=# \set ECHO error
fabrizio=# insert into foo values ('XXX');
ERROR: value too long for type character varying(2)
DETAIL: insert into foo values ('XXX');

or

fabrizio=# \set ECHO error
fabrizio=# insert into foo values ('XXX');
ERROR: value too long for type character varying(2)
QUERY: insert into foo values ('XXX');

This may help to filter the output with some tool like 'grep'.

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog sobre TI: http://fabriziomello.blogspot.com
>> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Wang, Jing 2014-03-04 05:58:20 Re: pg_dump reporing version of server & pg_dump as comments in the output
Previous Message Peter Geoghegan 2014-03-04 05:21:13 Re: jsonb and nested hstore