| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
| Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Bruce Momjian <bmomjian(at)gmail(dot)com> |
| Subject: | Re: Fix \crosstabview to honor \pset display_true/display_false |
| Date: | 2026-06-26 00:01:12 |
| Message-ID: | ED652286-9AED-4DA5-A70B-B1B4FF7C8479@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jun 25, 2026, at 21:21, Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:
Thank you very much for the comments.
>
> On 2026-Jun-21, Chao Li wrote:
>
>> Thank you both very much for reviewing and for the valuable comments.
>>
>> I have made the helper private to crosstabview.c and left print.c
>> unchanged in v3. I will see if I can improve print.h/c for v20.
>
> I mostly agree with this, but I don't think we need to make that
> function name that long. It's a private function after all. But it's
> definitely in the wrong spot in the file, so I propose to move it down.
Agreed.
>
> Now, your new test case doesn't exercise "\pset null" under
> \crosstabview, and I'm not sure that just leaving the cell empty for a
> NULL is really the thing to do, when \pset null has set it to some other
> value. Simply printing the \pset null string doesn't seem to cut it
> though (here implemented as the change in printCrosstab line 421ff), as
> seen in how this patch affects the test case prior to the new one.
> Should we have a separate array of bools to distinguish cells that must
> remain empty (because the query didn't provide a value for them) from
> cells that must have the \pset null value?
>
Yes, I didn’t include \pset null in the new test case because I didn’t intend this patch to change NULL display behavior, so I assumed other test cases already covered that. I didn’t check that carefully enough.
I didn’t take this part from your proposal, so an empty cell still shows nothing:
```
@@ -442,7 +421,7 @@ printCrosstab(const PGresult *result,
for (i = 0; i < cont.cellsadded; i++)
{
if (cont.cells[i] == NULL)
- cont.cells[i] = "";
+ cont.cells[i] = printDisplayValue(&popt, InvalidOid, NULL, "");
}
```
Your proposed test has NULL in the row and column headers, but not in the value column. I added a NULL value too, so the test case explicitly demonstrates the display difference between a NULL value and an empty cell.
PFA v4: addressed Álvaro's comments.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v4-0001-Make-crosstabview-honor-boolean-display-settings.patch | application/octet-stream | 7.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jacob Champion | 2026-06-26 00:12:42 | Re: REVOKE's CASCADE protection doesn't work with INHERITed table owners |
| Previous Message | Peter Smith | 2026-06-25 23:53:12 | Re: Support EXCEPT for ALL SEQUENCES publications |