feat(go): support transactions and isolation level - #121
Open
VishalGG wants to merge 1 commit into
Open
Conversation
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.
Mandukhai-Alimaa
left a comment
Contributor
There was a problem hiding this comment.
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?
Author
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. |
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.
What's Changed
Implement transaction support (autocommit toggle, Commit, Rollback) and
isolation-level support for the MySQL ADBC driver.
mysqlConnectionImplnow implementsdriverbase.AutocommitSetter(auto-registered by sqlwrapper via type assertion):
SetAutocommit(false)issues
BEGIN;SetAutocommit(true)issuesCOMMIT. The driverbasewrapper still short-circuits Commit/Rollback to
StatusInvalidStatewhen autocommit is enabled.
Commit/Rollbackuse chained-transaction semantics (COMMIT thenBEGIN) 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).OptionKeyIsolationLevelis translated toSET SESSION TRANSACTION ISOLATION LEVEL ...and applied immediately.LevelDefaultmaps toREPEATABLE READ(MySQL's documented defaultand the same convention the C++ PostgreSQL driver uses at
arrow-adbc/c/driver/postgresql/connection.cc:1215).LevelSnapshotand
LevelLinearizableare not supported and returnStatusNotImplementedper ADBC spec.GetOption(OptionKeyIsolationLevel)returns the cached level.SupportsTransactionscapability flag flipped totruein both Goquirks (
mysql_test.go) and Python validation(
validation/tests/mysql.py).pytest.inifilter that suppressed"Cannot disable autocommit; conn will not be DB-API 2.0 compliant"warnings — no longer triggered now that autocommit toggling works.
and isolation-level round-trips against a live MySQL server.
Closes #55.
Closes #34.