Re: BUG: PostgreSQL 19devel throws internal opfamily error for FK with reordered referenced columns
Amit Langote <amitlangote09@gmail.com>
From: Amit Langote <amitlangote09@gmail.com>
To: Fredrik Widlert <fredrik.widlert@digpro.se>
Cc: Junwang Zhao <zhjwpku@gmail.com>,
Matheus Alcantara <matheusssilv97@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2026-04-10T08:05:33Z
Lists: pgsql-bugs
Attachments
- v1-0001-Add-test-case-for-same-type-reordered-FK-columns.patch (application/octet-stream) patch v1-0001
On Fri, Apr 10, 2026 at 4:29 PM Fredrik Widlert <fredrik.widlert@digpro.se> wrote: > Thanks for the very quick fix - it's a great feeling to report a problem > and get it fixed this quickly. Credit goes to Matheus for quickly submitting a well-written patch. > I can confirm that the fix solves not only the small reproducer but also > the original problems I got when trying to install our (large) system > on PostgreSQL 19 devel for testing. Thanks for confirming that. > We actually ran into the same problem in two ways: > * the reordered FK with datatype mismatch (my reproducer) > * other reordered FKs with the same datatypes, where we instead got > regular FK violations > > In case you want a reproducer for the second case as well, I've included it below, > but perhaps it's not relevant since the patch already fixed it. > > ---- > drop table if exists parent, child; > > create table parent ( > c1 integer, > c2 integer, > primary key (c1, c2) > ); > > create table child ( > c1 integer, > c2 integer, > constraint child_fk foreign key (c2, c1) references parent (c2, c1) > ); > > insert into parent (c1, c2) values (1, 2); > insert into child (c1, c2) values (1, 2); Good to know. It's worth adding this case next to the ones Matheus's patch added, which the attached patch does. Will push it shortly. -- Thanks, Amit Langote
Commits
-
Add test case for same-type reordered FK columns
- 009ea1b08d7b 19 (unreleased) landed
-
Assert index_attnos[0] == 1 in ri_FastPathFlushArray()
- 155c03ee9d44 19 (unreleased) landed
-
Fix FK fast-path scan key ordering for mismatched column order
- 980c1a85d819 19 (unreleased) landed
-
Add fast path for foreign key constraint checks
- 2da86c1ef9b5 19 (unreleased) cited