feat!(c/driver/postgresql): defer transaction start - #4424
Merged
Conversation
Closes apache#4321. Assisted-by: GPT-5.5 <codex@openai.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the PostgreSQL C driver’s transaction behavior to avoid implicitly chaining transactions on COMMIT/ROLLBACK and to start transactions lazily (on first use) when autocommit is disabled—improving behavior with pooled connections.
Changes:
- Switch
COMMIT; BEGIN TRANSACTION→COMMITandROLLBACK AND CHAIN→ROLLBACK. - Add
PostgresConnection::EnsureTransaction()and invoke it before statement execution and selected metadata calls when autocommit is disabled. - Update/add Python and C++ tests to reflect “idle after commit/rollback” and to validate non-chaining rollback behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/adbc_driver_postgresql/tests/test_dbapi.py | Updates txn-status expectations; adds a cross-connection transaction behavior test. |
| c/driver/postgresql/statement.cc | Ensures a transaction exists before executing queries/ingest when autocommit is disabled. |
| c/driver/postgresql/postgresql_test.cc | Adjusts txn-status assertions; adds tests for non-chaining rollback and lazy txn start in GetObjects. |
| c/driver/postgresql/connection.h | Exposes EnsureTransaction() to PostgresStatement via friendship. |
| c/driver/postgresql/connection.cc | Implements lazy transaction start; changes COMMIT/ROLLBACK semantics; updates autocommit toggle behavior and adds EnsureTransaction calls in metadata paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lidavidm
marked this pull request as ready for review
June 22, 2026 07:24
zeroshade
approved these changes
Jun 23, 2026
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.
Closes #4321.
Assisted-by: GPT-5.5 codex@openai.com