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

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: bugfix - fix broken output in expanded aligned format, when data are too short
Date: 2026-03-23 19:42:35
Message-ID: CAFj8pRCzGpsr9zTHbtTd4mGh2YPJqOEgLgt8JLiopuYA9_1xGw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

There is a bug in fe_utils

(2026-03-23 20:36:21) postgres=# \pset
border 2
columns 0
csv_fieldsep ','
display_false 'f'
display_true 't'
expanded on
fieldsep '|'
fieldsep_zero off
footer on
format aligned
linestyle unicode
null '∅'
numericlocale off
pager 1
pager_min_lines 0
recordsep '\n'
recordsep_zero off
tableattr
title
tuples_only off
unicode_border_linestyle single
unicode_column_linestyle single
unicode_header_linestyle double
xheader_width full

(2026-03-23 20:36:56) postgres=# select * from foo;
kuku
┌────┬────┐
│ a │ b │
╞════╪════╡
│ 10 │ 20 │
│ 10 │ 20 │
└────┴────┘
(2 rows)

(2026-03-23 20:36:58) postgres=# \x
Expanded display is on.
(2026-03-23 20:37:01) postgres=# select * from foo;
┌─[ RECORD 1 ]─┐
│ a │ 10 │
│ b │ 20 │
╞═[ RECORD 2 ]═╡
│ a │ 10 │
│ b │ 20 │
└───┴────┘

the bugfix is really short

pavel(at)nemesis:~/src/postgresql$ git diff master
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index 12d969e8666..58a04a902d5 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -1445,7 +1445,7 @@ print_aligned_vertical(const printTableContent *cont,
/*
* 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)
{
unsigned int swidth,
rwidth = 0,

after fix:

(2026-03-23 20:40:11) postgres=# \x
Expanded display is on.
(2026-03-23 20:40:13) postgres=# select * from foo;
┌─[ RECORD 1 ]─┐
│ a │ 10 │
│ b │ 20 │
╞═[ RECORD 2 ]═╡
│ a │ 10 │
│ b │ 20 │
└───┴──────────┘

Regards

Pavel

Attachment Content-Type Size
0001-fix-expended-aligned-format.patch text/x-patch 759 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message PP L 2026-03-23 19:47:28 Re: pg_upgrade failing for 200+ million Large Objects
Previous Message shihao zhong 2026-03-23 19:08:52 [Patch] New pg_stat_tablespace view