Fix psql pager selection for wrapped expanded output - Mailing list pgsql-hackers

From Chao Li
Subject Fix psql pager selection for wrapped expanded output
Date
Msg-id A44110E7-6A03-4C67-95AD-527192A6C768@gmail.com
Whole thread
Responses Re: Fix psql pager selection for wrapped expanded output
List pgsql-hackers
Hi,

While testing “[27da1a796] Improve psql's ability to select pager mode accurately”, I found that the pager doesn’t work
forexpanded wrapped mode. However, I realized that this is not a new problem introduced by 27da1a796, it didn’t work
before27da1a796 either. Instead, with 27da1a796, we are almost there to make it work. 

27da1a796 introduces a new helper count_table_lines(), that takes a per-column-width array. For expanded mode (vertical
mode),all columns use the same data width. So we can simply build such a width_wrap array, and move IsPagerNeeded() to
afterdwidth is computed. Then the pager works in expanded wrapped mode. 

I tested with this procedure (making the terminal small with ~30 rows):
```
\pset pager on
\pset columns 25
\pset expanded on
\pset format wrapped
select g AS id, 'name_' || g AS name, repeat('x', g * 5) AS payload from generate_series(1, 10) AS g;
```
See the attached patch for details. I’m not going to add this to the v19 open items, as it’s not a v19-new bug.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/


Attachment

pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: Why our Valgrind reports suck
Next
From: Matthias van de Meent
Date:
Subject: Re: Commit Sequence Numbers and Visibility