pgsql: refint: Remove plan cache.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: refint: Remove plan cache.
Date: 2026-06-05 17:08:58
Message-ID: E1wVY2U-001DiY-0S@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

refint: Remove plan cache.

Presently, refint stores plans in a per-backend cache to avoid
re-preparing in each call. This has a few problems. For one,
check_foreign_key() embeds the new key values in its cascade-UPDATE
queries, so a cached plan reuses the values from preparation.
Also, the cache is never invalidated, so it can return stale
entries that cause other problems. There may very well be more
bugs lurking.

We could spend a lot of time trying to address all these problems,
but this module is primarily intended as sample code, and by all
indications, it sees minimal use. Furthermore, there is a growing
consensus for removing refint in v20. However, since we'll need to
support it on the back-branches for a while longer, it probably
still makes sense to fix some of the more egregious bugs.

Therefore, let's just remove refint's plan cache entirely. That
means we'll re-prepare on every call, but that seems quite unlikely
to bother anyone. On v17 and older versions, the regression test
for triggers fails after this change, so I've borrowed pieces of
commit 8cfbdf8f4d to fix it.

Author: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAJTYsWXU%2BfhuzrEd_bnrxyGH3%2Bny8QRQC2QHf3ws6s9iki3c2Q%40mail.gmail.com
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b7b513d9afabf43124edda3dff7dd8af39906951

Modified Files
--------------
contrib/spi/refint.c | 352 +++++++++++----------------------
src/test/regress/expected/triggers.out | 37 ++--
src/test/regress/sql/triggers.sql | 10 +-
3 files changed, 138 insertions(+), 261 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2026-06-05 18:05:22 pgsql: doc PG 19 relnotes: update to current, merge items
Previous Message Bruce Momjian 2026-06-05 15:38:56 pgsql: doc PG 19 relnotes: add more markup, move some items to sysviews