diff --git a/src/ast/mod.rs b/src/ast/mod.rs index a11fa63f4..47a380d09 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -1843,6 +1843,7 @@ impl fmt::Display for ShowCreateObject { pub enum CommentObject { Column, Table, + Extension, } impl fmt::Display for CommentObject { @@ -1850,6 +1851,7 @@ impl fmt::Display for CommentObject { match self { CommentObject::Column => f.write_str("COLUMN"), CommentObject::Table => f.write_str("TABLE"), + CommentObject::Extension => f.write_str("EXTENSION"), } } } diff --git a/src/dialect/postgresql.rs b/src/dialect/postgresql.rs index 945c4fcc0..2a66705bb 100644 --- a/src/dialect/postgresql.rs +++ b/src/dialect/postgresql.rs @@ -205,6 +205,10 @@ pub fn parse_comment(parser: &mut Parser) -> Result { let object_name = parser.parse_object_name(false)?; (CommentObject::Table, object_name) } + Token::Word(w) if w.keyword == Keyword::EXTENSION => { + let object_name = parser.parse_object_name(false)?; + (CommentObject::Extension, object_name) + } _ => parser.expected("comment object_type", token)?, }; diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index 9ba3e5dbc..735b87b5d 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs @@ -2902,6 +2902,21 @@ fn parse_comments() { _ => unreachable!(), } + match pg().verified_stmt("COMMENT ON EXTENSION plpgsql IS 'comment'") { + Statement::Comment { + object_type, + object_name, + comment: Some(comment), + if_exists, + } => { + assert_eq!("comment", comment); + assert_eq!("plpgsql", object_name.to_string()); + assert_eq!(CommentObject::Extension, object_type); + assert!(!if_exists); + } + _ => unreachable!(), + } + match pg().verified_stmt("COMMENT ON TABLE public.tab IS 'comment'") { Statement::Comment { object_type,