Re: Extend injection_points_attach() to accept a user-defined function - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Extend injection_points_attach() to accept a user-defined function
Date
Msg-id aQq-PhPO4khzmYDt@paquier.xyz
Whole thread Raw
In response to Re: Extend injection_points_attach() to accept a user-defined function  (Rahila Syed <rahilasyed90@gmail.com>)
List pgsql-hackers
On Tue, Nov 04, 2025 at 02:17:44PM +0530, Rahila Syed wrote:
> PFA a rebased patch that contains the test.
> The tests use the newly added SQL function to attach the injection_notice
> function to an injection point

+    if (injection_point_local)
+    {
+        condition.type = INJ_CONDITION_PID;
+        condition.pid = MyProcPid;
+    }

Hmm.  Is there a point in registering a condition that's linked to
the shared library injection_points?  The automatic drop is kind of
nice to have, I guess, but it gives the illusion that an attached
callback will not be run.  However, a callback from an entirely
different library *will* run anyway because it cannot look at the
condition registered, or the other library has an equivalent able to
treat a local condition with the same format and same structure as
what's in injection_points.c.

Different idea: we could allow one to pass a bytea that could be given
directly to InjectionPointAttach()?  Without a use-case, I cannot get
much excited about that yet, but if someone has a use for it, why not.

Maybe we should also discard the pgstat_create_inj() call in this
path?  The existing injection_points_detach() would be able to deal
with a point attached with a callback from a different library anyway.
Keeping pgstat_report_inj_fixed() feels OK in this new attach path.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: Adding REPACK [concurrently]
Next
From: Richard Guo
Date:
Subject: Re: Fix comments for ChangeVarNodes() and related functions