-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for pg DROP EXTENSION #1610
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5196,9 +5196,11 @@ impl<'a> Parser<'a> { | |
return self.parse_drop_secret(temporary, persistent); | ||
} else if self.parse_keyword(Keyword::TRIGGER) { | ||
return self.parse_drop_trigger(); | ||
} else if self.parse_keyword(Keyword::EXTENSION) { | ||
return self.parse_drop_extension(); | ||
} else { | ||
return self.expected( | ||
"TABLE, VIEW, INDEX, ROLE, SCHEMA, DATABASE, FUNCTION, PROCEDURE, STAGE, TRIGGER, SECRET, SEQUENCE, or TYPE after DROP", | ||
"TABLE, VIEW, INDEX, ROLE, SCHEMA, DATABASE, FUNCTION, PROCEDURE, STAGE, TRIGGER, SECRET, SEQUENCE, TYPE, or EXTENSION after DROP", | ||
self.peek_token(), | ||
); | ||
}; | ||
|
@@ -5861,6 +5863,22 @@ impl<'a> Parser<'a> { | |
}) | ||
} | ||
|
||
pub fn parse_drop_extension(&mut self) -> Result<Statement, ParserError> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the function is being made a public function, could we include a description for it? |
||
let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]); | ||
let names = self.parse_comma_separated(|p| p.parse_identifier(false))?; | ||
let cascade_or_restrict = | ||
self.parse_one_of_keywords(&[Keyword::CASCADE, Keyword::RESTRICT]); | ||
Ok(Statement::DropExtension { | ||
names, | ||
if_exists, | ||
cascade_or_restrict: cascade_or_restrict.map(|k| match k { | ||
Keyword::CASCADE => ReferentialAction::Cascade, | ||
Keyword::RESTRICT => ReferentialAction::Restrict, | ||
_ => unreachable!(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in place of panicking here in case we missed something/bug, we can return an explicit error |
||
}), | ||
}) | ||
} | ||
|
||
//TODO: Implement parsing for Skewed | ||
pub fn parse_hive_distribution(&mut self) -> Result<HiveDistributionStyle, ParserError> { | ||
if self.parse_keywords(&[Keyword::PARTITIONED, Keyword::BY]) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -662,6 +662,22 @@ fn parse_create_extension() { | |
.verified_stmt("CREATE EXTENSION extension_name WITH SCHEMA schema_name VERSION version"); | ||
} | ||
|
||
#[test] | ||
fn parse_drop_extension() { | ||
pg_and_generic().verified_stmt("DROP EXTENSION extension_name"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the feature introduces a new node to the ast can we add one scenario that asserts the ast in this style? |
||
pg_and_generic().verified_stmt("DROP EXTENSION extension_name CASCADE"); | ||
pg_and_generic().verified_stmt("DROP EXTENSION extension_name RESTRICT"); | ||
pg_and_generic().verified_stmt("DROP EXTENSION extension_name, extension_name2 CASCADE"); | ||
pg_and_generic().verified_stmt("DROP EXTENSION extension_name, extension_name2 RESTRICT"); | ||
|
||
pg_and_generic().verified_stmt("DROP EXTENSION IF EXISTS extension_name"); | ||
pg_and_generic().verified_stmt("DROP EXTENSION IF EXISTS extension_name CASCADE"); | ||
pg_and_generic() | ||
.verified_stmt("DROP EXTENSION IF EXISTS extension_name1, extension_name2 CASCADE"); | ||
pg_and_generic() | ||
.verified_stmt("DROP EXTENSION IF EXISTS extension_name1, extension_name2 RESTRICT"); | ||
} | ||
|
||
#[test] | ||
fn parse_alter_table_alter_column() { | ||
pg().one_statement_parses_to( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also include the link in the description here? would help folks find the syntax quicker in the future if needed