Repository navigation
fix(jdbc): keep column origin aligned with the protocol width (#100) - #123
Merged
Merged
Conversation
The parser mapped the Nth select item to the Nth result column without comparing the two widths. A `*` expansion that SQLite narrows, such as a USING or NATURAL join, or that the parser cannot expand at all, shifted every later column onto the wrong table. Discard the resolution when the expansion width differs from `StmtResult.cols`, so a misalignment reports an unknown origin instead of a wrong one. Load table columns through `pragma_table_xinfo` and exclude hidden columns, which keeps generated columns in the expansion. Drop the right-side duplicate of a USING or NATURAL join column while expanding `*`.
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 #100
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.Protocol basis
StmtResult.colsis authoritative for column count, name, and decltype. The protocol has no column-origin field, so the local parser supplies only table origin and nullability. The parser expansion is now compared withcols.size(), and it never overrides the protocol width.Change
resolveColumnOriginspassescols.size()to a newSqlTableReference.resolve(sql, schema, columnCount)overload that discards the resolution when the parser expansion count differs. Every misalignment reports an empty table name andcolumnNullableUnknowninstead of a wrong table.pragma_table_xinfowithp.hidden != 1, so generated columns are present in*expansions and virtual-table hidden columns stay out.*expansion drops the right-side duplicate of a USING or NATURAL join column, which is what SQLite does.VALUESsubquery, and an unknown source, each asserting the resolved column count equals the result column count.Evidence
Red at base
2c83a84(new tests only, width seam returning the parser result unchanged):SqlTableReferenceTest: 22 run, 3 failed. USING, NATURAL, and width-discard cases failed on[resolved column count equals the result column count] Expecting value to be true but was false. Log:/tmp/xerial-parity-i100/red-parser.log.LibsqlResultSetMetaDataTest: 30 run, 3 failed.resolvesUsingJoinStarColumnsToTheLeftTableexpected"c"but was"b",resolvesGeneratedColumnStarColumnsThroughTableXinfoexpected"g"but was"c",leavesEveryColumnUnknownWhenTheStarWidthDiffersExpecting empty but was: "c". Log:/tmp/xerial-parity-i100/red-metadata.log.Green at head
a755f21:./mvnw -pl libsql-jdbc test -Dtest=SqlTableReferenceTest/tmp/xerial-parity-i100/green-parser.log)./mvnw -pl libsql-jdbc test -Dtest=LibsqlResultSetMetaDataTest/tmp/xerial-parity-i100/green-metadata.log)resolvesUsingJoinStarColumnsToTheLeftTablea,ztoc./mvnw -pl libsql-jdbc testlane-4-module-suite.log)./mvnw -pl libsql-conformance -am verifylane-5-conformance.log)./mvnw -pl libsql-conformance -am -Pxerial-control verifylane-6-control.log)./mvnw spotless:checklane-7-spotless.log)./mvnw testlibsql-jdbc(lane-8-reactor.log)./mvnw -pl libsql-jdbc -am package -DskipTestslane-10-package.log)Perf: wall clock of
./mvnw -pl libsql-jdbc test, three interleaved runs per side. Trunk median 2.14 s, head median 2.17 s, +1.4 percent, inside the ten percent rule (perf-interleaved.log).Divergence
None from SQLite or xerial. When the parser cannot prove alignment the driver reports the documented JDBC unknown values, which is the behavior the issue asks for.
Base
2c83a84, heada755f21.