From 799fcedf1b629cb98b222c9fc204ac0e02274a01 Mon Sep 17 00:00:00 2001 From: Yoav Cohen Date: Sun, 20 Jul 2025 11:10:15 +0300 Subject: [PATCH] Add support for the DROP privilege --- src/ast/mod.rs | 2 ++ src/parser/mod.rs | 2 ++ tests/sqlparser_common.rs | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 1f5311aff..bf513e22a 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -6587,6 +6587,7 @@ pub enum Action { role: ObjectName, }, Delete, + Drop, EvolveSchema, Exec { obj_type: Option, @@ -6656,6 +6657,7 @@ impl fmt::Display for Action { } Action::DatabaseRole { role } => write!(f, "DATABASE ROLE {role}")?, Action::Delete => f.write_str("DELETE")?, + Action::Drop => f.write_str("DROP")?, Action::EvolveSchema => f.write_str("EVOLVE SCHEMA")?, Action::Exec { obj_type } => { f.write_str("EXEC")?; diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 3bb913118..5717977d5 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -14265,6 +14265,8 @@ impl<'a> Parser<'a> { Ok(Action::Usage) } else if self.parse_keyword(Keyword::OWNERSHIP) { Ok(Action::Ownership) + } else if self.parse_keyword(Keyword::DROP) { + Ok(Action::Drop) } else { self.expected("a privilege keyword", self.peek_token())? } diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index 4183c5539..5c81722d1 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -9317,7 +9317,7 @@ fn parse_drop_role() { #[test] fn parse_grant() { - let sql = "GRANT SELECT, INSERT, UPDATE (shape, size), USAGE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CONNECT, CREATE, EXECUTE, TEMPORARY ON abc, def TO xyz, m WITH GRANT OPTION GRANTED BY jj"; + let sql = "GRANT SELECT, INSERT, UPDATE (shape, size), USAGE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CONNECT, CREATE, EXECUTE, TEMPORARY, DROP ON abc, def TO xyz, m WITH GRANT OPTION GRANTED BY jj"; match verified_stmt(sql) { Statement::Grant { privileges, @@ -9355,6 +9355,7 @@ fn parse_grant() { Action::Create { obj_type: None }, Action::Execute { obj_type: None }, Action::Temporary, + Action::Drop, ], actions );