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

Chao Li <li.evan.chao@gmail.com>

From: Chao Li <li.evan.chao@gmail.com>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>, Álvaro Herrera <alvherre@kurilemu.de>, Bruce Momjian <bmomjian@gmail.com>
Date: 2026-06-19T01:35:34Z
Lists: pgsql-hackers

Attachments


> On Jun 19, 2026, at 06:47, David G. Johnston <david.g.johnston@gmail.com> wrote:
> 
> On Wed, Jun 3, 2026 at 12:16 AM Chao Li <li.evan.chao@gmail.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/




Commits

  1. Make crosstabview honor boolean/null display settings