Repository navigation
PostgreSQL: Support BEGIN ATOMIC function bodies - #2728
Open
LucaCappelletti94 wants to merge 3 commits into
Open
LucaCappelletti94 wants to merge 3 commits into
LucaCappelletti94 wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2728 +/- ##
==========================================
+ Coverage 82.40% 82.41% +0.01%
==========================================
Files 42 42
Lines 35342 35362 +20
Branches 35342 35362 +20
==========================================
+ Hits 29122 29145 +23
+ Misses 2678 2675 -3
Partials 3542 3542 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
LucaCappelletti94
force-pushed
the
upstream/begin-atomic-function-body
branch
2 times, most recently
from
October 26, 2026 20:18
9aef0bb to
565b633
Compare
sabir-akhadov-localstack
approved these changes
Oct 27, 2026
| } else if self.parse_keyword(Keyword::RETURN) { | ||
| ensure_not_set(&body.function_body, "RETURN")?; | ||
| body.function_body = Some(CreateFunctionBody::Return(self.parse_expr()?)); | ||
| } else if self.peek_keywords(&[Keyword::BEGIN, Keyword::ATOMIC]) { |
Contributor
There was a problem hiding this comment.
PostgreSQL accepts the same body for procedures (CREATE PROCEDURE p() LANGUAGE sql BEGIN ATOMIC INSERT INTO t VALUES (1); END), which parse_create_procedure still rejects at AS. Fine as a follow-up.
LucaCappelletti94
force-pushed
the
upstream/begin-atomic-function-body
branch
from
October 28, 2026 11:29
565b633 to
aa5a432
Compare
LucaCappelletti94
force-pushed
the
upstream/begin-atomic-function-body
branch
from
October 28, 2026 14:51
30d2371 to
a710be2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CREATE FUNCTIONrejected the SQL-standard body that PostgreSQL 14 added.CREATE FUNCTION f() RETURNS INT LANGUAGE sql BEGIN ATOMIC SELECT 1; ENDfailed withExpected: end of statement, found: BEGINunder bothPostgreSqlDialectandGenericDialect, andpg_dumpwrites SQL functions with such bodies in exactly this form.The PostgreSQL
CREATE FUNCTIONoption loop now readsBEGIN ATOMICand the statements up toEND, and stores them in a newCreateFunctionBody::BeginAtomicvariant that reusesBeginEndStatements. PostgreSQL writes noASbefore the block, so a separate variant keeps it apart from the SQL ServerAS BEGIN ... ENDbody. ARETURN expr;inside the block parses as the existingStatement::Return.