(&mut self)
| 6400 | } |
| 6401 | |
| 6402 | fn parse_alter_default_privileges(&mut self) -> Result<Statement<Raw>, ParserError> { |
| 6403 | self.expect_keyword(FOR)?; |
| 6404 | let target_roles = match self.expect_one_of_keywords(&[ROLE, USER, ALL])? { |
| 6405 | ROLE | USER => TargetRoleSpecification::Roles( |
| 6406 | self.parse_comma_separated(Parser::parse_identifier)?, |
| 6407 | ), |
| 6408 | ALL => { |
| 6409 | self.expect_keyword(ROLES)?; |
| 6410 | TargetRoleSpecification::AllRoles |
| 6411 | } |
| 6412 | _ => unreachable!(), |
| 6413 | }; |
| 6414 | let target_objects = if self.parse_keyword(IN) { |
| 6415 | match self.expect_one_of_keywords(&[SCHEMA, DATABASE])? { |
| 6416 | SCHEMA => GrantTargetAllSpecification::AllSchemas { |
| 6417 | schemas: self.parse_comma_separated(Parser::parse_schema_name)?, |
| 6418 | }, |
| 6419 | DATABASE => GrantTargetAllSpecification::AllDatabases { |
| 6420 | databases: self.parse_comma_separated(Parser::parse_database_name)?, |
| 6421 | }, |
| 6422 | _ => unreachable!(), |
| 6423 | } |
| 6424 | } else { |
| 6425 | GrantTargetAllSpecification::All |
| 6426 | }; |
| 6427 | let is_grant = self.expect_one_of_keywords(&[GRANT, REVOKE])? == GRANT; |
| 6428 | let privileges = self.parse_privilege_specification().ok_or_else(|| { |
| 6429 | self.expected::<_, PrivilegeSpecification>( |
| 6430 | self.peek_pos(), |
| 6431 | "ALL or INSERT or SELECT or UPDATE or DELETE or USAGE or CREATE", |
| 6432 | self.peek_token(), |
| 6433 | ) |
| 6434 | .expect_err("only returns errors") |
| 6435 | })?; |
| 6436 | self.expect_keyword(ON)?; |
| 6437 | let object_type = |
| 6438 | self.expect_grant_revoke_plural_object_type(if is_grant { "GRANT" } else { "REVOKE" })?; |
| 6439 | if is_grant { |
| 6440 | self.expect_keyword(TO)?; |
| 6441 | } else { |
| 6442 | self.expect_keyword(FROM)?; |
| 6443 | } |
| 6444 | let grantees = self.parse_comma_separated(Parser::expect_role_specification)?; |
| 6445 | |
| 6446 | let grant_or_revoke = if is_grant { |
| 6447 | AbbreviatedGrantOrRevokeStatement::Grant(AbbreviatedGrantStatement { |
| 6448 | privileges, |
| 6449 | object_type, |
| 6450 | grantees, |
| 6451 | }) |
| 6452 | } else { |
| 6453 | AbbreviatedGrantOrRevokeStatement::Revoke(AbbreviatedRevokeStatement { |
| 6454 | privileges, |
| 6455 | object_type, |
| 6456 | revokees: grantees, |
| 6457 | }) |
| 6458 | }; |
| 6459 |
no test coverage detected