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.ba...@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
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c index e8772a278c..9f16fed49d 100644 --- a/src/fe_utils/print.c +++ b/src/fe_utils/print.c @@ -1247,6 +1247,10 @@ print_aligned_vertical(const printTableContent *cont, { printTableFooter *f; + /* print title */ + if (cont->title) + fprintf(fout, "%s\n", cont->title); + for (f = footers; f; f = f->next) fprintf(fout, "%s\n", f->data); }