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 /src/test/modules/injection_points/injection_points.c | |
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 'src/test/modules/injection_points/injection_points.c')
-rw-r--r-- | src/test/modules/injection_points/injection_points.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c index ad528d77752..44eda3caa05 100644 --- a/src/test/modules/injection_points/injection_points.c +++ b/src/test/modules/injection_points/injection_points.c @@ -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(); } |