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 @@ -27,3 +27,4 @@ ALTER EXTENSION citext DROP STATISTICS public.st;
ALTER EXTENSION citext DROP SUBSCRIPTION sub;
ALTER EXTENSION citext ADD TABLESPACE ts;
ALTER EXTENSION citext ADD FUNCTION public.f(IN a int, text);
ALTER EXTENSION citext DROP PROCEDURE public.p(int);
3 changes: 3 additions & 0 deletions src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4959,6 +4959,8 @@ pub enum AlterExtensionMember {
},
/// `MATERIALIZED VIEW object_name`
MaterializedView(ObjectName),
/// `PROCEDURE procedure_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]`
Procedure(FunctionDesc),
/// `PUBLICATION object_name`
Publication(Ident),
/// `ROLE object_name`
Expand Down Expand Up @@ -5031,6 +5033,7 @@ impl fmt::Display for AlterExtensionMember {
}
}
AlterExtensionMember::MaterializedView(name) => write!(f, "MATERIALIZED VIEW {name}"),
AlterExtensionMember::Procedure(function) => write!(f, "PROCEDURE {function}"),
AlterExtensionMember::Publication(name) => write!(f, "PUBLICATION {name}"),
AlterExtensionMember::Role(name) => write!(f, "ROLE {name}"),
AlterExtensionMember::Schema(name) => write!(f, "SCHEMA {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 @@ -12581,6 +12581,8 @@ impl<'a> Parser<'a> {
Ok(AlterExtensionMember::MaterializedView(
self.parse_object_name(false)?,
))
} else if self.parse_keyword(Keyword::PROCEDURE) {
Ok(AlterExtensionMember::Procedure(self.parse_function_desc()?))
} else if self.parse_keyword(Keyword::PUBLICATION) {
Ok(AlterExtensionMember::Publication(self.parse_identifier()?))
} else if self.parse_keyword(Keyword::ROLE) {
Expand Down
7 changes: 7 additions & 0 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13546,6 +13546,9 @@ fn alter_extension_member_round_trip_forms(action: &str) {
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"),
format!("ALTER EXTENSION ext_name {action} PROCEDURE p"),
format!("ALTER EXTENSION ext_name {action} PROCEDURE p()"),
format!("ALTER EXTENSION ext_name {action} PROCEDURE p(INT)"),
format!("ALTER EXTENSION ext_name {action} PUBLICATION pub"),
format!("ALTER EXTENSION ext_name {action} ROLE role_name"),
format!("ALTER EXTENSION ext_name {action} SCHEMA schema_name"),
Expand Down Expand Up @@ -13745,6 +13748,10 @@ fn parse_alter_extension_add_member() {
"ALTER EXTENSION ext_name ADD FUNCTION 1",
"Expected: identifier, found: 1",
),
(
"ALTER EXTENSION ext_name ADD PROCEDURE 1",
"Expected: identifier, found: 1",
),
] {
assert_eq!(
pg_and_generic().parse_sql_statements(sql).unwrap_err(),
Expand Down
Loading