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

Function ParseRolesArray

pg_documentdb/src/commands/roles.c:389–422  ·  view source on GitHub ↗

* ParseRolesArray parses the "roles" array from the createRole command. * Extracts inherited built-in role names. */

Source from the content-addressed store, hash-verified

387 * Extracts inherited built-in role names.
388 */
389static void
390ParseRolesArray(bson_iter_t *rolesIter, CreateRoleSpec *createRoleSpec)
391{
392 if (bson_iter_type(rolesIter) != BSON_TYPE_ARRAY)
393 {
394 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
395 errmsg(
396 "Expected 'array' type for 'roles' parameter but found '%s' type",
397 BsonTypeName(bson_iter_type(rolesIter)))));
398 }
399
400 bson_iter_t rolesArrayIter;
401 bson_iter_recurse(rolesIter, &rolesArrayIter);
402
403 while (bson_iter_next(&rolesArrayIter))
404 {
405 if (bson_iter_type(&rolesArrayIter) != BSON_TYPE_UTF8)
406 {
407 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
408 errmsg(
409 "Invalid inherited from role name provided.")));
410 }
411
412 uint32_t roleNameLength = 0;
413 const char *inheritedBuiltInRole = bson_iter_utf8(&rolesArrayIter,
414 &roleNameLength);
415
416 if (roleNameLength > 0 && roleNameLength < NAMEDATALEN)
417 {
418 hash_search(createRoleSpec->parentRoles, inheritedBuiltInRole, HASH_ENTER,
419 NULL);
420 }
421 }
422}
423
424
425/*

Callers 1

ParseCreateRoleSpecFunction · 0.85

Calls 1

BsonTypeNameFunction · 0.85

Tested by

no test coverage detected