MCPcopy Create free account
hub / github.com/documentdb/documentdb / GrantRoleInheritance

Function GrantRoleInheritance

pg_documentdb/src/commands/roles.c:1857–1878  ·  view source on GitHub ↗

* GrantRoleInheritance grants a parent role to the target role. * Only allows inheriting from roles in IS_INHERITABLE_ROLE whitelist. */

Source from the content-addressed store, hash-verified

1855 * Only allows inheriting from roles in IS_INHERITABLE_ROLE whitelist.
1856 */
1857static void
1858GrantRoleInheritance(const char *parentRole, const char *targetRole)
1859{
1860 if (!IS_INHERITABLE_ROLE(parentRole))
1861 {
1862 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
1863 errmsg(
1864 "Creating custom roles that inherit from '%s' is not supported.",
1865 GetNativeRoleName(parentRole))));
1866 }
1867
1868 bool readOnly = false;
1869 bool isNull = false;
1870
1871 StringInfo grantRoleInfo = makeStringInfo();
1872 appendStringInfo(grantRoleInfo, "GRANT %s TO %s",
1873 quote_identifier(parentRole),
1874 quote_identifier(targetRole));
1875
1876 ExtensionExecuteQueryViaSPI(grantRoleInfo->data, readOnly, SPI_OK_UTILITY,
1877 &isNull);
1878}
1879
1880
1881/*

Callers 1

Calls 2

GetNativeRoleNameFunction · 0.85

Tested by

no test coverage detected