Fix DDL generation in case of an empty arguments function. (#1690)

This commit is contained in:
Rémy SAISSY 2025-01-30 07:50:30 +01:00 committed by GitHub
parent 252fdbab82
commit a7e984099f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View file

@ -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}")?;

View file

@ -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() {