mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +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:
2
src/backend/utils/cache/catcache.c
vendored
2
src/backend/utils/cache/catcache.c
vendored
@@ -1926,7 +1926,7 @@ SearchCatCacheList(CatCache *cache,
|
||||
/* Injection point to help testing the recursive invalidation case */
|
||||
if (first_iter)
|
||||
{
|
||||
INJECTION_POINT("catcache-list-miss-systable-scan-started");
|
||||
INJECTION_POINT("catcache-list-miss-systable-scan-started", NULL);
|
||||
first_iter = false;
|
||||
}
|
||||
|
||||
|
||||
2
src/backend/utils/cache/inval.c
vendored
2
src/backend/utils/cache/inval.c
vendored
@@ -1207,7 +1207,7 @@ AtEOXact_Inval(bool isCommit)
|
||||
/* Must be at top of stack */
|
||||
Assert(transInvalInfo->my_level == 1 && transInvalInfo->parent == NULL);
|
||||
|
||||
INJECTION_POINT("transaction-end-process-inval");
|
||||
INJECTION_POINT("transaction-end-process-inval", NULL);
|
||||
|
||||
if (isCommit)
|
||||
{
|
||||
|
||||
2
src/backend/utils/cache/typcache.c
vendored
2
src/backend/utils/cache/typcache.c
vendored
@@ -952,7 +952,7 @@ lookup_type_cache(Oid type_id, int flags)
|
||||
load_domaintype_info(typentry);
|
||||
}
|
||||
|
||||
INJECTION_POINT("typecache-before-rel-type-cache-insert");
|
||||
INJECTION_POINT("typecache-before-rel-type-cache-insert", NULL);
|
||||
|
||||
Assert(in_progress_offset + 1 == in_progress_list_len);
|
||||
in_progress_list_len--;
|
||||
|
||||
@@ -747,7 +747,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
|
||||
if (!bootstrap)
|
||||
{
|
||||
pgstat_bestart_initial();
|
||||
INJECTION_POINT("init-pre-auth");
|
||||
INJECTION_POINT("init-pre-auth", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -541,14 +541,14 @@ InjectionPointLoad(const char *name)
|
||||
* Execute an injection point, if defined.
|
||||
*/
|
||||
void
|
||||
InjectionPointRun(const char *name)
|
||||
InjectionPointRun(const char *name, void *arg)
|
||||
{
|
||||
#ifdef USE_INJECTION_POINTS
|
||||
InjectionPointCacheEntry *cache_entry;
|
||||
|
||||
cache_entry = InjectionPointCacheRefresh(name);
|
||||
if (cache_entry)
|
||||
cache_entry->callback(name, cache_entry->private_data);
|
||||
cache_entry->callback(name, cache_entry->private_data, arg);
|
||||
#else
|
||||
elog(ERROR, "Injection points are not supported by this build");
|
||||
#endif
|
||||
@@ -558,14 +558,14 @@ InjectionPointRun(const char *name)
|
||||
* Execute an injection point directly from the cache, if defined.
|
||||
*/
|
||||
void
|
||||
InjectionPointCached(const char *name)
|
||||
InjectionPointCached(const char *name, void *arg)
|
||||
{
|
||||
#ifdef USE_INJECTION_POINTS
|
||||
InjectionPointCacheEntry *cache_entry;
|
||||
|
||||
cache_entry = injection_point_cache_get(name);
|
||||
if (cache_entry)
|
||||
cache_entry->callback(name, cache_entry->private_data);
|
||||
cache_entry->callback(name, cache_entry->private_data, arg);
|
||||
#else
|
||||
elog(ERROR, "Injection points are not supported by this build");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user