Re: psql now shows zero elapsed time after an error

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>, Tom Lane <tgl@sss.pgh.pa.us>, Richard Guo <guofenglinux@gmail.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-05-23T08:13:40Z
Lists: pgsql-hackers
On 10.05.22 15:42, Fabien COELHO wrote:
> 
> Hello,
> 
> Thanks for the catch and the proposed fix! Indeed, on errors the timing 
> is not updated appropriately.
> 
> ISTM that the best course is to update the elapsed time whenever a 
> result is obtained, so that a sensible value is always available.
> 
> See attached patch which is a variant of Richard's version.
> 
>   fabien=# SELECT 1 as one \; SELECT 1/0 \; SELECT 2 as two;
>   ┌─────┐
>   │ one │
>   ├─────┤
>   │   1 │
>   └─────┘
>   (1 row)
> 
>   ERROR:  division by zero
>   Time: 0,352 ms
> 
> Probably it would be appropriate to add a test case. I'll propose 
> something later.

committed with a test




Commits

  1. psql: Update \timing also in case of an error