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

Function LookupAllInheritedRoles

pg_documentdb/src/commands/roles.c:1236–1260  ·  view source on GitHub ↗

* Look up all inherited roles (transitive closure) from the pre-built role * inheritance table using recursive traversal. * * Handles diamond inheritance (e.g., role A inherits B and C, both B and C * inherit D) by using a hash set that serves for both deduplication and * collecting results. */

Source from the content-addressed store, hash-verified

1234 * collecting results.
1235 */
1236static List *
1237LookupAllInheritedRoles(const char *internalRoleName, HTAB *roleInheritanceTable)
1238{
1239 HASHCTL resultCtl;
1240 MemSet(&resultCtl, 0, sizeof(resultCtl));
1241 resultCtl.keysize = NAMEDATALEN;
1242 resultCtl.entrysize = NAMEDATALEN;
1243 HTAB *resultSet = hash_create("InheritedRolesSet", 32, &resultCtl,
1244 HASH_ELEM | HASH_STRINGS);
1245
1246 CollectInheritedRolesRecursive(internalRoleName, roleInheritanceTable, resultSet);
1247
1248 /* Convert hash set to list */
1249 List *result = NIL;
1250 HASH_SEQ_STATUS status;
1251 char *entry;
1252 hash_seq_init(&status, resultSet);
1253 while ((entry = hash_seq_search(&status)) != NULL)
1254 {
1255 result = lappend(result, pstrdup(entry));
1256 }
1257
1258 hash_destroy(resultSet);
1259 return result;
1260}
1261
1262
1263/*

Callers 1

WriteRoleResponseFunction · 0.85

Calls 1

Tested by

no test coverage detected