Skip to content

Commit ed4d5f0

Browse files
committed
Add support for GRANT <P> ON ALL VIEWS IN SCHEMA
1 parent a339822 commit ed4d5f0

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/ast/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6920,6 +6920,8 @@ pub enum GrantObjects {
69206920
AllSequencesInSchema { schemas: Vec<ObjectName> },
69216921
/// Grant privileges on `ALL TABLES IN SCHEMA <schema_name> [, ...]`
69226922
AllTablesInSchema { schemas: Vec<ObjectName> },
6923+
/// Grant privileges on `ALL VIEWS IN SCHEMA <schema_name> [, ...]`
6924+
AllViewsInSchema { schemas: Vec<ObjectName> },
69236925
/// Grant privileges on `FUTURE SCHEMAS IN DATABASE <database_name> [, ...]`
69246926
FutureSchemasInDatabase { databases: Vec<ObjectName> },
69256927
/// Grant privileges on `FUTURE TABLES IN SCHEMA <schema_name> [, ...]`
@@ -6994,6 +6996,13 @@ impl fmt::Display for GrantObjects {
69946996
display_comma_separated(schemas)
69956997
)
69966998
}
6999+
GrantObjects::AllViewsInSchema { schemas } => {
7000+
write!(
7001+
f,
7002+
"ALL VIEWS IN SCHEMA {}",
7003+
display_comma_separated(schemas)
7004+
)
7005+
}
69977006
GrantObjects::FutureSchemasInDatabase { databases } => {
69987007
write!(
69997008
f,

src/parser/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13866,6 +13866,15 @@ impl<'a> Parser<'a> {
1386613866
Some(GrantObjects::AllTablesInSchema {
1386713867
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
1386813868
})
13869+
} else if self.parse_keywords(&[
13870+
Keyword::ALL,
13871+
Keyword::VIEWS,
13872+
Keyword::IN,
13873+
Keyword::SCHEMA,
13874+
]) {
13875+
Some(GrantObjects::AllViewsInSchema {
13876+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13877+
})
1386913878
} else if self.parse_keywords(&[
1387013879
Keyword::FUTURE,
1387113880
Keyword::SCHEMAS,

tests/sqlparser_common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9376,6 +9376,7 @@ fn parse_grant() {
93769376
verified_stmt("GRANT SELECT ON ALL TABLES IN SCHEMA db1.sc1 TO APPLICATION role1");
93779377
verified_stmt("GRANT SELECT ON ALL TABLES IN SCHEMA db1.sc1 TO APPLICATION ROLE role1");
93789378
verified_stmt("GRANT SELECT ON ALL TABLES IN SCHEMA db1.sc1 TO SHARE share1");
9379+
verified_stmt("GRANT SELECT ON ALL VIEWS IN SCHEMA db1.sc1 TO ROLE role1");
93799380
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO a:b");
93809381
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO GROUP group1");
93819382
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST");

0 commit comments

Comments
 (0)