@@ -12140,7 +12140,7 @@ impl<'a> Parser<'a> {
1214012140
1214112141 pub fn parse_grant_revoke_privileges_objects(
1214212142 &mut self,
12143- ) -> Result<(Privileges, GrantObjects), ParserError> {
12143+ ) -> Result<(Privileges, Option< GrantObjects> ), ParserError> {
1214412144 let privileges = if self.parse_keyword(Keyword::ALL) {
1214512145 Privileges::All {
1214612146 with_privileges_keyword: self.parse_keyword(Keyword::PRIVILEGES),
@@ -12150,48 +12150,49 @@ impl<'a> Parser<'a> {
1215012150 Privileges::Actions(actions)
1215112151 };
1215212152
12153- self.expect_keyword_is(Keyword::ON)?;
12154-
12155- let objects = if self.parse_keywords(&[
12156- Keyword::ALL,
12157- Keyword::TABLES,
12158- Keyword::IN,
12159- Keyword::SCHEMA,
12160- ]) {
12161- GrantObjects::AllTablesInSchema {
12162- schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
12163- }
12164- } else if self.parse_keywords(&[
12165- Keyword::ALL,
12166- Keyword::SEQUENCES,
12167- Keyword::IN,
12168- Keyword::SCHEMA,
12169- ]) {
12170- GrantObjects::AllSequencesInSchema {
12171- schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
12172- }
12173- } else {
12174- let object_type = self.parse_one_of_keywords(&[
12175- Keyword::SEQUENCE,
12176- Keyword::DATABASE,
12153+ let objects = if self.parse_keyword(Keyword::ON) {
12154+ if self.parse_keywords(&[Keyword::ALL, Keyword::TABLES, Keyword::IN, Keyword::SCHEMA]) {
12155+ Some(GrantObjects::AllTablesInSchema {
12156+ schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
12157+ })
12158+ } else if self.parse_keywords(&[
12159+ Keyword::ALL,
12160+ Keyword::SEQUENCES,
12161+ Keyword::IN,
1217712162 Keyword::SCHEMA,
12178- Keyword::TABLE,
12179- Keyword::VIEW,
12180- Keyword::WAREHOUSE,
12181- Keyword::INTEGRATION,
12182- ]);
12183- let objects =
12184- self.parse_comma_separated(|p| p.parse_object_name_with_wildcards(false, true));
12185- match object_type {
12186- Some(Keyword::DATABASE) => GrantObjects::Databases(objects?),
12187- Some(Keyword::SCHEMA) => GrantObjects::Schemas(objects?),
12188- Some(Keyword::SEQUENCE) => GrantObjects::Sequences(objects?),
12189- Some(Keyword::WAREHOUSE) => GrantObjects::Warehouses(objects?),
12190- Some(Keyword::INTEGRATION) => GrantObjects::Integrations(objects?),
12191- Some(Keyword::VIEW) => GrantObjects::Views(objects?),
12192- Some(Keyword::TABLE) | None => GrantObjects::Tables(objects?),
12193- _ => unreachable!(),
12163+ ]) {
12164+ Some(GrantObjects::AllSequencesInSchema {
12165+ schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
12166+ })
12167+ } else {
12168+ let object_type = self.parse_one_of_keywords(&[
12169+ Keyword::SEQUENCE,
12170+ Keyword::DATABASE,
12171+ Keyword::DATABASE,
12172+ Keyword::SCHEMA,
12173+ Keyword::TABLE,
12174+ Keyword::VIEW,
12175+ Keyword::WAREHOUSE,
12176+ Keyword::INTEGRATION,
12177+ Keyword::VIEW,
12178+ Keyword::WAREHOUSE,
12179+ Keyword::INTEGRATION,
12180+ ]);
12181+ let objects =
12182+ self.parse_comma_separated(|p| p.parse_object_name_with_wildcards(false, true));
12183+ match object_type {
12184+ Some(Keyword::DATABASE) => Some(GrantObjects::Databases(objects?)),
12185+ Some(Keyword::SCHEMA) => Some(GrantObjects::Schemas(objects?)),
12186+ Some(Keyword::SEQUENCE) => Some(GrantObjects::Sequences(objects?)),
12187+ Some(Keyword::WAREHOUSE) => Some(GrantObjects::Warehouses(objects?)),
12188+ Some(Keyword::INTEGRATION) => Some(GrantObjects::Integrations(objects?)),
12189+ Some(Keyword::VIEW) => Some(GrantObjects::Views(objects?)),
12190+ Some(Keyword::TABLE) | None => Some(GrantObjects::Tables(objects?)),
12191+ _ => unreachable!(),
12192+ }
1219412193 }
12194+ } else {
12195+ None
1219512196 };
1219612197
1219712198 Ok((privileges, objects))
@@ -12218,6 +12219,9 @@ impl<'a> Parser<'a> {
1221812219 Ok(Action::AttachPolicy)
1221912220 } else if self.parse_keywords(&[Keyword::BIND, Keyword::SERVICE, Keyword::ENDPOINT]) {
1222012221 Ok(Action::BindServiceEndpoint)
12222+ } else if self.parse_keywords(&[Keyword::DATABASE, Keyword::ROLE]) {
12223+ let role = self.parse_object_name(false)?;
12224+ Ok(Action::DatabaseRole { role })
1222112225 } else if self.parse_keywords(&[Keyword::EVOLVE, Keyword::SCHEMA]) {
1222212226 Ok(Action::EvolveSchema)
1222312227 } else if self.parse_keywords(&[Keyword::IMPORT, Keyword::SHARE]) {
@@ -12283,6 +12287,9 @@ impl<'a> Parser<'a> {
1228312287 Ok(Action::Read)
1228412288 } else if self.parse_keyword(Keyword::REPLICATE) {
1228512289 Ok(Action::Replicate)
12290+ } else if self.parse_keyword(Keyword::ROLE) {
12291+ let role = self.parse_identifier()?;
12292+ Ok(Action::Role { role })
1228612293 } else if self.parse_keyword(Keyword::SELECT) {
1228712294 Ok(Action::Select {
1228812295 columns: parse_columns(self)?,
0 commit comments