40#define INJ_NAME_MAXLEN 64
97 const void *private_data,
100 const void *private_data,
103 const void *private_data,
123 memset(
state->wait_counts, 0,
sizeof(
state->wait_counts));
196 switch (condition->
type)
236 char *argstr = (
char *)
arg;
242 elog(
ERROR,
"error triggered for injection point %s (%s)",
252 char *argstr = (
char *)
arg;
258 elog(
NOTICE,
"notice triggered for injection point %s (%s)",
268 uint32 old_wait_counts = 0;
270 uint32 injection_wait_event = 0;
303 elog(
ERROR,
"could not find free slot for wait of injection point %s ",
316 if (old_wait_counts != new_wait_counts)
340 if (strcmp(
action,
"error") == 0)
342 else if (strcmp(
action,
"notice") == 0)
344 else if (strcmp(
action,
"wait") == 0)
347 elog(
ERROR,
"incorrect action \"%s\" for injection point creation",
action);
382 bytea *private_data = NULL;
383 int private_data_size = 0;
386 elog(
ERROR,
"injection point name cannot be NULL");
388 elog(
ERROR,
"injection point library cannot be NULL");
390 elog(
ERROR,
"injection point function cannot be NULL");
402 if (private_data != NULL)
498 elog(
ERROR,
"could not find injection point %s to wake up",
name);
544 elog(
ERROR,
"could not detach injection point \"%s\"",
name);
566#define NUM_INJECTION_POINTS_LIST 3
576 foreach(lc, inj_points)
583 memset(nulls, 0,
sizeof(nulls));
594#undef NUM_INJECTION_POINTS_LIST
static Datum values[MAXATTR]
bool ConditionVariableCancelSleep(void)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
void * GetNamedDSMSegment(const char *name, size_t size, void(*init_callback)(void *ptr), bool *found)
#define PG_GETARG_BYTEA_PP(n)
#define PG_GETARG_TEXT_PP(n)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
bool InjectionPointDetach(const char *name)
List * InjectionPointList(void)
void InjectionPointAttach(const char *name, const char *library, const char *function, const void *private_data, int private_data_size)
#define INJECTION_POINT(name, arg)
#define INJECTION_POINT_CACHED(name, arg)
#define INJECTION_POINT_LOAD(name)
Datum injection_points_detach(PG_FUNCTION_ARGS)
static bool injection_point_local
static void injection_shmem_request(void)
PG_FUNCTION_INFO_V1(injection_points_attach)
PGDLLEXPORT void injection_wait(const char *name, const void *private_data, void *arg)
InjectionPointConditionType
static void injection_init_shmem(void)
Datum injection_points_cached(PG_FUNCTION_ARGS)
Datum injection_points_attach(PG_FUNCTION_ARGS)
struct InjectionPointCondition InjectionPointCondition
Datum injection_points_run(PG_FUNCTION_ARGS)
static List * inj_list_local
Datum injection_points_set_local(PG_FUNCTION_ARGS)
static shmem_startup_hook_type prev_shmem_startup_hook
static bool injection_point_allowed(InjectionPointCondition *condition)
static shmem_request_hook_type prev_shmem_request_hook
static void injection_points_cleanup(int code, Datum arg)
static void injection_shmem_startup(void)
PGDLLEXPORT void injection_error(const char *name, const void *private_data, void *arg)
struct InjectionPointSharedState InjectionPointSharedState
Datum injection_points_attach_func(PG_FUNCTION_ARGS)
#define NUM_INJECTION_POINTS_LIST
Datum injection_points_wakeup(PG_FUNCTION_ARGS)
PGDLLEXPORT void injection_notice(const char *name, const void *private_data, void *arg)
Datum injection_points_list(PG_FUNCTION_ARGS)
static void injection_point_init_state(void *ptr)
static InjectionPointSharedState * inj_state
Datum injection_points_load(PG_FUNCTION_ARGS)
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
void(* shmem_startup_hook_type)(void)
shmem_startup_hook_type shmem_startup_hook
void RequestAddinShmemSpace(Size size)
List * lappend(List *list, void *datum)
List * list_delete(List *list, void *datum)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
char * pstrdup(const char *in)
MemoryContext TopMemoryContext
void(* shmem_request_hook_type)(void)
shmem_request_hook_type shmem_request_hook
bool process_shared_preload_libraries_in_progress
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
on_exit_nicely_callback function
size_t strlcpy(char *dst, const char *src, size_t siz)
static Datum PointerGetDatum(const void *X)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
InjectionPointConditionType type
uint32 wait_counts[INJ_MAX_WAIT]
char name[INJ_MAX_WAIT][INJ_NAME_MAXLEN]
ConditionVariable wait_point
Tuplestorestate * setResult
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
String * makeString(char *str)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)
uint32 WaitEventInjectionPointNew(const char *wait_event_name)