Skip to content

test(jdbc): pin attached schema, date time, and savepoint edges - #215

Merged
magnusp merged 1 commit into
mainfrom
test/i195-pin-jdbc-behaviors
Oct 24, 2026
Merged

magnusp merged 1 commit into
mainfrom
test/i195-pin-jdbc-behaviors

Conversation

@magnusp

@magnusp magnusp commented Oct 24, 2026

Copy link
Copy Markdown
Owner

What

Tests only, for the four behaviors Wave 0 of #195 names. No production code, pom.xml, or dependency change; no existing assertion edited.

  1. Attached-schema table metadata (LibsqlResultSetMetaDataTest). SELECT id, name FROM aux.People drives pragma_database_list and the per-schema lookup, so findSchema and loadAttachedTableInfo run. The stub answers a different People in main (nullable, no autoincrement) and in the attached schema Aux (NOT NULL, INTEGER PRIMARY KEY AUTOINCREMENT), so the assertions on getTableName/isNullable/isAutoIncrement only pass when the attached catalogue wins. A second test queries ghost.People with ghost absent from the database list and asserts no table metadata.
  2. Date/time tails (LibsqlResultSetTest). +02:00 suffix, Z suffix, bare 10:30:45 defaulting to 2000-01-01, and BLOB rejection with "Bad value for type LocalDate" / LocalTime / LocalDateTime (exact target-type spelling from the code).
  3. Savepoint edges (LibsqlSavepointTest). Two savepoints named dup: releasing the later one must keep the earlier active, so the next statement runs on the same stream with no BEGIN, and rollback to the earlier one still works. Releasing the only savepoint of a transaction started in auto-commit ends the transaction, so the following commit() sends nothing and exactly one stream close is issued.
  4. Batch vs close() (LibsqlStatementConcurrencyTest). A batch is held inside the connection round trip with the existing Pause seam while close() lands on the statement, so the interleaving is deterministic; executeBatch then fails with Statement is closed.

Mutation probe

Each new test was run alone against a scratch break of the behavior it pins, then the break was reverted with git checkout -- <file>. All nine bite; none stayed green.

Probe lane: ./mvnw -pl libsql-jdbc -am -Dtest='<Class>#<method>' -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false test

Test Break Observed failure
LibsqlResultSetMetaDataTest#resolvesAttachedTableMetadataThroughPragmaDatabaseList findSchema: name.equalsIgnoreCase(schema) → name.equals(schema) :65 expected "People" but was ""
LibsqlResultSetMetaDataTest#reportsNoTableMetadataForASchemaMissingFromPragmaDatabaseList findSchema: return null → return schema when no database matches :81 Expecting empty but was: "People"
LibsqlResultSetTest#textDateTimeWithAnOffsetSuffixIsConvertedToTheSystemZone parseSqliteDateTime: guard if (sign > 9) → if (false && sign > 9) :290 SQLException: Bad value for type LocalDateTime: 2024-03-15 10:30:00+02:00
LibsqlResultSetTest#textDateTimeWithAZSuffixIsReadAsUtc parseSqliteDateTime: skip the Z branch (if (false && ...)) :305 SQLException: Bad value for type LocalDateTime: 2024-03-15T10:30:00Z
LibsqlResultSetTest#bareTimeTextGetsTheYear2000DefaultDate LocalDate.of(2000, 1, 1) → LocalDate.of(1970, 1, 1) :316 expected 2000-01-01T10:30:45 but was 1970-01-01T10:30:45
LibsqlResultSetTest#blobRejectsDateAndTimeGettersWithTheTargetTypeName BLOB branch message → "Cannot read " + targetType + " from a BLOB" :328 Expecting message "Bad value for type LocalDate"
LibsqlSavepointTest#releasingTheLaterOfTwoSavepointsWithTheSameNameKeepsTheEarlierOneActive releaseSavepoint: savepointNames.lastIndexOf → indexOf :225 actual statements contain a BEGIN before the first INSERT (the transaction was ended early)
LibsqlSavepointTest#releasingTheOnlySavepointOfAnAutoCommitTransactionLeavesCommitWithNothingToSend releaseSavepoint: drop closeStreamQuietly() in the outermost branch :250 actual statements end with "COMMIT" (unexpected)
LibsqlStatementConcurrencyTest#executeBatchThatLosesTheRaceToCloseFailsWithStatementClosed executeBatch finally: clearBatch() → batchStatements.clear() :200 Expecting code to raise a throwable

Lanes

Command Result
./mvnw -pl libsql-jdbc -am test EXIT=0, 383 tests, 0 failures, 0 errors (baseline 374 + 9 new)
./mvnw spotless:apply no changes
./mvnw spotless:check BUILD SUCCESS
probe lane (9 runs, table above) each EXIT=1, production file reverted after every run

Discovery

executeBatch's finally { clearBatch(); } calls checkClosed() through clearBatch. When a statement close() lands while the batch round trip is in flight, a batch whose steps all succeeded reports SQLException("Statement is closed") instead of the update counts. Pinned as the current behavior and not fixed here, since a fix changes behavior under a race; it sits next to the #197 update-count snapshot and #211 close-path work, so the root can decide.

The socketTimeout URL case from the wave list is deliberately absent: #196 owns it.

Fixes #195

Characterization tests for the four unpinned behaviors in the JDBC
refactor Wave 0:

- attached-schema table metadata through pragma_database_list
- date/time text tails (offset, Z, bare time) and BLOB rejection
- duplicate savepoint names and releasing the outermost savepoint of
  an auto-commit-started transaction
- executeBatch racing statement close

Tests only; no production code, pom or dependency change.
@magnusp

magnusp commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Root verdict: PASS at 4df54b1.

Independent verifier re-ran the gates on a clean worktree: 383 tests, 0 failures, spotless green, the concurrency class 7 times with no flake, and two mutation probes that bit and were reverted. Diff is 235 insertions across four test files, no production change, no existing assertion edited. CI is green and the PR is CLEAN.

One note carried forward: the duplicate-savepoint test name promises more than observable behavior can distinguish. Its mutation does bite the truncation path, so it stays as written. Countersign: root, 4df54b1.

@magnusp
magnusp merged commit fe91f99 into main Oct 24, 2026
6 checks passed
@magnusp
magnusp deleted the test/i195-pin-jdbc-behaviors branch October 24, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pin unpinned JDBC behaviors before the refactor passes

1 participant