| From: | Amit Langote <amitlan(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix RI fast-path for domain-typed FK columns |
| Date: | 2026-06-17 02:17:53 |
| Message-ID: | E1wZfqj-000esG-0l@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix RI fast-path for domain-typed FK columns
The RI fast path is the first caller to pass a cross-type pf_eq_oprs
operator to ri_HashCompareOp(). Its test for whether a cast can be
skipped, "typeid == righttype", failed when the FK column was a domain,
since typeid is then the domain OID rather than its base type. The code
concluded no usable conversion existed and threw "no conversion function
from <domain> to <type>" for every valid row.
Look through the domain to its base type. When pfeqop comes directly
from the index opfamily its right-hand input is getBaseType(fktype), so
getBaseType(typeid) == righttype is the correct test; the PK = PK
fallback (right-hand input opcintype) still fails that test and falls
through to the existing cast lookup unchanged.
Oversight in commit 2da86c1.
Reported-by: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Author: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Reviewed-by: Amit Langote <amitlangote09(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAON2xHNDFC4cX2atvTpMuC=cK9y7q4J+n3+15w4148AohXEc1w@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/68ace967c16bcd5fae87f13678b74ab5c5ea1a0f
Modified Files
--------------
src/backend/utils/adt/ri_triggers.c | 7 ++++---
src/test/regress/expected/foreign_key.out | 15 +++++++++++++++
src/test/regress/sql/foreign_key.sql | 14 ++++++++++++++
3 files changed, 33 insertions(+), 3 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuo Ishii | 2026-06-17 03:57:27 | pgsql: Fix error message typo. |
| Previous Message | Tatsuo Ishii | 2026-06-17 01:14:50 | pgsql: Fix to not allow null treatment to non window functions. |