Skip to content

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

Merged
iffyio merged 1 commit intoapache:mainfrom
remysaissy:postgres/support_no_arg_functions
Jan 30, 2025
Merged

Fix DDL generation in case of an empty arguments function.#1690
iffyio merged 1 commit intoapache:mainfrom
remysaissy:postgres/support_no_arg_functions

Conversation

@remysaissy
Copy link
Copy Markdown
Contributor

@remysaissy remysaissy commented Jan 29, 2025

Functions with an empty argument list are properly parsed into the AST but the string representation of such function removes the parenthesis required after the function name, causing an error at the database level.

For eg.
CREATE OR REPLACE FUNCTION no_arg() RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN DELETE FROM my_table; END; $$
Becomes:
CREATE OR REPLACE FUNCTION no_arg RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN DELETE FROM my_table; END; $$
And causes Postgres to reject the query with a
[96579] ERROR: syntax error at or near "RETURNS"

This PR fixes the string representation in this specific case.

@remysaissy remysaissy changed the title Fix DDL generation in case of an empty arguments FUNCTION. Fix DDL generation in case of an empty arguments function. Jan 29, 2025
@remysaissy remysaissy force-pushed the postgres/support_no_arg_functions branch from 3396449 to 4636691 Compare January 29, 2025 15:27
Copy link
Copy Markdown
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @remysaissy!
cc @alamb

@iffyio iffyio merged commit a7e9840 into apache:main Jan 30, 2025
iffyio added a commit to validio-io/sqlparser-rs that referenced this pull request Jan 30, 2025
Vedin pushed a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
Vedin pushed a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
Vedin added a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants