Re: [PATCH] refint: Avoid reusing cascade UPDATE plans.

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] refint: Avoid reusing cascade UPDATE plans.
Date: 2026-05-15 17:27:22
Message-ID: agdXesda4Ynsuc7y@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 15, 2026 at 08:34:55PM +0530, Ayush Tiwari wrote:
> On Fri, 15 May 2026 at 20:16, Nathan Bossart <nathandbossart(at)gmail(dot)com>
> wrote:
>> Big +1 for removing it in v20. Or maybe even v19. I do think it is worth
>> trying to fix the more egregious bugs, though, as the code will still be
>> supported for a few years.
>
> I agree on the removal part.

Cool. Do you want to write the patch for that, too? I think we should aim
for removing it shortly after v20 opens for development. It might be best
to move that to its own thread so that folks are aware and have a chance to
object.

> In the meantime, since the module will still be
> supported for a while, this seems like a focused fix for the more
> egregious cache behavior.
>
> Attached v3 removes the private SPI plan cache from refint entirely.
> Both check_primary_key() and check_foreign_key() now prepare their SPI
> plans per trigger invocation and let SPI_finish() release them.

I'm not sure I'd bother with the tests. At a glance the rest looks
generally reasonable. I realize that leaving the braces around the plan
preparation logic keeps the patch small, but we probably wouldn't write it
that way today. I'd suggest moving the local variable declarations to the
top of the function in your patch, and then doing a follow-up patch to
re-pgindent the file. Also, I don't think we need any of the comments
about the historical usage of a cache; let's just clean house.

--
nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2026-05-15 17:27:40 Re: First draft of PG 19 release notes
Previous Message Mohamed ALi 2026-05-15 16:47:30 [PATCH] vacuumdb: Add --exclude-database option