psql: Count all table footer lines in pager setup

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: pgsql-hackers(at)postgresql(dot)org
Subject: psql: Count all table footer lines in pager setup
Date: 2025-08-05 01:51:09
Message-ID: 2dd2430f-dd20-4c89-97fd-242616a3d768@ewie.name
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v1-0001-psql-Count-all-table-footer-lines-in-pager-setup.patch text/plain 1.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-08-05 02:09:19 RE: Conflict detection for update_deleted in logical replication
Previous Message Erik Wienhold 2025-08-05 01:17:06 Re: CREATE OR REPLACE MATERIALIZED VIEW