Repository navigation
refactor(jdbc): unify statement result attachment - #233
Merged
Merged
Conversation
Attach the current result through one `attachResult` transition shared by `assignResultSet` and `executeResult`, and discard it through `discardCurrentResult` when close won the race. The closed branch now closes the discarded result set with the new `LibsqlResultSet.closeDetached`, so `closeResultSet` no longer flips `closed`/`closing` to let a nested close through. `newQueryResult` is shared by both `executeQuery` paths. `JdbcEscapes` holds the JDBC escape scan that `checkEscapeProcessing` used to inline; the move keeps `LibsqlStatement` under 650 lines.
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 #211
What changed
attachResult(resultSet, result, sql, requested)now owns every transition that makes a result set current.assignResultSet(the metadata seam) andexecuteResultboth delegate to it, so the two near-copies cannot drift apart.discardCurrentResult(resultSet, updateCountWhenNoResultSet)is the closed branch: it marks the discarded result set closed, clearscurrentResultSet/resultSetRequested, restores the update count, and clears generated keys.LibsqlResultSet.closeDetached()closes a result set without calling back into the statement. The statement calls it for the current result, discarded results, and generated keys.closeResultSetdeleted. Theclosed = false; closing = true; ... restoreflip is gone.closedis now written only byclose(), andLibsqlResultSet.closedonly byclose()/closeDetached(). No method temporarily reopens the statement.newQueryResult(sql, result)is shared byLibsqlStatement.executeQueryandLibsqlPreparedStatement.executeQuery.JdbcEscapesnow holds the escape-sequence scan thatcheckEscapeProcessinginlined. Pure move; it exists because the unification alone did not bringLibsqlStatementunder the 650-line budget.No message, flag semantic, or lock order changed. All state transitions still use the single
stateLock; no lock was added, removed, or reordered.Preserved contract (pinned by
LibsqlStatementLifecycleTestandLibsqlStatementConcurrencyTest)execute,executeQuery,executeUpdate, andgetConnectionkeep working, and a result set produced after close is returned closed.ResultSet already requested.closeOnCompletion/isCloseOnCompletionkeep the lower-casestatement is closedmessage.updateCountis-1when a result set exists and the affected row count otherwise.pom.xmlwas edited.Diff
Line counts:
LibsqlStatement.java702 -> 636 (< 650).LibsqlResultSet.java809 -> 818.JdbcEscapes.java71 (new).Probe
Probe: set
resultSetRequested = falseinstead ofrequestedinattachResult(breaks the requested-result error), reverted.After revert,
LibsqlStatementLifecycleTestis 21/21 green and the full suite is green.Lanes (final tree)
./mvnw -pl libsql-jdbc -am test./mvnw spotless:check./mvnw -pl libsql-conformance -am verifyDOCKER_CONFIG=... ./mvnw -pl libsql-itests -am verify