From 20e0e7da9bc0089433c70b2b53ddf6a340ab5df3 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 26 Jul 2024 15:12:21 +0300 Subject: Add test for early backend startup errors The new test tests the libpq fallback behavior on an early error, which was fixed in the previous commit. This adds an IS_INJECTION_POINT_ATTACHED() macro, to allow writing injected test code alongside the normal source code. In principle, the new test could've been implemented by an extra test module with a callback that sets the FrontendProtocol global variable, but I think it's more clear to have the test code right where the injection point is, because it has pretty intimate knowledge of the surrounding context it runs in. Reviewed-by: Michael Paquier Discussion: https://www.postgresql.org/message-id/CAOYmi%2Bnwvu21mJ4DYKUa98HdfM_KZJi7B1MhyXtnsyOO-PB6Ww%40mail.gmail.com --- src/backend/utils/misc/injection_point.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/backend/utils/misc/injection_point.c') diff --git a/src/backend/utils/misc/injection_point.c b/src/backend/utils/misc/injection_point.c index 8ab5bc63276..80bc32b0e08 100644 --- a/src/backend/utils/misc/injection_point.c +++ b/src/backend/utils/misc/injection_point.c @@ -570,3 +570,17 @@ InjectionPointCached(const char *name) elog(ERROR, "Injection points are not supported by this build"); #endif } + +/* + * Test if an injection point is defined. + */ +bool +IsInjectionPointAttached(const char *name) +{ +#ifdef USE_INJECTION_POINTS + return InjectionPointCacheRefresh(name) != NULL; +#else + elog(ERROR, "Injection points are not supported by this build"); + return false; /* silence compiler */ +#endif +} -- cgit v1.2.3