On 2025-08-11 20:28 +0200, Greg Sabino Mullane wrote:
> Patch looks good, applies and works. Needs a pgindent run:

Thanks for the review.  Here's v2 with proper formatting.

-- 
Erik
>From 96479e8bcc2d6598ce7d76ff7282541dc4d2e58e Mon Sep 17 00:00:00 2001
From: Erik Wienhold <e...@ewie.name>
Date: Wed, 7 May 2025 03:43:46 +0200
Subject: [PATCH v2] psql: Count all table footer lines in pager setup

Until now every table footer was counted as a single line when
determining if the pager is needed.  This fails to trigger the pager
when describing a view with a long definition using command \d+.  Fix
that by counting the actual lines of the footer text.
---
 src/fe_utils/print.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index 4af0f32f2fc..103fef4b46b 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -3416,12 +3416,14 @@ IsPagerNeeded(const printTableContent *cont, int 
extra_lines, bool expanded,
                {
                        printTableFooter *f;
 
-                       /*
-                        * FIXME -- this is slightly bogus: it counts the 
number of
-                        * footers, not the number of lines in them.
-                        */
                        for (f = cont->footers; f; f = f->next)
-                               lines++;
+                       {
+                               int                     f_lines;
+
+                               pg_wcssize((const unsigned char *) f->data, 
strlen(f->data),
+                                                  cont->opt->encoding, NULL, 
&f_lines, NULL);
+                               lines += f_lines;
+                       }
                }
 
                *fout = PageOutput(lines + extra_lines, cont->opt);
-- 
2.50.1

Reply via email to