bugfix - fix broken output in expanded aligned format, when data are too short - Mailing list pgsql-hackers

From Pavel Stehule
Subject bugfix - fix broken output in expanded aligned format, when data are too short
Date
Msg-id CAFj8pRCzGpsr9zTHbtTd4mGh2YPJqOEgLgt8JLiopuYA9_1xGw@mail.gmail.com
Whole thread
Responses Re: bugfix - fix broken output in expanded aligned format, when data are too short
List 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@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

pgsql-hackers by date:

Previous
From: shihao zhong
Date:
Subject: [Patch] New pg_stat_tablespace view
Next
From: PP L
Date:
Subject: Re: pg_upgrade failing for 200+ million Large Objects