Re: psql now shows zero elapsed time after an error - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: psql now shows zero elapsed time after an error
Date
Msg-id alpine.DEB.2.22.394.2205101526240.1550767@pseudo
Whole thread Raw
In response to Re: psql now shows zero elapsed time after an error  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: psql now shows zero elapsed time after an error
List pgsql-hackers
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.

-- 
Fabien.
Attachment

pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: Proposal: add a debug message about using geqo
Next
From: Ashutosh Bapat
Date:
Subject: Re: Allowing REINDEX to have an optional name