73 Assert(last_release_priority <= mres->kind->desc.release_priority);
123 for (
int i = 0;
i < nresources;
i++)
127 mres->
kind = &kinds[kind_idx];
137 kind_idx = (kind_idx + 1) % nkinds;
153 if (ntotal < nresources)
154 elog(
PANIC,
"cannot free %d resources, only %d remembered", nresources, ntotal);
156 for (
int i = 0;
i < nresources;
i++)
160 for (
int j = 0;
j < nkinds;
j++)
162 kind_idx = (kind_idx + 1) % nkinds;
177 elog(
ERROR,
"could not find a test resource to forget");
189 for (
int i = 0;
i < nkinds;
i++)
190 ntotal += kinds[
i].nremembered - kinds[
i].nforgotten - kinds[
i].nreleased;
220 if (nremember_bl < 0)
221 elog(
ERROR,
"nremember_bl must be >= 0");
222 if (nforget_bl < 0 || nforget_bl > nremember_bl)
223 elog(
ERROR,
"nforget_bl must between 0 and 'nremember_bl'");
224 if (nremember_al < 0)
225 elog(
ERROR,
"nremember_al must be greater than zero");
226 if (nforget_al < 0 || nforget_al > nremember_al)
227 elog(
ERROR,
"nforget_al must between 0 and 'nremember_al'");
231 for (
int i = 0;
i < nkinds;
i++)
239 for (
int i = 0;
i < nkinds;
i++)
250 if (nremember_bl > 0)
252 elog(
NOTICE,
"remembering %d before-locks resources", nremember_bl);
255 if (nremember_al > 0)
257 elog(
NOTICE,
"remembering %d after-locks resources", nremember_al);
264 elog(
NOTICE,
"forgetting %d before-locks resources", nforget_bl);
270 elog(
NOTICE,
"forgetting %d after-locks resources", nforget_al);
275 elog(
NOTICE,
"releasing resources before locks");
286 elog(
NOTICE,
"releasing resources after locks");
#define Assert(condition)
static void PGresult * res
#define PG_GETARG_INT32(n)
static void dlist_init(dlist_head *head)
#define dlist_head_element(type, membername, lhead)
static void dlist_delete(dlist_node *node)
static bool dlist_is_empty(const dlist_head *head)
static void dlist_push_tail(dlist_head *head, dlist_node *node)
static void dlist_node_init(dlist_node *node)
void pfree(void *pointer)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
char * psprintf(const char *fmt,...)
ResourceOwner ResourceOwnerCreate(ResourceOwner parent, const char *name)
ResourceOwner CurrentResourceOwner
void ResourceOwnerRelease(ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
void ResourceOwnerForget(ResourceOwner owner, Datum value, const ResourceOwnerDesc *kind)
void ResourceOwnerDelete(ResourceOwner owner)
void ResourceOwnerRemember(ResourceOwner owner, Datum value, const ResourceOwnerDesc *kind)
void ResourceOwnerEnlarge(ResourceOwner owner)
@ RESOURCE_RELEASE_BEFORE_LOCKS
@ RESOURCE_RELEASE_AFTER_LOCKS
#define RELEASE_PRIO_FIRST
dlist_head current_resources
ManyTestResourceKind * kind
char *(* DebugPrint)(Datum res)
ResourceReleasePhase release_phase
void(* ReleaseResource)(Datum res)
ResourceReleasePriority release_priority
static int GetTotalResourceCount(ManyTestResourceKind *kinds, int nkinds)
static void InitManyTestResourceKind(ManyTestResourceKind *kind, char *name, ResourceReleasePhase phase, uint32 priority)
PG_FUNCTION_INFO_V1(test_resowner_many)
static void ForgetManyTestResources(ResourceOwner owner, ManyTestResourceKind *kinds, int nkinds, int nresources)
static void ReleaseManyTestResource(Datum res)
static ResourceReleasePhase current_release_phase
static void RememberManyTestResources(ResourceOwner owner, ManyTestResourceKind *kinds, int nkinds, int nresources)
Datum test_resowner_many(PG_FUNCTION_ARGS)
static char * PrintManyTest(Datum res)
static uint32 last_release_priority