Fix \watch if expanded output is on and there are no results - Mailing list pgsql-hackers

From Michael Banck
Subject Fix \watch if expanded output is on and there are no results
Date
Msg-id e72b9c3b052675e940697012932fe897b73806d8.camel@credativ.de
Whole thread Raw
List pgsql-hackers
Hi,

in expanded output, psql does not print the title if there are zero
results. In regular output, it prints the title ("foo") no matter how
many rows:

postgres=# \pset title foo
Title is "foo".
postgres=# SELECT 1 WHERE 1=1;
   foo
 ?column? 
----------
        1
(1 row)

postgres=# SELECT 1 WHERE 1=2;
   foo
 ?column? 
----------
(0 rows)

In expanded mode, it only prints the title if there is at least one row:

postgres=# \x
Expanded display is on.
postgres=# SELECT 1 WHERE 1=1;
foo
-[ RECORD 1 ]
?column? | 1

postgres=# SELECT 1 WHERE 1=2;
(0 rows)

Is that intentional? It breaks \watch for expanded output if the query
being watched does not always return at least one row. If that is not
the case, the timestamp is ommitted. I think that's bad enough to
warrant fixing like in the attached.

But maybe there was a good reason the title wasn't printed? On the ohter
hand, we're just returning early from print_aligned_vertical() right now
and never get to the part where we usually print the title if there are
zero results.


Michael

-- 
Michael Banck
Projektleiter / Senior Berater
Tel.: +49 2166 9901-171
Fax:  +49 2166 9901-100
Email: michael.banck@credativ.de

credativ GmbH, HRB Mönchengladbach 12080
USt-ID-Nummer: DE204566209
Trompeterallee 108, 41189 Mönchengladbach
Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer

Unser Umgang mit personenbezogenen Daten unterliegt
folgenden Bestimmungen: https://www.credativ.de/datenschutz

Attachment

pgsql-hackers by date:

Previous
From: Zhihong Yu
Date:
Subject: Re: Implement for window functions
Next
From: Bruce Momjian
Date:
Subject: Re: Key management with tests