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

Function WriteMultipleRolePrivileges

pg_documentdb/src/utils/role_utils.c:296–324  ·  view source on GitHub ↗

* Consolidates privileges for all roles in the provided HTAB and * writes them to the provided BSON array writer. * The rolesTable should contain StringView entries representing role names. */

Source from the content-addressed store, hash-verified

294 * The rolesTable should contain StringView entries representing role names.
295 */
296void
297WriteMultipleRolePrivileges(HTAB *rolesTable,
298 pgbson_array_writer *privilegesArrayWriter)
299{
300 if (rolesTable == NULL)
301 {
302 return;
303 }
304
305 List *consolidatedPrivileges = NIL;
306 HASH_SEQ_STATUS status;
307 StringView *roleEntry;
308
309 hash_seq_init(&status, rolesTable);
310 while ((roleEntry = hash_seq_search(&status)) != NULL)
311 {
312 /* Convert StringView to null-terminated string */
313 char *roleName = palloc(roleEntry->length + 1);
314 memcpy(roleName, roleEntry->string, roleEntry->length);
315 roleName[roleEntry->length] = '\0';
316
317 ConsolidatePrivilegesForRole(roleName, &consolidatedPrivileges);
318
319 pfree(roleName);
320 }
321
322 WritePrivilegeListToArray(consolidatedPrivileges, privilegesArrayWriter);
323 DeepFreePrivileges(consolidatedPrivileges);
324}
325
326
327/*

Callers 2

WriteSingleUserDocumentFunction · 0.85
WriteRoleResponseFunction · 0.85

Calls 3

DeepFreePrivilegesFunction · 0.85

Tested by

no test coverage detected