Re: RI fast path gets cross-type foreign keys wrong - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: RI fast path gets cross-type foreign keys wrong
Date
Msg-id CAH2-Wz=D533JbF_ak_Pc8kP0FKse-ju8DnMxtjvY==yHsP4xgw@mail.gmail.com
Whole thread
List pgsql-hackers
On Fri, Jul 31, 2026 at 11:03 PM Peter Geoghegan <pg@bowt.ie> wrote:
> The attached isolation test patch (written by Claude code) shows that
> the new RI fast path can get some things wrong when a foreign key uses
> a cross-type equality operator.

Opus 5 flagged an independent problem in the RI fast path work. This
one appears to be a resource management issue.

When I run the foreign_key tests with the attached patch applied, I
see these failures:

#  END$$;
#  CREATE TRIGGER fp_expand_kit_trg AFTER INSERT ON fp_order
#      FOR EACH ROW EXECUTE FUNCTION fp_expand_kit();
#  INSERT INTO fp_order VALUES (1, 1, 1);
# +WARNING:  resource was not closed: relation "fp_product"
# +WARNING:  resource was not closed: relation "fp_product_pkey"
# +WARNING:  resource was not closed: TupleDesc 0x7f7e109a3448 (34085,-1)
# +WARNING:  resource was not closed: TupleDesc 0x7f7e109a2cd8 (34068,-1)
#  NOTICE:  order 1 expanded into 3 order items

Right afterwards, "Assert(rel->rd_refcnt > 0)" fails within
RelationDecrementReferenceCount().

--
Peter Geoghegan

Attachment

pgsql-hackers by date:

Previous
From: Hüseyin Demir
Date:
Subject: Re: PSQL - improve tab completion for pub/sub options
Next
From: Andrey Rachitskiy
Date:
Subject: Re: [PATCH]Fix pg_xact corruption from subtransaction abort after subcommit