mirror of
https://github.com/postgres/postgres.git
synced 2026-01-27 21:43:08 +03:00
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.da7226993f(core AIO infrastructure) and93bc3d75d8(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
This commit is contained in:
@@ -16,13 +16,13 @@
|
||||
*/
|
||||
#ifdef USE_INJECTION_POINTS
|
||||
#define INJECTION_POINT_LOAD(name) InjectionPointLoad(name)
|
||||
#define INJECTION_POINT(name) InjectionPointRun(name)
|
||||
#define INJECTION_POINT_CACHED(name) InjectionPointCached(name)
|
||||
#define INJECTION_POINT(name, arg) InjectionPointRun(name, arg)
|
||||
#define INJECTION_POINT_CACHED(name, arg) InjectionPointCached(name, arg)
|
||||
#define IS_INJECTION_POINT_ATTACHED(name) IsInjectionPointAttached(name)
|
||||
#else
|
||||
#define INJECTION_POINT_LOAD(name) ((void) name)
|
||||
#define INJECTION_POINT(name) ((void) name)
|
||||
#define INJECTION_POINT_CACHED(name) ((void) name)
|
||||
#define INJECTION_POINT(name, arg) ((void) name)
|
||||
#define INJECTION_POINT_CACHED(name, arg) ((void) name)
|
||||
#define IS_INJECTION_POINT_ATTACHED(name) (false)
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
* Typedef for callback function launched by an injection point.
|
||||
*/
|
||||
typedef void (*InjectionPointCallback) (const char *name,
|
||||
const void *private_data);
|
||||
const void *private_data,
|
||||
void *arg);
|
||||
|
||||
extern Size InjectionPointShmemSize(void);
|
||||
extern void InjectionPointShmemInit(void);
|
||||
@@ -41,8 +42,8 @@ extern void InjectionPointAttach(const char *name,
|
||||
const void *private_data,
|
||||
int private_data_size);
|
||||
extern void InjectionPointLoad(const char *name);
|
||||
extern void InjectionPointRun(const char *name);
|
||||
extern void InjectionPointCached(const char *name);
|
||||
extern void InjectionPointRun(const char *name, void *arg);
|
||||
extern void InjectionPointCached(const char *name, void *arg);
|
||||
extern bool IsInjectionPointAttached(const char *name);
|
||||
extern bool InjectionPointDetach(const char *name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user