public inbox for [email protected]  
help / color / mirror / Atom feed
From: Pavel Stehule <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: bugfix - fix broken output in expanded aligned format, when data are too short
Date: Mon, 23 Mar 2026 20:42:35 +0100
Message-ID: <CAFj8pRCzGpsr9zTHbtTd4mGh2YPJqOEgLgt8JLiopuYA9_1xGw@mail.gmail.com> (raw)

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@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


Attachments:

  [text/x-patch] 0001-fix-expended-aligned-format.patch (759B, 3-0001-fix-expended-aligned-format.patch)
  download | inline diff:
From 131261620f35997be1cf2b4726577c2c284335d2 Mon Sep 17 00:00:00 2001
From: "[email protected]" <[email protected]>
Date: Mon, 23 Mar 2026 20:39:31 +0100
Subject: [PATCH] fix expended aligned format

---
 src/fe_utils/print.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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,
-- 
2.53.0



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: bugfix - fix broken output in expanded aligned format, when data are too short
  In-Reply-To: <CAFj8pRCzGpsr9zTHbtTd4mGh2YPJqOEgLgt8JLiopuYA9_1xGw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox