* GrantRoleInheritance grants a parent role to the target role. * Only allows inheriting from roles in IS_INHERITABLE_ROLE whitelist. */
| 1855 | * Only allows inheriting from roles in IS_INHERITABLE_ROLE whitelist. |
| 1856 | */ |
| 1857 | static void |
| 1858 | GrantRoleInheritance(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 | /* |
no test coverage detected