Re: Add \pset options for boolean value display - Mailing list pgsql-hackers

From a.kozhemyakin
Subject Re: Add \pset options for boolean value display
Date
Msg-id 83e247ed-0b2d-4aba-bc42-e7bbc20be0d6@postgrespro.ru
Whole thread
In response to Re: Add \pset options for boolean value display  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Add \pset options for boolean value display
List pgsql-hackers

Hi Hackers,

The following script, when built with addresssanitizer, fails with a DoubleFree error. reproduce on master (d3bba0415435)

psql postgres <<EOF
\pset display_false 'f'
SELECT 1 as one, 2 as two \g (display_false=csv csv_fieldsep='\t')
\pset display_false 'f'
EOF
Boolean false display is "f".
one | two
-----+-----
1 | 2
(1 строка) =================================================================
==2263488==ERROR: AddressSanitizer: attempting double-free on 0x774e419e15d0 in thread T0:
    #0 0x64c15cb777ab in free.part.0 (/pgpro/builds/master/inst_asan/bin/psql+0x23e7ab) (BuildId: 235e8c12978fc34235af5b00bd4a2feaab9cb794)
    #1 0x64c15cbedfbd in do_pset /pgpro/postgres/src/bin/psql/command.c:5310
    #2 0x64c15cbef308 in exec_command_pset /pgpro/postgres/src/bin/psql/command.c:2737
    #3 0x64c15cbf10d3 in exec_command /pgpro/postgres/src/bin/psql/command.c:431
    #4 0x64c15cbf1579 in HandleSlashCmds /pgpro/postgres/src/bin/psql/command.c:258
    #5 0x64c15cc25ecd in MainLoop /pgpro/postgres/src/bin/psql/mainloop.c:496
    #6 0x64c15cbec791 in process_file /pgpro/postgres/src/bin/psql/command.c:4977
    #7 0x64c15cc48cda in main /pgpro/postgres/src/bin/psql/startup.c:424
    #8 0x7b2e4322a574 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #9 0x7b2e4322a627 in __libc_start_main_impl ../csu/libc-start.c:360
    #10 0x64c15ca91b84 in _start (/pgpro/builds/master/inst_asan/bin/psql+0x158b84) (BuildId: 235e8c12978fc34235af5b00bd4a2feaab9cb794)

0x774e419e15d0 is located 0 bytes inside of 2-byte region [0x774e419e15d0,0x774e419e15d2)
freed by thread T0 here:
    #0 0x64c15cb777ab in free.part.0 (/pgpro/builds/master/inst_asan/bin/psql+0x23e7ab) (BuildId: 235e8c12978fc34235af5b00bd4a2feaab9cb794)
    #1 0x64c15cbedfbd in do_pset /pgpro/postgres/src/bin/psql/command.c:5310
    #2 0x783e419e2980  (<unknown module>)

previously allocated by thread T0 here:
    #0 0x64c15cb725c8 in strdup (/pgpro/builds/master/inst_asan/bin/psql+0x2395c8) (BuildId: 235e8c12978fc34235af5b00bd4a2feaab9cb794)
    #1 0x64c15cc92bd5 in pg_strdup /pgpro/postgres/src/common/fe_memutils.c:95

SUMMARY: AddressSanitizer: double-free (/pgpro/builds/master/inst_asan/bin/psql+0x23e7ab) (BuildId: 235e8c12978fc34235af5b00bd4a2feaab9cb794) in free.part.0
==2263488==ABORTING

645cb44c5490f70da4dca57b8ecca6562fb883a7 is the first bad commit

gcc --version
gcc (Ubuntu 15.2.0-4ubuntu4) 15.2.0

building CPPFLAGS="-Og -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=nonnull-attribute -fstack-protector" LDFLAGS='-fsanitize=address -fsanitize=undefined -static-libasan' \
./configure --prefix /pgpro/builds/master_simple && make world-bin -s -j$(nproc) && make install-world-bin -s

04.11.2025 00:16, David G. Johnston пишет:
On Monday, November 3, 2025, Álvaro Herrera <alvherre@kurilemu.de> wrote:
On 2025-Oct-21, Álvaro Herrera wrote:
> On 2025-Oct-20, David G. Johnston wrote:
> > Thank you.  Seems good from a quick read.  I’m regretting the choice of the
> > display_ prefix; is there any technical limitation or other opposition to
> > using just true and false?
> >
> > \pset true ‘true’
> > \pset false ‘false’

> Uhm.  I don't know.  [...]  I'll gladly take a vote.

I got zero votes and lots of digression, so I have pushed with your
original choice of "display_true" and "display_false".  The "true" and
"false" variable names sound too generic and I think they're more likely
to cause confusion.  I think "null" is not a great name either, but it's
been there since forever so I'm not going to propose changing it.

Thank you.

David J.

pgsql-hackers by date:

Previous
From: Antonin Houska
Date:
Subject: Re: repack: fix a bug to reject deferrable primary key fallback for concurrent mode
Next
From: Alex Guo
Date:
Subject: Re: [PATCH] Fix column name escaping in postgres_fdw stats import