Re: psql: show only failed queries

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Samrat Revagade <revagade(dot)samrat(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Fabrízio Mello <fabriziomello(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql: show only failed queries
Date: 2014-06-25 18:48:13
Message-ID: CAFj8pRBXQV5Gousp3jpn2k=MXuaZn-T5FzmoFuXqUfonVaXNMg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2014-06-25 12:32 GMT+02:00 Samrat Revagade <revagade(dot)samrat(at)gmail(dot)com>:

> Hi Pavel,
>
> After applying patch, on error condition it displays error message two
> times as follows:
>
> ERROR: column "abc" does not exist at character 23
> STATEMENT: insert into ax
> values(abc);
> psql:a.sql:7: ERROR: column "abc" does not exist
> LINE 2: values(abc);
>
>
> user may confuse because of repeated error messages. so I think its better
> to display only one message, one of the possible ways is as follows:
>
> ERROR: column "abc" does not exist at character 23
> STATEMENT: insert into ax
> values(abc);
>
>
> Am I missing something ?
>

LINE info is a part of error message and should be eliminated by terse mode

[pavel(at)localhost ~]$ psql -v ECHO=error -f test.sql postgres > /dev/null
psql:test.sql:4: ERROR: syntax error at or near ";"
LINE 2: 10 + ;
^
psql:test.sql:4: STATEMENT: select
10 + ;
psql:test.sql:8: ERROR: syntax error at end of input
LINE 2: 30 +
^
psql:test.sql:8: STATEMENT: select
30 +

but you can switch to terse mode:

[pavel(at)localhost ~]$ psql -v ECHO=error -v VERBOSITY=terse -f test.sql
postgres > /dev/null
psql:test.sql:4: ERROR: syntax error at or near ";" at character 13
psql:test.sql:4: STATEMENT: select
10 + ;
psql:test.sql:8: ERROR: syntax error at end of input at character 13
psql:test.sql:8: STATEMENT: select
30 +

What is what you would

I am sending updated patch - buggy statement is printed via more logical
psql_error function instead printf

Regards

Pavel

>
>
>
> On Wed, Jun 4, 2014 at 9:52 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>
>>
>>
>>
>> 2014-06-04 18:16 GMT+02:00 Peter Eisentraut <peter_e(at)gmx(dot)net>:
>>
>> On 6/4/14, 11:54 AM, Pavel Stehule wrote:
>>> > updated patch - only one change: query is prefixed by "QUERY: "
>>>
>>> In the backend server log, this is called "STATEMENT: ".
>>>
>>
>> good idea
>>
>> updated patch
>>
>> Pavel
>>
>>
>> --
>> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-hackers
>>
>>
>
>
> --
> Regards,
>
> Samrat Revgade
>

Attachment Content-Type Size
echo-error-01.patch text/x-patch 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabrízio de Royes Mello 2014-06-25 18:49:01 Re: pg_filedump for 9.4?
Previous Message Tom Lane 2014-06-25 18:46:58 What's the point of json_extract_path_op etc?