@@ -12130,7 +12130,7 @@ impl<'a> Parser<'a> {
1213012130
1213112131 pub fn parse_grant_revoke_privileges_objects(
1213212132 &mut self,
12133- ) -> Result<(Privileges, GrantObjects), ParserError> {
12133+ ) -> Result<(Privileges, Option< GrantObjects> ), ParserError> {
1213412134 let privileges = if self.parse_keyword(Keyword::ALL) {
1213512135 Privileges::All {
1213612136 with_privileges_keyword: self.parse_keyword(Keyword::PRIVILEGES),
@@ -12140,48 +12140,49 @@ impl<'a> Parser<'a> {
1214012140 Privileges::Actions(actions)
1214112141 };
1214212142
12143- self.expect_keyword_is(Keyword::ON)?;
12144-
12145- let objects = if self.parse_keywords(&[
12146- Keyword::ALL,
12147- Keyword::TABLES,
12148- Keyword::IN,
12149- Keyword::SCHEMA,
12150- ]) {
12151- GrantObjects::AllTablesInSchema {
12152- schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
12153- }
12154- } else if self.parse_keywords(&[
12155- Keyword::ALL,
12156- Keyword::SEQUENCES,
12157- Keyword::IN,
12158- Keyword::SCHEMA,
12159- ]) {
12160- GrantObjects::AllSequencesInSchema {
12161- schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
12162- }
12163- } else {
12164- let object_type = self.parse_one_of_keywords(&[
12165- Keyword::SEQUENCE,
12166- Keyword::DATABASE,
12143+ let objects = if self.parse_keyword(Keyword::ON) {
12144+ if self.parse_keywords(&[Keyword::ALL, Keyword::TABLES, Keyword::IN, Keyword::SCHEMA]) {
12145+ Some(GrantObjects::AllTablesInSchema {
12146+ schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
12147+ })
12148+ } else if self.parse_keywords(&[
12149+ Keyword::ALL,
12150+ Keyword::SEQUENCES,
12151+ Keyword::IN,
1216712152 Keyword::SCHEMA,
12168- Keyword::TABLE,
12169- Keyword::VIEW,
12170- Keyword::WAREHOUSE,
12171- Keyword::INTEGRATION,
12172- ]);
12173- let objects =
12174- self.parse_comma_separated(|p| p.parse_object_name_with_wildcards(false, true));
12175- match object_type {
12176- Some(Keyword::DATABASE) => GrantObjects::Databases(objects?),
12177- Some(Keyword::SCHEMA) => GrantObjects::Schemas(objects?),
12178- Some(Keyword::SEQUENCE) => GrantObjects::Sequences(objects?),
12179- Some(Keyword::WAREHOUSE) => GrantObjects::Warehouses(objects?),
12180- Some(Keyword::INTEGRATION) => GrantObjects::Integrations(objects?),
12181- Some(Keyword::VIEW) => GrantObjects::Views(objects?),
12182- Some(Keyword::TABLE) | None => GrantObjects::Tables(objects?),
12183- _ => unreachable!(),
12153+ ]) {
12154+ Some(GrantObjects::AllSequencesInSchema {
12155+ schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
12156+ })
12157+ } else {
12158+ let object_type = self.parse_one_of_keywords(&[
12159+ Keyword::SEQUENCE,
12160+ Keyword::DATABASE,
12161+ Keyword::DATABASE,
12162+ Keyword::SCHEMA,
12163+ Keyword::TABLE,
12164+ Keyword::VIEW,
12165+ Keyword::WAREHOUSE,
12166+ Keyword::INTEGRATION,
12167+ Keyword::VIEW,
12168+ Keyword::WAREHOUSE,
12169+ Keyword::INTEGRATION,
12170+ ]);
12171+ let objects =
12172+ self.parse_comma_separated(|p| p.parse_object_name_with_wildcards(false, true));
12173+ match object_type {
12174+ Some(Keyword::DATABASE) => Some(GrantObjects::Databases(objects?)),
12175+ Some(Keyword::SCHEMA) => Some(GrantObjects::Schemas(objects?)),
12176+ Some(Keyword::SEQUENCE) => Some(GrantObjects::Sequences(objects?)),
12177+ Some(Keyword::WAREHOUSE) => Some(GrantObjects::Warehouses(objects?)),
12178+ Some(Keyword::INTEGRATION) => Some(GrantObjects::Integrations(objects?)),
12179+ Some(Keyword::VIEW) => Some(GrantObjects::Views(objects?)),
12180+ Some(Keyword::TABLE) | None => Some(GrantObjects::Tables(objects?)),
12181+ _ => unreachable!(),
12182+ }
1218412183 }
12184+ } else {
12185+ None
1218512186 };
1218612187
1218712188 Ok((privileges, objects))
@@ -12208,6 +12209,9 @@ impl<'a> Parser<'a> {
1220812209 Ok(Action::AttachPolicy)
1220912210 } else if self.parse_keywords(&[Keyword::BIND, Keyword::SERVICE, Keyword::ENDPOINT]) {
1221012211 Ok(Action::BindServiceEndpoint)
12212+ } else if self.parse_keywords(&[Keyword::DATABASE, Keyword::ROLE]) {
12213+ let role = self.parse_object_name(false)?;
12214+ Ok(Action::DatabaseRole { role })
1221112215 } else if self.parse_keywords(&[Keyword::EVOLVE, Keyword::SCHEMA]) {
1221212216 Ok(Action::EvolveSchema)
1221312217 } else if self.parse_keywords(&[Keyword::IMPORT, Keyword::SHARE]) {
@@ -12273,6 +12277,9 @@ impl<'a> Parser<'a> {
1227312277 Ok(Action::Read)
1227412278 } else if self.parse_keyword(Keyword::REPLICATE) {
1227512279 Ok(Action::Replicate)
12280+ } else if self.parse_keyword(Keyword::ROLE) {
12281+ let role = self.parse_identifier()?;
12282+ Ok(Action::Role { role })
1227612283 } else if self.parse_keyword(Keyword::SELECT) {
1227712284 Ok(Action::Select {
1227812285 columns: parse_columns(self)?,
0 commit comments