* 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. */
| 294 | * The rolesTable should contain StringView entries representing role names. |
| 295 | */ |
| 296 | void |
| 297 | WriteMultipleRolePrivileges(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 | /* |
no test coverage detected