Re: Fix \crosstabview to honor \pset display_true/display_false

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Bruce Momjian <bmomjian(at)gmail(dot)com>
Subject: Re: Fix \crosstabview to honor \pset display_true/display_false
Date: 2026-06-19 01:35:34
Message-ID: 88A5B14E-D080-447D-98B5-0B33D272B3A2@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Jun 19, 2026, at 06:47, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Wed, Jun 3, 2026 at 12:16 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
> While testing “[645cb44c5] Add \pset options for boolean value display”, I noticed that it seems to miss support for \crosstabview.
>
> In this patch, I add a helper function, printQueryOptDisplayValue(), to handle both nullPrint and display_true/display_false in a single place. In the future, we may also be able to handle numericlocale in this function.
>
>
> Thanks Chao!
>
> Adding a function indeed seems like the best choice - the only question is whether expanding print.h at this point is acceptable. If not, making it private to crosstab.c will accomplish the same immediate need.
>
> The name is a bit odd to me but I'm also not that familiar with naming conventions in the C code. But this is another reason to make it private in v19 and figure out the public interface in v20.

Sounds fair. I removed the helper declaration from print.h and added local temporary declaration in the .c files with a TODO comment for v20.

>
> > cont.cells[idx] =
> > printQueryOptDisplayValue(!PQgetisnull(result, rn, field_for_data) ?
> > PQgetvalue(result, rn, field_for_data) :
> > NULL,
> > data_ftype, &popt, "");
>
> I'd either remove the not operator and flip the order of the output ternary positions, or move the entire "compute the unadjusted value" to a local variable (assignment from ternary or just an if block) and then pass it to printQueryOptDisplayValue directly. Having a ternary expression as the first argument is what the other changes got rid of and makes this much easier to read (hence the need for the function).

Agreed.

PFA v2: addressed David’s comments.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v2-0001-Make-crosstabview-honor-boolean-display-settings.patch application/octet-stream 9.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2026-06-19 01:59:56 Re: Why is the LSN reported for pg_logical_emit_message() different from other decoded operations?
Previous Message Richard Guo 2026-06-19 01:13:25 Prove a NOT IN's left-hand expressions non-nullable from quals