pgsql: Allow callback functions to deregister themselves during a call.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow callback functions to deregister themselves during a call.
Date: 2022-09-28 15:23:39
Message-ID: E1odYuQ-002POU-VL@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow callback functions to deregister themselves during a call.

Fetch the next-item pointer before the call not after, so that
we aren't dereferencing a dangling pointer if the callback
deregistered itself during the call. The risky coding pattern
appears in CallXactCallbacks, CallSubXactCallbacks, and
ResourceOwnerReleaseInternal. (There are some other places that
might be at hazard if they offered deregistration functionality,
but they don't.)

I (tgl) considered back-patching this, but desisted because it
wouldn't be very safe for extensions to rely on this working in
pre-v16 branches.

Hao Wu

Discussion: https://postgr.es/m/CAH+9SWXTiERkmhRke+QCcc+jRH8d5fFHTxh8ZK0-Yn4BSpyaAg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4d2a844242dcfb34e05dd0d880b1a283a514b16b

Modified Files
--------------
src/backend/access/transam/xact.c | 14 ++++++++++++--
src/backend/utils/resowner/resowner.c | 7 ++++++-
2 files changed, 18 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-09-28 16:31:59 pgsql: Doc: document bpchar, clarify relationship of text and varchar.
Previous Message Alvaro Herrera 2022-09-28 15:19:36 pgsql: Change some errdetail() to errdetail_internal()