| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, ewie(at)ewie(dot)name |
| Subject: | Re: Fix psql pager selection for wrapped expanded output |
| Date: | 2026-06-12 10:57:27 |
| Message-ID: | 873721BE-3AA3-4FB1-93B0-EF98CC28603A@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jun 12, 2026, at 18:01, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> Hi,
>
> While testing “[27da1a796] Improve psql's ability to select pager mode accurately”, I found that the pager doesn’t work for expanded wrapped mode. However, I realized that this is not a new problem introduced by 27da1a796, it didn’t work before 27da1a796 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 after dwidth 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/
>
> <v1-0001-Fix-psql-pager-selection-for-wrapped-expanded-out.patch>
This is simpler repro:
```
\pset pager on
\pset format wrapped
\pset expanded on
\pset columns 5
SELECT repeat('x',100) AS payload;
```
My terminal size:
```
evantest=# \! stty size
27 170
```
BTW, I also ran into another issue that confused me. After changing print.c, running make from the source root didn’t rebuild psql. I had to run "make clean" and rebuild everything. Is that known or intentional?
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Antonin Houska | 2026-06-12 11:01:04 | Re: REPACK CONCURRENTLY fails on tables with generated columns |
| Previous Message | Amit Kapila | 2026-06-12 10:54:11 | Re: Fix race in ReplicationSlotRelease for ephemeral slots |