From: Chao Li <li.evan.chao@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Álvaro Herrera <alvherre@kurilemu.de>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Add \pset options for boolean value display
Date: Tue, 21 Oct 2025 09:38:24 +0800
Message-ID: <385850DE-F52D-4E37-9207-50FD51DF6F9A@gmail.com> (raw)
In-Reply-To: <CAKFQuwYWdocoCsfDOZhY2xALM1U89O4bP=Ou266pAOdVojgpfw@mail.gmail.com>
References: <CAKFQuwZaeRT3Nco9sPd-9ZwEuStUZLU+AKH9+iRf4978T59kRg@mail.gmail.com>
<202510201419.mpror4maizbg@alvherre.pgsql>
<CAKFQuwYWdocoCsfDOZhY2xALM1U89O4bP=Ou266pAOdVojgpfw@mail.gmail.com>
> On Oct 21, 2025, at 04:51, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
> On Monday, October 20, 2025, Álvaro Herrera <alvherre@kurilemu.de> wrote:
> On 2025-Jun-24, David G. Johnston wrote:
>
> > v1, Ready aside from bike-shedding the name.
>
> Here's v2 after some kibitzing. What do you think?
>
> 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’
>
> To keep in line with:
>
> \pset null ‘(null)’
>
+1. Especially, when I see the newly added test case:
```
+prepare q as select null as n, true as t, false as f;
+\pset null '(null)'
+\pset display_true 'true'
+\pset display_false 'false'
```
Looks inconsistant. If we decided to use “display_xx” then we should have renamed “null” to “display_null”.
The other thing I am thinking is that, with this patch, users are allowed to display arbitrary strings for true/false, if a user mistakenly set display_true to f and display_false to t, which will load to misunderstanding.
```
evantest=# \pset display_true f
Boolean true display is "f".
evantest=# \pset display_false t
Boolean false display is "t".
evantest=# select true as t, false as f;
t | f
---+---
f | t
(1 row)
```
Can we perform a basic sanity check to prevent this kind of error-prone behavior? The consideration applies to the “null” option, but since “null” lacks a clear opposite string representation (unlike “true”/“t" and “false”/“f”), it’s fine to skip the check for it.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
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: pgsql-hackers@postgresql.org
Cc: li.evan.chao@gmail.com, david.g.johnston@gmail.com, alvherre@kurilemu.de, pgsql-hackers@lists.postgresql.org
Subject: Re: Add \pset options for boolean value display
In-Reply-To: <385850DE-F52D-4E37-9207-50FD51DF6F9A@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox