Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fuzz/fuzz_seeds/postgres_alter_extension.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ ALTER EXTENSION citext DROP TEXT SEARCH PARSER public.pgrm;
ALTER EXTENSION citext ADD TEXT SEARCH TEMPLATE public.tpl;
ALTER EXTENSION citext DROP DATABASE db_name;
ALTER EXTENSION citext ADD EXTENSION other_ext;
ALTER EXTENSION citext DROP INDEX public.idx;
3 changes: 3 additions & 0 deletions src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4946,6 +4946,8 @@ pub enum AlterExtensionMember {
ForeignDataWrapper(Ident),
/// `FOREIGN TABLE object_name`
ForeignTable(ObjectName),
/// `INDEX object_name`
Index(ObjectName),
/// `[ PROCEDURAL ] LANGUAGE object_name`
Language {
/// Whether the `PROCEDURAL` keyword was present.
Expand Down Expand Up @@ -5007,6 +5009,7 @@ impl fmt::Display for AlterExtensionMember {
write!(f, "FOREIGN DATA WRAPPER {name}")
}
AlterExtensionMember::ForeignTable(name) => write!(f, "FOREIGN TABLE {name}"),
AlterExtensionMember::Index(name) => write!(f, "INDEX {name}"),
AlterExtensionMember::Language { procedural, name } => {
if *procedural {
write!(f, "PROCEDURAL LANGUAGE {name}")
Expand Down
2 changes: 2 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12563,6 +12563,8 @@ impl<'a> Parser<'a> {
Ok(AlterExtensionMember::ForeignTable(
self.parse_object_name(false)?,
))
} else if self.parse_keyword(Keyword::INDEX) {
Ok(AlterExtensionMember::Index(self.parse_object_name(false)?))
} else if self.parse_keywords(&[Keyword::PROCEDURAL, Keyword::LANGUAGE]) {
Ok(AlterExtensionMember::Language {
procedural: true,
Expand Down
2 changes: 2 additions & 0 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13538,6 +13538,7 @@ fn alter_extension_member_round_trip_forms(action: &str) {
format!("ALTER EXTENSION ext_name {action} FOREIGN DATA WRAPPER fdw"),
format!("ALTER EXTENSION ext_name {action} FOREIGN TABLE ft"),
format!("ALTER EXTENSION ext_name {action} FOREIGN TABLE schema.ft"),
format!("ALTER EXTENSION ext_name {action} INDEX idx"),
format!("ALTER EXTENSION ext_name {action} LANGUAGE plpgsql"),
format!("ALTER EXTENSION ext_name {action} PROCEDURAL LANGUAGE plpgsql"),
format!("ALTER EXTENSION ext_name {action} MATERIALIZED VIEW mv"),
Expand Down Expand Up @@ -13734,6 +13735,7 @@ fn parse_alter_extension_add_member() {
"EXTENSION",
"FOREIGN DATA WRAPPER",
"FOREIGN TABLE",
"INDEX",
"LANGUAGE",
"MATERIALIZED VIEW",
"PROCEDURAL LANGUAGE",
Expand Down
Loading