diff --git a/src/backend/utils/resgroup/resgroup.c b/src/backend/utils/resgroup/resgroup.c index 77ec3b2ec4154bdd77431128f20fa53580602c10..cc2f88f936cb177e8fae2d260ad05092853190a0 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 b17818edd4a9e52d16a91d8093e849ee6767c1a6..956cdf1226029dd042cc75ce4f2a524db2d27c90 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);