On Wed, Jun 3, 2026 at 12:16 AM Chao Li <[email protected]> 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.

> 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).

David J.

Reply via email to