| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(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-18 22:47:43 |
| Message-ID: | CAKFQuwb-MdD3gjpJ5hMDSMgNJDykOArrA2_orA29VzLTy9=ELw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
> 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tristan Partin | 2026-06-18 23:11:48 | Re: Fix publisher-side sequence permission reporting |
| Previous Message | Tom Lane | 2026-06-18 22:26:06 | Re: PG20 Minimum Dependency Thread |