Fix an error in psql that overcounted output lines.
authorAndrew Dunstan <[email protected]>
Fri, 21 Nov 2014 17:37:09 +0000 (12:37 -0500)
committerAndrew Dunstan <[email protected]>
Fri, 21 Nov 2014 17:37:09 +0000 (12:37 -0500)
This error counted the first line of a cell as "extra". The effect was
to cause far too frequent invocation of the pager. In most cases this
can be worked around (for example, by using the "less" pager with the -F
flag), so don't backpatch.

src/bin/psql/print.c

index 3b3c3b73d957f76b3191ea2055e3ce80336d4684..fd26d6d1afbebe032c323809f1e6a04893648907 100644 (file)
@@ -836,7 +836,8 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
            {
                unsigned int extra_lines;
 
-               extra_lines = (width - 1) / width_wrap[i] + nl_lines;
+               /* don't count the first line of nl_lines - it's not "extra" */
+               extra_lines = ((width - 1) / width_wrap[i]) + nl_lines - 1;
                if (extra_lines > extra_row_output_lines)
                    extra_row_output_lines = extra_lines;
            }