double counting of lines in psql

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: double counting of lines in psql
Date: 2014-11-17 16:13:15
Message-ID: 546A1E9B.80305@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


This tiny change fixes what I think is a longstanding bug in psql. I
causes the first line of every cell to be counted twice, whereas it
should in fact be excluded from extra_lines / extra_row_output_lines.
The bug appears to date back to commit 43ee2282 in 2008. Changing it
appears to make my proposed pager_min_lines feature work as expected.

So, should it be backpatched? It's a behaviour change, albeit that the
existing behaviour is a bug, and will cause the pager to be invoked on
output that is way too short (by about half a screen's height, I think).

cheers

andrew

diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 2e158b8..c93f744 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -837,7 +837,7 @@ print_aligned_text(const printTableContent *cont,
FILE *fout)
{
unsigned int extra_lines;

- extra_lines = (width - 1) / width_wrap[i] + nl_lines;
+ extra_lines = ((width - 1) / width_wrap[i]) + (nl_lines
- 1);
if (extra_lines > extra_row_output_lines)
extra_row_output_lines = extra_lines;
}

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2014-11-17 16:14:34 Re: 9.5: Better memory accounting, towards memory-bounded HashAgg
Previous Message Simon Riggs 2014-11-17 16:08:53 Re: 9.5: Better memory accounting, towards memory-bounded HashAgg