Hi,
While testing “[645cb44c5] Add \pset options for boolean value display”, I noticed that it seems to miss support for
\crosstabview.
Here is a repro:
```
evantest=# \pset display_true YES
Boolean true display is "YES".
evantest=# \pset display_false NO
Boolean false display is "NO".
evantest=#
evantest=# select true as direct_true, false as direct_false;
direct_true | direct_false
-------------+--------------
YES | NO
(1 row)
evantest=#
evantest=# select false as row_key, true as col_key, true as val
evantest-# union all
evantest-# select true, false, false
evantest-# \crosstabview row_key col_key val
row_key | t | f
---------+---+---
f | t |
t | | f
(2 rows)
```
In normal query output, true/false are shown as YES/NO, but \crosstabview still shows them as t/f.
I noticed this problem by searching for nullPrint and finding it in crosstabview.c. Since nullPrint is already honored
there,display_true/display_false should be honored as well.
While working on the fix, I further noticed that numericlocale is also not honored by \crosstabview:
```
evantest=# \pset numericlocale on
evantest=#
evantest=# SELECT 12345::numeric AS direct_value;
direct_value
--------------
12,345
(1 row)
evantest=#
evantest=# SELECT 1 AS row_key, 1 AS col_key, 12345::numeric AS val
evantest-# \crosstabview row_key col_key val
row_key | 1
---------+-------
1 | 12345
(1 row)
```
Since we are supposed to fix only v19 bugs at this stage, this patch only makes \crosstabview honor
display_true/display_false,as that is a new PG19 feature. I will add the numericlocale work to my TODO and revisit it
forv20.
In this patch, I add a helper function, printQueryOptDisplayValue(), to handle both nullPrint and
display_true/display_falsein a single place. In the future, we may also be able to handle numericlocale in this
function.
See the attached patch for details. With the fix, \crosstabview displays boolean values according to the \pset
settings:
```
evantest=# select false as row_key, true as col_key, true as val
evantest-# union all
evantest-# select true, false, false
evantest-# \crosstabview row_key col_key val
row_key | YES | NO
---------+-----+----
NO | YES |
YES | | NO
(2 rows)
```
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/