1/*--------------------------------------------------------------------------
4 * Test dynamic shared memory areas (DSAs)
6 * Copyright (c) 2022-2025, PostgreSQL Global Development Group
9 * src/test/modules/test_dsa/test_dsa.c
11 * -------------------------------------------------------------------------
22/* Test basic DSA functionality */
31 /* XXX: this tranche is leaked */
35 for (
int i = 0;
i < 100;
i++)
41 for (
int i = 0;
i < 100;
i++)
50 for (
int i = 0;
i < 100;
i++)
60/* Test using DSA across different resource owners */
71 /* XXX: this tranche is leaked */
74 /* Create DSA in parent resource owner */
78 * Switch to child resource owner, and do a bunch of allocations in the
85 for (
int i = 0;
i < 10000;
i++)
91 /* Also test freeing, by freeing some of the allocations. */
92 for (
int i = 0;
i < 500;
i++)
95 /* Release the child resource owner */
void * dsa_get_address(dsa_area *area, dsa_pointer dp)
void dsa_detach(dsa_area *area)
void dsa_free(dsa_area *area, dsa_pointer dp)
#define dsa_create(tranche_id)
#define dsa_allocate(area, size)
int LWLockNewTrancheId(const char *name)
ResourceOwner ResourceOwnerCreate(ResourceOwner parent, const char *name)
ResourceOwner CurrentResourceOwner
void ResourceOwnerRelease(ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
void ResourceOwnerDelete(ResourceOwner owner)
@ RESOURCE_RELEASE_BEFORE_LOCKS
@ RESOURCE_RELEASE_AFTER_LOCKS
Datum test_dsa_basic(PG_FUNCTION_ARGS)
Datum test_dsa_resowners(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(test_dsa_basic)