Re: Enables to call Unregister*XactCallback() in Call*XactCallback()

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Hao Wu <gfphoenix78@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2022-04-03T16:39:23Z
Lists: pgsql-hackers
Hi,

On 2022-03-29 14:48:54 +0800, Hao Wu wrote:
> It's a natural requirement to unregister the callback for transaction or
> subtransaction when the callback is invoked, so we don't have to
> unregister the callback somewhere.

You normally shouldn'd need to do this frequently - what's your use case?
UnregisterXactCallback() is O(N), so workloads registering / unregistering a
lot of callbacks would be problematic.

> Luckily, we just need a few lines of code to support this feature,
> by saving the next pointer before calling the callback.

That seems reasonable...

Greetings,

Andres Freund



Commits

  1. Allow callback functions to deregister themselves during a call.