From e87fdd1a33d2f611023a71e9e77e679a1c2f9855 Mon Sep 17 00:00:00 2001 From: Ning Yu Date: Wed, 16 Jan 2019 10:46:27 +0800 Subject: [PATCH] resgroup: provide an API to get resgroup id of my proc Resource group id of my proc is stored in a local variable accessible only in resgroup.c, but this information can also be interested in other contexts, so an API `GetMyResGroupId()` is provided to get this information. Reviewed-by: Heikki Linnakangas Reviewed-by: Hao Wang --- src/backend/utils/resgroup/resgroup.c | 21 +++++++++++++++++++++ src/include/utils/resgroup.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/src/backend/utils/resgroup/resgroup.c b/src/backend/utils/resgroup/resgroup.c index 77ec3b2ec4..cc2f88f936 100644 --- a/src/backend/utils/resgroup/resgroup.c +++ b/src/backend/utils/resgroup/resgroup.c @@ -932,6 +932,27 @@ ResGroupIsAssigned(void) return selfIsAssigned(); } +/* + * Get resource group id of my proc. + * + * Returns InvalidOid in any of below cases: + * - resource group is not enabled; + * - resource group is not activated (initialized); + * - my proc is not running inside a transaction; + * - my proc is not assigned a resource group yet; + * + * Otherwise a valid resource group id is returned. + * + * This function is not dead code although there is no consumer in the gpdb + * code tree. Some extensions require this to get the internal resource group + * information. + */ +Oid +GetMyResGroupId(void) +{ + return self->groupId; +} + int32 ResGroupGetVmemLimitChunks(void) { diff --git a/src/include/utils/resgroup.h b/src/include/utils/resgroup.h index b17818edd4..956cdf1226 100644 --- a/src/include/utils/resgroup.h +++ b/src/include/utils/resgroup.h @@ -168,6 +168,15 @@ extern void ResGroupCreateOnAbort(const ResourceGroupCallbackContext *callbackCt extern void ResGroupAlterOnCommit(const ResourceGroupCallbackContext *callbackCtx); extern void ResGroupCheckForDrop(Oid groupId, char *name); +/* + * Get resource group id of my proc. + * + * This function is not dead code although there is no consumer in the gpdb + * code tree. Some extensions require this to get the internal resource group + * information. + */ +extern Oid GetMyResGroupId(void); + extern int32 ResGroupGetVmemLimitChunks(void); extern int32 ResGroupGetVmemChunkSizeInBits(void); extern int32 ResGroupGetMaxChunksPerQuery(void); -- GitLab