diff --git a/src/ast/ddl.rs b/src/ast/ddl.rs index 1b5ccda265..4fe6b0bb28 100644 --- a/src/ast/ddl.rs +++ b/src/ast/ddl.rs @@ -2011,6 +2011,8 @@ impl fmt::Display for CreateFunction { )?; if let Some(args) = &self.args { write!(f, "({})", display_comma_separated(args))?; + } else { + write!(f, "()")?; } if let Some(return_type) = &self.return_type { write!(f, " RETURNS {return_type}")?; diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index b3eb4f10d0..e7aeef4ee5 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs @@ -3802,6 +3802,7 @@ fn parse_create_function_detailed() { pg_and_generic().verified_stmt("CREATE OR REPLACE FUNCTION add(a INTEGER, IN b INTEGER = 1) RETURNS INTEGER LANGUAGE SQL STABLE PARALLEL UNSAFE RETURN a + b"); pg_and_generic().verified_stmt("CREATE OR REPLACE FUNCTION add(a INTEGER, IN b INTEGER = 1) RETURNS INTEGER LANGUAGE SQL STABLE CALLED ON NULL INPUT PARALLEL UNSAFE RETURN a + b"); pg_and_generic().verified_stmt(r#"CREATE OR REPLACE FUNCTION increment(i INTEGER) RETURNS INTEGER LANGUAGE plpgsql AS $$ BEGIN RETURN i + 1; END; $$"#); + pg_and_generic().verified_stmt(r#"CREATE OR REPLACE FUNCTION no_arg() RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN DELETE FROM my_table; END; $$"#); } #[test] fn parse_incorrect_create_function_parallel() {