Re: bugfix - fix broken output in expanded aligned format, when data are too short

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: getiancheng <getiancheng_2012(at)163(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: bugfix - fix broken output in expanded aligned format, when data are too short
Date: 2026-03-24 07:23:01
Message-ID: CAFj8pRB9S3kESHbux0smuXoDA9Z1cMTLYUmL3J3YN3O7mALyKA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

út 24. 3. 2026 v 8:17 odesílatel getiancheng <getiancheng_2012(at)163(dot)com>
napsal:

>
>
> ---- Replied Message ----
> From Chao Li<li(dot)evan(dot)chao(at)gmail(dot)com> <li(dot)evan(dot)chao(at)gmail(dot)com>
> Date 3/24/2026 15:01
> To Pavel Stehule<pavel(dot)stehule(at)gmail(dot)com> <pavel(dot)stehule(at)gmail(dot)com>
> Cc PostgreSQL Hackers<pgsql-hackers(at)lists(dot)postgresql(dot)org>
> <pgsql-hackers(at)lists(dot)postgresql(dot)org>
> Subject Re: bugfix - fix broken output in expanded aligned format, when
> data are too short
>
>
>
> On Mar 24, 2026, at 14:31, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>
>
>
> út 24. 3. 2026 v 7:12 odesílatel Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> napsal:
>
>
> On Mar 24, 2026, at 13:46, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>
> Hi
>
> new version
>
> * fixed unwanted forcing to wrapped mode
> * regress test
>
> Regards
>
> Pavel
> <v20260324-1-0001-The-output-of-thin-table-is-broken-in-expanded-mode-.patch>
>
>
> Thanks for the fix. The patch overall looks good to me. A couple of small comments:
>
> 1
> ```
> /*
> * Calculate available width for data in wrapped mode
> */
> - if (cont->opt->format == PRINT_WRAPPED)
> + if (cont->opt->format == PRINT_WRAPPED || cont->opt->format == PRINT_ALIGNED)
> ```
>
> Since the condition has been updated, I think the comment above should be adjusted as well.
>
> done
>
> pavel(at)nemesis:~/src/postgresql$ git diff
> diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
> index 7d7eb7dd041..dbfe437bc4c 100644
> --- a/src/fe_utils/print.c
> +++ b/src/fe_utils/print.c
> @@ -1443,7 +1443,8 @@ print_aligned_vertical(const printTableContent *cont,
> }
>
> /*
> - * Calculate available width for data in wrapped mode
> + * Calculate available width for data in wrapped mode or minimal width
> + * in aligned mode
> */
> if (cont->opt->format == PRINT_WRAPPED || cont->opt->format == PRINT_ALIGNED)
> {
>
>
> 2
> ```
> +-- the output in expanded mode is shorter than header
> +\pset border 2
> +\pset expanded on
> +create table psql_short_tab(a int, b int);
> +insert into psql_short_tab values(10,20),(30,40);
> +\pset format aligned
> +select * from psql_short_tab;
> +\pset format wrapped
> +select * from psql_short_tab;
> +drop table psql_short_tab;
> +
> ```
>
> After this test, does it make sense to turn expanded mode off explicitly, in case it affects following tests? Today the next test happens to reset it, but maybe tomorrow a new test gets added before that point.
>
> There is no default pset setting in psql.sql. Following test has its own setting. Generally this is the responsibility to every test to set the environment how it is necessary. Maybe I am wrong, but I see, so only database objects and prepared queries are cleaned there. There is not problem to write \pset border 1 \pset expanded off, but following tests starts with \pset expanded off and this can be little bit messy and redundant
>
> Thank you for check
>
> Regards
>
> Pavel
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
>
> <v20260324-2-0001-The-output-of-thin-table-is-broken-in-expanded-mode-.patch>
>
>
> LGTM.
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
> Hi,
>
> Overall looks good to me. Only nitpick is that, in the commit message, "thin table" sounds a little unusual, maybe "narrow table".
>
>
changed in attached version

Thank you for check

Regards

Pavel

>
>
> Best regards,
> Tiancheng Ge
>
>
>

Attachment Content-Type Size
v20260324-3-0001-The-output-of-narrow-table-is-broken-in-expanded-mod.patch text/x-patch 2.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-03-24 07:25:44 Re: tablecmds: fix bug where index rebuild loses replica identity on partitions
Previous Message songjinzhou 2026-03-24 07:22:29 Re: [Patch] New pg_stat_tablespace view