double counting of lines in psql - Mailing list pgsql-hackers

From Andrew Dunstan
Subject double counting of lines in psql
Date
Msg-id 546A1E9B.80305@dunslane.net
Whole thread Raw
Responses Re: double counting of lines in psql  (David Fetter <david@fetter.org>)
List 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;
          }
 





pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: 9.5: Better memory accounting, towards memory-bounded HashAgg
Next
From: Simon Riggs
Date:
Subject: Re: 9.5: Better memory accounting, towards memory-bounded HashAgg