1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-09 13:09:39 +03:00

Support loading of injection points

This can be used to load an injection point and prewarm the
backend-level cache before running it, to avoid issues if the point
cannot be loaded due to restrictions in the code path where it would be
run, like a critical section where no memory allocation can happen
(load_external_function() can do allocations when expanding a library
name).

Tests can use a macro called INJECTION_POINT_LOAD() to load an injection
point.  The test module injection_points gains some tests, and a SQL
function able to load an injection point.

Based on a request from Andrey Borodin, who has implemented a test for
multixacts requiring this facility.

Reviewed-by: Andrey Borodin
Discussion: https://postgr.es/m/ZkrBE1e2q2wGvsoN@paquier.xyz
This commit is contained in:
Michael Paquier
2024-07-05 17:41:49 +09:00
parent 98347b5a3a
commit 4b211003ec
7 changed files with 168 additions and 36 deletions

View File

@@ -302,6 +302,23 @@ injection_points_attach(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
/*
* SQL function for loading an injection point.
*/
PG_FUNCTION_INFO_V1(injection_points_load);
Datum
injection_points_load(PG_FUNCTION_ARGS)
{
char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
if (inj_state == NULL)
injection_init_shmem();
INJECTION_POINT_LOAD(name);
PG_RETURN_VOID();
}
/*
* SQL function for triggering an injection point.
*/