Skip to content

feat(go): support transactions and isolation level - #121

Open
VishalGG wants to merge 1 commit into
adbc-drivers:mainfrom
ettaflow:feat/go-transactions
Open

feat(go): support transactions and isolation level#121
VishalGG wants to merge 1 commit into
adbc-drivers:mainfrom
ettaflow:feat/go-transactions

Conversation

@VishalGG

Copy link
Copy Markdown

What's Changed

Implement transaction support (autocommit toggle, Commit, Rollback) and
isolation-level support for the MySQL ADBC driver.

  • mysqlConnectionImpl now implements driverbase.AutocommitSetter
    (auto-registered by sqlwrapper via type assertion): SetAutocommit(false)
    issues BEGIN; SetAutocommit(true) issues COMMIT. The driverbase
    wrapper still short-circuits Commit/Rollback to StatusInvalidState
    when autocommit is enabled.
  • Commit/Rollback use chained-transaction semantics (COMMIT then
    BEGIN) so the next statement continues to run inside a transaction
    until the caller re-enables autocommit — matches the Snowflake driver's
    pattern (snowflake/go/connection.go:800-826).
  • OptionKeyIsolationLevel is translated to
    SET SESSION TRANSACTION ISOLATION LEVEL ... and applied immediately.
    LevelDefault maps to REPEATABLE READ (MySQL's documented default
    and the same convention the C++ PostgreSQL driver uses at
    arrow-adbc/c/driver/postgresql/connection.cc:1215). LevelSnapshot
    and LevelLinearizable are not supported and return
    StatusNotImplemented per ADBC spec.
  • GetOption(OptionKeyIsolationLevel) returns the cached level.
  • SupportsTransactions capability flag flipped to true in both Go
    quirks (mysql_test.go) and Python validation
    (validation/tests/mysql.py).
  • Removed obsolete pytest.ini filter that suppressed
    "Cannot disable autocommit; conn will not be DB-API 2.0 compliant"
    warnings — no longer triggered now that autocommit toggling works.
  • Added integration tests covering transaction commit/rollback durability
    and isolation-level round-trips against a live MySQL server.

Closes #55.
Closes #34.

Implement transaction support (autocommit toggle, Commit, Rollback) and
isolation-level support for the MySQL ADBC driver.

- mysqlConnectionImpl now implements driverbase.AutocommitSetter
  (auto-registered by sqlwrapper via type assertion): SetAutocommit(false)
  issues BEGIN; SetAutocommit(true) issues COMMIT. The driverbase wrapper
  still short-circuits Commit/Rollback to StatusInvalidState when autocommit
  is enabled.
- Commit/Rollback use chained-transaction semantics (COMMIT then BEGIN) so
  the next statement continues to run inside a transaction until the caller
  re-enables autocommit — matches the Snowflake driver's pattern.
- OptionKeyIsolationLevel is translated to
  SET SESSION TRANSACTION ISOLATION LEVEL ... and applied immediately.
  LevelDefault maps to REPEATABLE READ (MySQL's documented default and the
  same convention the C++ PostgreSQL driver uses). LevelSnapshot and
  LevelLinearizable are not supported and return StatusNotImplemented per
  ADBC spec.
- GetOption(OptionKeyIsolationLevel) returns the cached level.
- SupportsTransactions capability flag flipped to true in both Go quirks
  (mysql_test.go) and Python validation (validation/tests/mysql.py).
- Removed obsolete pytest.ini filter that suppressed
  'Cannot disable autocommit; conn will not be DB-API 2.0 compliant'
  warnings — no longer triggered now that autocommit toggling works.
- Added integration tests covering transaction commit/rollback durability
  and isolation-level round-trips against a live MySQL server.
@VishalGG
VishalGG requested a review from lidavidm as a code owner July 22, 2026 19:37

@Mandukhai-Alimaa Mandukhai-Alimaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this driver uses the shared sqlwrapper, would it make sense to implement transactions there using Go’s database/sql transaction API instead of managing them with raw BEGIN/COMMIT statements here?

@VishalGG

Copy link
Copy Markdown
Author

Since this driver uses the shared sqlwrapper, would it make sense to implement transactions there using Go’s database/sql transaction API instead of managing them with raw BEGIN/COMMIT statements here?

yes, this makes sense. I saw there is already an existing issue adbc-drivers/driverbase-go#28 . Will look into that and see if i can implement transactions there and raise a PR.

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.

[go] Implement transaction support Cannot disable autocommit warning

3 participants