mirror of
https://github.com/postgres/postgres.git
synced 2026-03-07 07:40:31 -05:00
This new macro is able to perform a direct lookup from the local cache of injection points (refreshed each time a point is loaded or run), without touching the shared memory state of injection points at all. This works in combination with INJECTION_POINT_LOAD(), and it is better than INJECTION_POINT() in a critical section due to the fact that it would avoid all memory allocations should a concurrent detach happen since a LOAD(), as it retrieves a callback from the backend-private memory. The documentation is updated to describe in more details how to use this new macro with a load. Some tests are added to the module injection_points based on a new SQL function that acts as a wrapper of INJECTION_POINT_CACHED(). Based on a suggestion from Heikki Linnakangas. Author: Heikki Linnakangas, Michael Paquier Discussion: https://postgr.es/m/58d588d0-e63f-432f-9181-bed29313dece@iki.fi
46 lines
1.5 KiB
C
46 lines
1.5 KiB
C
/*-------------------------------------------------------------------------
|
|
* injection_point.h
|
|
* Definitions related to injection points.
|
|
*
|
|
* Copyright (c) 2001-2024, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/utils/injection_point.h
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef INJECTION_POINT_H
|
|
#define INJECTION_POINT_H
|
|
|
|
/*
|
|
* Injections points require --enable-injection-points.
|
|
*/
|
|
#ifdef USE_INJECTION_POINTS
|
|
#define INJECTION_POINT_LOAD(name) InjectionPointLoad(name)
|
|
#define INJECTION_POINT(name) InjectionPointRun(name)
|
|
#define INJECTION_POINT_CACHED(name) InjectionPointCached(name)
|
|
#else
|
|
#define INJECTION_POINT_LOAD(name) ((void) name)
|
|
#define INJECTION_POINT(name) ((void) name)
|
|
#define INJECTION_POINT_CACHED(name) ((void) name)
|
|
#endif
|
|
|
|
/*
|
|
* Typedef for callback function launched by an injection point.
|
|
*/
|
|
typedef void (*InjectionPointCallback) (const char *name,
|
|
const void *private_data);
|
|
|
|
extern Size InjectionPointShmemSize(void);
|
|
extern void InjectionPointShmemInit(void);
|
|
|
|
extern void InjectionPointAttach(const char *name,
|
|
const char *library,
|
|
const char *function,
|
|
const void *private_data,
|
|
int private_data_size);
|
|
extern void InjectionPointLoad(const char *name);
|
|
extern void InjectionPointRun(const char *name);
|
|
extern void InjectionPointCached(const char *name);
|
|
extern bool InjectionPointDetach(const char *name);
|
|
|
|
#endif /* INJECTION_POINT_H */
|