Repository navigation
docs(jdbc): document last_insert_rowid under the remote model (#83) - #126
Merged
Merged
Conversation
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.
Summary
Statement.getGeneratedKeys()after an auto-commit insert already reports the rowid fromStmtResult.last_insert_rowid. This PR pins that protocol linkage inLibsqlGeneratedKeysTestand documents why a directSELECT last_insert_rowid()cannot return the same value.No production code changes.
Contract
Hrana 3 is the source of truth for transport, values, and metadata.
java.sqlis the source of truth for the JDBC surface. xerial/sqlite-jdbc is a behavioral reference and conformance foundation, never a copy target.Divergence
A null baton opens a new Hrana stream, and
StmtResult.last_insert_rowidis a per-statement result on one stream. Auto-commit is one-shot, so a later directSELECT last_insert_rowid()runs on a fresh stream and returns0. xerial returns the connection's last rowid because it owns a single SQLite connection.The driver holds no session stream in auto-commit because Hrana over HTTP expires idle streams, and #99 removed the last eager stream of that kind. A hidden stream is not an option. The supported ways to read the rowid are
getGeneratedKeys()and running the query inside an explicit transaction, where the connection holds the baton and both statements share one stream. Section 8 ofIMPLEMENTATION_BUGS_AND_RESOLUTIONS.mdrecords this.Live evidence
Throwaway itest against real sqld (
ghcr.io/tursodatabase/libsql-server:latest), one connection, each mode inserting then selectinglast_insert_rowid():The throwaway probe was removed after the run. The retained contract is the unit test plus the doc section; the probe asserted no behavior the unit test does not already pin, and adding it would have added a second sqld container lane for one already-covered fact.
Verification
./mvnw -pl libsql-jdbc test -Dtest=LibsqlGeneratedKeysTest./mvnw -pl libsql-jdbc test./mvnw -pl libsql-itests -am verify./mvnw -pl libsql-conformance -am verify./mvnw -pl libsql-conformance -am -Pxerial-control verify./mvnw spotless:check./mvnw test./mvnw -pl libsql-jdbc -am package -DskipTests37a86a0Perf lane skipped. The change touches one test and one Markdown file, so no hot path changed and no timing comparison is meaningful.
Logs are under
/tmp/xerial-parity-i83/. The itests lane used the readable empty Docker config copy at/tmp/docker-configviaDOCKER_CONFIG.Base
37a86a0, head333af86.Fixes #83