| From: | Henson Choi <assam258(at)gmail(dot)com> |
|---|---|
| To: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, "crprashant(at)hotmail(dot)com" <crprashant(at)hotmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | Re: [DEPARSE] Operators on ROW() constructors read back as row comparisons |
| Date: | 2026-11-14 09:16:44 |
| Message-ID: | CAAAe_zA2EypMhAoNNUhadcSjKXWEGU_ZafkW3inp0CtYdGro0Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Zsolt,
> Function-like cast syntax has the same problem, even with v4:
>
> create view v as select record(row(1, null::int)) = record(row(1,
> null::int)) as r;
> select r from v;
> select pg_get_viewdef('v');
> -- SELECT (ROW(1, NULL::integer) = ROW(1, NULL::integer)) AS r;
Thanks for testing this. A function-style cast reaches coerce_type()
with COERCE_EXPLICIT_CALL, and v4 only recorded COERCE_EXPLICIT_CAST.
As with ::record, it also matters in WHERE:
create view v2 as select x from t
where record(row(x, null::int)) = record(row(1, null::int));
That view was dumped as
WHERE (ROW(x, NULL::integer) = ROW(1, NULL::integer))
so after restore it returns no rows instead of the row with x = 1.
Attached is v5. The only functional change is the condition in
0002's coerce_type():
- cformat == COERCE_EXPLICIT_CAST &&
+ (cformat == COERCE_EXPLICIT_CAST ||
+ cformat == COERCE_EXPLICIT_CALL) &&
0001 adds a view with the function-style cast in the target list and
in WHERE, and 0002 prints it with ::record. 0003 is unchanged.
Best regards,
Henson
| Attachment | Content-Type | Size |
|---|---|---|
| v5-0001-Add-tests-for-deparsing-record-comparisons-of-ROW.patch | application/octet-stream | 8.8 KB |
| v5-0002-Record-explicit-casts-of-ROW-constructors-in-the-.patch | application/octet-stream | 6.6 KB |
| v5-0003-Show-casts-of-ROW-constructors-made-by-the-parser.patch | application/octet-stream | 7.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert I Nilsson | 2026-11-14 10:41:14 | Re: [PATCH] Fix SASLprep validation after NFKC normalization |
| Previous Message | Bertrand Drouvot | 2026-11-14 06:52:21 | Re: Assertion failure in update_local_synced_slot(), slotsync.c:364 |