On Wed, 20 Aug 2025 at 21:57, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> The reason this broke at 0313c5dc6 is that that enabled
> SQLFunctionCaches to be re-used for the life of the associated
> FmgrInfo, and when we are talking about an opclass support procedure,
> that FmgrInfo is in the relcache so it is likely to last for the
> life of the session. So the presented test case causes us to error
> out of execution of the SQL function during the first INSERT, but
> its SQLFunctionCache still exists and has fcache->cplan != NULL,
> even though error cleanup would've released the reference count
> already. When we come back to this point in the second INSERT,
> init_execution_state is fooled into trying to release the
> already-released cplan.
Thank you for this explanation. I understood how things got buggy and
how they should be fixed.
The v3 LGTM.
--
Best regards,
Kirill Reshke