mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +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:
@@ -94,11 +94,14 @@ typedef struct InjectionPointSharedState
|
||||
static InjectionPointSharedState *inj_state = NULL;
|
||||
|
||||
extern PGDLLEXPORT void injection_error(const char *name,
|
||||
const void *private_data);
|
||||
const void *private_data,
|
||||
void *arg);
|
||||
extern PGDLLEXPORT void injection_notice(const char *name,
|
||||
const void *private_data);
|
||||
const void *private_data,
|
||||
void *arg);
|
||||
extern PGDLLEXPORT void injection_wait(const char *name,
|
||||
const void *private_data);
|
||||
const void *private_data,
|
||||
void *arg);
|
||||
|
||||
/* track if injection points attached in this process are linked to it */
|
||||
static bool injection_point_local = false;
|
||||
@@ -239,7 +242,7 @@ injection_points_cleanup(int code, Datum arg)
|
||||
|
||||
/* Set of callbacks available to be attached to an injection point. */
|
||||
void
|
||||
injection_error(const char *name, const void *private_data)
|
||||
injection_error(const char *name, const void *private_data, void *arg)
|
||||
{
|
||||
InjectionPointCondition *condition = (InjectionPointCondition *) private_data;
|
||||
|
||||
@@ -252,7 +255,7 @@ injection_error(const char *name, const void *private_data)
|
||||
}
|
||||
|
||||
void
|
||||
injection_notice(const char *name, const void *private_data)
|
||||
injection_notice(const char *name, const void *private_data, void *arg)
|
||||
{
|
||||
InjectionPointCondition *condition = (InjectionPointCondition *) private_data;
|
||||
|
||||
@@ -266,7 +269,7 @@ injection_notice(const char *name, const void *private_data)
|
||||
|
||||
/* Wait on a condition variable, awaken by injection_points_wakeup() */
|
||||
void
|
||||
injection_wait(const char *name, const void *private_data)
|
||||
injection_wait(const char *name, const void *private_data, void *arg)
|
||||
{
|
||||
uint32 old_wait_counts = 0;
|
||||
int index = -1;
|
||||
@@ -405,7 +408,7 @@ injection_points_run(PG_FUNCTION_ARGS)
|
||||
char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||
|
||||
pgstat_report_inj_fixed(0, 0, 1, 0, 0);
|
||||
INJECTION_POINT(name);
|
||||
INJECTION_POINT(name, NULL);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -420,7 +423,7 @@ injection_points_cached(PG_FUNCTION_ARGS)
|
||||
char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||
|
||||
pgstat_report_inj_fixed(0, 0, 0, 1, 0);
|
||||
INJECTION_POINT_CACHED(name);
|
||||
INJECTION_POINT_CACHED(name, NULL);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user