Skip to content

PostgreSQL: Support BEGIN ATOMIC function bodies - #2728

Open
LucaCappelletti94 wants to merge 1 commit into
mainfrom
upstream/begin-atomic-function-body
Open

LucaCappelletti94 wants to merge 1 commit into
mainfrom
upstream/begin-atomic-function-body

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

CREATE FUNCTION rejected the SQL-standard body that PostgreSQL 14 added. CREATE FUNCTION f() RETURNS INT LANGUAGE sql BEGIN ATOMIC SELECT 1; END failed with Expected: end of statement, found: BEGIN under both PostgreSqlDialect and GenericDialect, and pg_dump writes SQL functions with such bodies in exactly this form.

The PostgreSQL CREATE FUNCTION option loop now reads BEGIN ATOMIC and the statements up to END, and stores them in a new CreateFunctionBody::BeginAtomic variant that reuses BeginEndStatements. PostgreSQL writes no AS before the block, so a separate variant keeps it apart from the SQL Server AS BEGIN ... END body. A RETURN expr; inside the block parses as the existing Statement::Return.

@codecov-commenter

codecov-commenter commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.30%. Comparing base (583c4d4) to head (565b633).

Files with missing lines Patch % Lines
src/ast/ddl.rs 55.55% 0 Missing and 4 partials ⚠️
src/parser/mod.rs 81.81% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2728   +/-   ##
=======================================
  Coverage   82.30%   82.30%           
=======================================
  Files          42       42           
  Lines       35307    35327   +20     
  Branches    35307    35327   +20     
=======================================
+ Hits        29058    29075   +17     
+ Misses       2691     2688    -3     
- Partials     3558     3564    +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/begin-atomic-function-body branch from 5dcc527 to 9aef0bb Compare October 26, 2026 18:58
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/begin-atomic-function-body branch from 9aef0bb to 565b633 Compare October 26, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants