Thread

  1. [PATCH v1] psql: Count all table footer lines in pager setup

    Erik Wienhold <ewie@ewie.name> — 2025-05-07T01:43:46Z

    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 | 13 +++++++------
     1 file changed, 7 insertions(+), 6 deletions(-)
    
    diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
    index 4af0f32f2fc..accb12145da 100644
    --- a/src/fe_utils/print.c
    +++ b/src/fe_utils/print.c
    @@ -3416,12 +3416,13 @@ 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++;
    +			for (f = cont->footers; f; f = f->next) {
    +				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
    
    
    --zbipdo3ugt3s25ts--