* Helper function to parse a role definition (string or document) */
| 1089 | * Helper function to parse a role definition (string or document) |
| 1090 | */ |
| 1091 | static void |
| 1092 | ParseRoleDefinition(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 | /* |
no test coverage detected