Repository navigation
refactor(jdbc): name savepoint state transitions - #231
Merged
Merged
Conversation
Fixes #210 Names the three savepoint state transitions in `LibsqlConnection` and moves savepoint-name resolution next to the type that owns it. - `beginSavepointTransaction` starts the transaction an auto-commit savepoint owns without sending `BEGIN`; a failed savepoint closes the fresh stream and leaves auto-commit on. - `discardSavepointsAfter` cancels the savepoints created after a rollback target, which stays active. - `closeTransactionOwnedBySavepoint` drops the released savepoint and its nested ones, and closes the stream only when the released savepoint is the outermost one that started the transaction. - `requireManualCommit(String action)` builds `Cannot <action> when in autoCommit mode`, so commit, rollback, and savepoint rollback/release keep their distinct messages. - `savepointSqlName` moved to `LibsqlSavepoint.sqlNameOf`; messages unchanged. - `beginTransaction` folded into its only caller, `ensureTransactionStarted`, and the redundant second lock in `setSavepoint(String)` dropped. Preserved: auto-commit savepoint opens the stream and its outermost release commits and closes it; failed implicit savepoint leaves auto-commit on; rollback/release in auto-commit send nothing; duplicate names resolve by `lastIndexOf`. No test or `pom.xml` change.
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.
Fixes #210
Names the savepoint state transitions in
LibsqlConnection. The three fields(
autoCommit,transactionStartedBySavepoint,savepointNames) still encodeone state machine, but each transition now has a name and one caller.
What changed
beginSavepointTransaction— the savepoint sent in auto-commit opens thestream and owns the transaction; no
BEGINis sent, and a failed savepointcloses the fresh stream and leaves auto-commit on.
discardSavepointsAfter— a rollback cancels the savepoints created afterthe target; the target stays active.
closeTransactionOwnedBySavepoint— a release drops the released savepointand its nested ones, and closes the stream only when that savepoint is the
outermost one that started the transaction.
requireManualCommit(String action)— buildsCannot <action> when in autoCommit mode, socommit,rollback, rollback-to-savepoint, andrelease-savepoint each keep their distinct wording.
savepointSqlNamemoved toLibsqlSavepoint.sqlNameOf. Same messages, andthe savepoint type now owns savepoint naming while the connection keeps the
transitions.
beginTransactionfolded into its only callerensureTransactionStarted,and the redundant second lock acquisition around the
setSavepoint(String)name guard dropped. Both are behavior-preserving.
Preserved
BEGIN; releasingthe outermost savepoint commits and closes the stream.
setSavepoint(null)throws;setSavepoint()does not.lastIndexOf; the list is kept.stateLockheld by everytransition) unchanged. No test file and no
pom.xmlchange.Diff
Line counts:
LibsqlConnection.java748 → 734 (under the 740 budget);LibsqlSavepoint.java43 → 70.Probe
Switched
lastIndexOftoindexOfincloseTransactionOwnedBySavepoint(the duplicate-name resolution), one line, reverted:
The later duplicate then looked outermost, so the release committed and closed
the stream and the next statement re-began. Reverted;
LibsqlSavepointTest17/17 green again.
Verification
./mvnw -pl libsql-jdbc -am test./mvnw spotless:check./mvnw -pl libsql-conformance -am verifyDOCKER_CONFIG=$PWD/libsql-conformance/src/test/docker-config ./mvnw -pl libsql-itests -am verify