Thread

  1. psql: Count all table footer lines in pager setup

    Erik Wienhold <ewie@ewie.name> — 2025-08-05T01:51:09Z

    Here's a patch to fix the pager setup when printing tables with large
    footers, e.g., long view definitions.
    
    For testing create a view with many columns (50 in this example):
    
    	select 'create view longview as select ' || string_agg('1 f' || s, ', ')
    	from generate_series(1, 50) s
    	\gexec
    
    Then describe the view with verbose output to also print its definition
    in the table footer:
    
    	\d+ longview
    
    Without the patch, no pager is used when the terminal can display 55 or
    more lines (check with `stty size`).  Below 55 available lines the pager
    is always used because the table itself requires 54 lines (50 view
    columns + 3 header lines + 1 "View definition" footer line).
    
    With the patch applied, the lines of the view definition also count
    towards the line total and the pager is used when more than 54 lines are
    available.
    
    -- 
    Erik Wienhold