1/*--------------------------------------------------------------------------
3 * test_lwlock_tranches.c
4 * Test code for LWLock tranches allocated by extensions.
6 * Copyright (c) 2025, PostgreSQL Global Development Group
9 * src/test/modules/test_lwlock_tranches/test_lwlock_tranches.c
11 * -------------------------------------------------------------------------
24 #define STARTUP_TRANCHE_NAME "test_lwlock_tranches_startup"
25 #define DYNAMIC_TRANCHE_NAME "test_lwlock_tranches_dynamic"
27 #define NUM_STARTUP_TRANCHES (32)
28 #define NUM_DYNAMIC_TRANCHES (256 - NUM_STARTUP_TRANCHES)
30 #define GET_TRANCHE_NAME(a) GetLWLockIdentifier(PG_WAIT_LWLOCK, (a))
53 * Checks that GetLWLockIdentifier() returns the expected value for tranches
54 * registered via RequestNamedLWLockTranche() and LWLockNewTrancheId().
69 elog(
ERROR,
"incorrect startup lock tranche name");
76 elog(
ERROR,
"incorrect dynamic lock tranche name");
83 * Wrapper for LWLockNewTrancheId().
97 * Wrapper for GetNamedLWLockTranche().
111 * Wrapper for LWLockInitialize().
#define TextDatumGetCString(d)
#define PG_GETARG_DATUM(n)
#define PG_GETARG_INT32(n)
int LWLockNewTrancheId(const char *name)
LWLockPadded * GetNamedLWLockTranche(const char *tranche_name)
void RequestNamedLWLockTranche(const char *tranche_name, int num_lwlocks)
void LWLockInitialize(LWLock *lock, int tranche_id)
@ LWTRANCHE_FIRST_USER_DEFINED
void(* shmem_request_hook_type)(void)
shmem_request_hook_type shmem_request_hook
Datum test_lwlock_tranche_creation(PG_FUNCTION_ARGS)
#define STARTUP_TRANCHE_NAME
#define NUM_STARTUP_TRANCHES
PG_FUNCTION_INFO_V1(test_lwlock_tranches)
static shmem_request_hook_type prev_shmem_request_hook
Datum test_lwlock_tranche_lookup(PG_FUNCTION_ARGS)
#define GET_TRANCHE_NAME(a)
Datum test_lwlock_tranches(PG_FUNCTION_ARGS)
static void test_lwlock_tranches_shmem_request(void)
#define NUM_DYNAMIC_TRANCHES
#define DYNAMIC_TRANCHE_NAME
Datum test_lwlock_initialize(PG_FUNCTION_ARGS)