From cae6fc2bc27cdb072693076249ce688f048ca7b7 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 15 Sep 2021 10:47:44 +0900 Subject: [PATCH] Update README for resource owners about the resource types supported All the types supported were listed directly in the README, but it was very outdated. Rather than listing all the types supported in the README, this commit adds a reference to look at ResourceOwnerData in resowner.c to get this information. The order of the paragraphs is reworked a bit for clarity. Author: Amit Langote Discussion: https://postgr.es/m/CA+HiwqHtfT9z=4H5+F7DOy0OyNHAaVwuRcakt9b2t2uADOaiag@mail.gmail.com --- src/backend/utils/resowner/README | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/backend/utils/resowner/README b/src/backend/utils/resowner/README index 2998f6bb362..f94c9700df4 100644 --- a/src/backend/utils/resowner/README +++ b/src/backend/utils/resowner/README @@ -54,20 +54,19 @@ The basic operations on a ResourceOwner are: * delete a ResourceOwner (including child owner objects); all resources must have been released beforehand +This API directly supports the resource types listed in the definition of +ResourceOwnerData struct in src/backend/utils/resowner/resowner.c. +Other objects can be associated with a ResourceOwner by recording the address +of the owning ResourceOwner in such an object. There is an API for other +modules to get control during ResourceOwner release, so that they can scan +their own data structures to find the objects that need to be deleted. + Locks are handled specially because in non-error situations a lock should be held until end of transaction, even if it was originally taken by a subtransaction or portal. Therefore, the "release" operation on a child ResourceOwner transfers lock ownership to the parent instead of actually releasing the lock, if isCommit is true. -Currently, ResourceOwners contain direct support for recording ownership of -buffer pins, lmgr locks, and catcache, relcache, plancache, tupdesc, and -snapshot references. Other objects can be associated with a ResourceOwner by -recording the address of the owning ResourceOwner in such an object. There is -an API for other modules to get control during ResourceOwner release, so that -they can scan their own data structures to find the objects that need to be -deleted. - Whenever we are inside a transaction, the global variable CurrentResourceOwner shows which resource owner should be assigned ownership of acquired resources. Note however that CurrentResourceOwner