diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-05-10 06:56:26 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-05-10 06:56:26 +0900 |
commit | 371f2db8b05e4d46cbf489f05cbfc4d6ed6976d4 (patch) | |
tree | af10abf135f4a14534d31c7d8f95d7bed9b4e949 /doc/src | |
parent | 89372d0aaa4a6f0e560acdf9014c5ad66fdde1b1 (diff) | |
download | postgresql-371f2db8b05e4d46cbf489f05cbfc4d6ed6976d4.tar.gz postgresql-371f2db8b05e4d46cbf489f05cbfc4d6ed6976d4.zip |
Add support for runtime arguments in injection points
The macros INJECTION_POINT() and INJECTION_POINT_CACHED() are extended
with an optional argument that can be passed down to the callback
attached when an injection point is run, giving to callbacks the
possibility to manipulate a stack state given by the caller. The
existing callbacks in modules injection_points and test_aio have their
declarations adjusted based on that.
da7226993fd4 (core AIO infrastructure) and 93bc3d75d8e1 (test_aio) and
been relying on a set of workarounds where a static variable called
pgaio_inj_cur_handle is used as runtime argument in the injection point
callbacks used by the AIO tests, in combination with a TRY/CATCH block
to reset the argument value. The infrastructure introduced in this
commit will be reused for the AIO tests, simplifying them.
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/Z_y9TtnXubvYAApS@paquier.xyz
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/xfunc.sgml | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index 3a73b02ccaf..2d81afce8cb 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -3829,15 +3829,17 @@ uint32 WaitEventExtensionNew(const char *wait_event_name) An injection point with a given <literal>name</literal> is declared using macro: <programlisting> -INJECTION_POINT(name); +INJECTION_POINT(name, arg); </programlisting> There are a few injection points already declared at strategic points within the server code. After adding a new injection point the code needs to be compiled in order for that injection point to be available in the binary. Add-ins written in C-language can declare injection points in - their own code using the same macro. The injection point names should - use lower-case characters, with terms separated by dashes. + their own code using the same macro. The injection point names should use + lower-case characters, with terms separated by + dashes. <literal>arg</literal> is an optional argument value given to the + callback at run-time. </para> <para> @@ -3847,7 +3849,7 @@ INJECTION_POINT(name); a two-step approach with the following macros: <programlisting> INJECTION_POINT_LOAD(name); -INJECTION_POINT_CACHED(name); +INJECTION_POINT_CACHED(name, arg); </programlisting> Before entering the critical section, @@ -3880,7 +3882,9 @@ extern void InjectionPointAttach(const char *name, <literal>InjectionPointCallback</literal>: <programlisting> static void -custom_injection_callback(const char *name, const void *private_data) +custom_injection_callback(const char *name, + const void *private_data, + void *arg) { uint32 wait_event_info = WaitEventInjectionPointNew(name); @@ -3909,7 +3913,7 @@ if (IS_INJECTION_POINT_ATTACHED("before-foobar")) local_var = 123; /* also execute the callback */ - INJECTION_POINT_CACHED("before-foobar"); + INJECTION_POINT_CACHED("before-foobar", NULL); } #endif </programlisting> |