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

Function ParseRoleDefinition

pg_documentdb/src/commands/roles.c:1091–1116  ·  view source on GitHub ↗

* Helper function to parse a role definition (string or document) */

Source from the content-addressed store, hash-verified

1089 * Helper function to parse a role definition (string or document)
1090 */
1091static void
1092ParseRoleDefinition(bson_iter_t *iter, RolesInfoSpec *rolesInfoSpec)
1093{
1094 if (bson_iter_type(iter) == BSON_TYPE_UTF8)
1095 {
1096 uint32_t roleNameLength = 0;
1097 const char *roleName = bson_iter_utf8(iter, &roleNameLength);
1098
1099 /* If the string is empty, we will not add it to the list of roles to fetched */
1100 if (roleNameLength > 0)
1101 {
1102 rolesInfoSpec->roleNames = lappend(rolesInfoSpec->roleNames, pstrdup(
1103 roleName));
1104 }
1105 }
1106 else if (bson_iter_type(iter) == BSON_TYPE_DOCUMENT)
1107 {
1108 ParseRoleDocument(iter, rolesInfoSpec);
1109 }
1110 else
1111 {
1112 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
1113 errmsg(
1114 "'rolesInfo' must be 1, a string, a document, or an array.")));
1115 }
1116}
1117
1118
1119/*

Callers 1

ParseRolesInfoSpecFunction · 0.85

Calls 1

ParseRoleDocumentFunction · 0.85

Tested by

no test coverage detected