Skip to content

Commit e1e0087

Browse files
committed
Add support for GRANT <P> ON ALL VIEWS IN SCHEMA
1 parent 239e30a commit e1e0087

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
@@ -6928,6 +6928,8 @@ pub enum GrantObjects {
69286928
AllSequencesInSchema { schemas: Vec<ObjectName> },
69296929
/// Grant privileges on `ALL TABLES IN SCHEMA <schema_name> [, ...]`
69306930
AllTablesInSchema { schemas: Vec<ObjectName> },
6931+
/// Grant privileges on `ALL VIEWS IN SCHEMA <schema_name> [, ...]`
6932+
AllViewsInSchema { schemas: Vec<ObjectName> },
69316933
/// Grant privileges on `FUTURE SCHEMAS IN DATABASE <database_name> [, ...]`
69326934
FutureSchemasInDatabase { databases: Vec<ObjectName> },
69336935
/// Grant privileges on `FUTURE TABLES IN SCHEMA <schema_name> [, ...]`
@@ -7002,6 +7004,13 @@ impl fmt::Display for GrantObjects {
70027004
display_comma_separated(schemas)
70037005
)
70047006
}
7007+
GrantObjects::AllViewsInSchema { schemas } => {
7008+
write!(
7009+
f,
7010+
"ALL VIEWS IN SCHEMA {}",
7011+
display_comma_separated(schemas)
7012+
)
7013+
}
70057014
GrantObjects::FutureSchemasInDatabase { databases } => {
70067015
write!(
70077016
f,

src/parser/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13897,6 +13897,15 @@ impl<'a> Parser<'a> {
1389713897
Some(GrantObjects::AllTablesInSchema {
1389813898
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
1389913899
})
13900+
} else if self.parse_keywords(&[
13901+
Keyword::ALL,
13902+
Keyword::VIEWS,
13903+
Keyword::IN,
13904+
Keyword::SCHEMA,
13905+
]) {
13906+
Some(GrantObjects::AllViewsInSchema {
13907+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13908+
})
1390013909
} else if self.parse_keywords(&[
1390113910
Keyword::FUTURE,
1390213911
Keyword::SCHEMAS,

tests/sqlparser_common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9414,6 +9414,7 @@ fn parse_grant() {
94149414
verified_stmt("GRANT SELECT ON ALL TABLES IN SCHEMA db1.sc1 TO APPLICATION role1");
94159415
verified_stmt("GRANT SELECT ON ALL TABLES IN SCHEMA db1.sc1 TO APPLICATION ROLE role1");
94169416
verified_stmt("GRANT SELECT ON ALL TABLES IN SCHEMA db1.sc1 TO SHARE share1");
9417+
verified_stmt("GRANT SELECT ON ALL VIEWS IN SCHEMA db1.sc1 TO ROLE role1");
94179418
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO a:b");
94189419
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO GROUP group1");
94199420
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST");

0 commit comments

Comments
 (0)