Repository navigation
fix(jdbc): cache database metadata per connection - #94
Merged
Merged
Conversation
This was referenced Oct 22, 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 #50
Part of #54.
What changed
LibsqlConnection.getMetaData()now createsLibsqlDatabaseMetaDataon first use and returns the same instance for the lifetime of the connection. Separate connections get separate instances. A closed connection still throws. The method Javadoc documents the caching contract.The behavior test
LibsqlConnectionTest#getMetaDataIsCachedPerConnectionpins both halves: repeated calls on one connection return the same object, and another connection returns a different object.Contract decision
Parity with xerial sqlite-jdbc 3.53.4.0.
SQLiteConnection.getSQLiteDatabaseMetaData()caches its metadata object in ametafield andgetMetaData()delegates to it, so the same instance is returned per connection. This change matches that behavior. No Hrana or sqld constraint makes parity impossible.Evidence
Failing before the fix:
Passing after the fix:
No failures (exit 0).
Full module suite after the fix:
Formatting:
libsql-itestsandlibsql-conformancewere not run: the #50 Steering evidence asks for./mvnw -pl libsql-jdbc -am testand./mvnw spotless:apply, and this change touches no live-sqld or conformance path.Deviations
None.
Defect coverage
This is defect (4) of the four sequenced defects under #50:
getMetaDatacaching. It does not reopen the earlier three defects, which were delivered in #90 (getTableTypes), #91 (statement leaks), and #93 (getIndexInfoescaping).Files touched:
libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlConnection.javalibsql-jdbc/src/test/java/com/github/magnusp/libsql/jdbc/LibsqlConnectionTest.java