Skip to content

fix(jdbc): throw SQLFeatureNotSupportedException and implement stream getters - #146

Merged
magnusp merged 1 commit into
mainfrom
fix/i114-unsupported-methods
Oct 23, 2026
Merged

magnusp merged 1 commit into
mainfrom
fix/i114-unsupported-methods

Conversation

@magnusp

@magnusp magnusp commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Fixes #114
Closes #27

Contract

Hrana 3 is the source of truth for transport, values, metadata, batching, transactions, and error reporting. java.sql is the source of truth for the JDBC surface. xerial/sqlite-jdbc is a behavioral reference and conformance foundation, never a copy target.

Protocol basis: Value.Blob is base64 on the wire, so streams and blobs materialize locally from the decoded bytes. Unsupported optional features throw SQLFeatureNotSupportedException per JDBC.

What changed

  • LibsqlResultSet: every remaining UnsupportedOperationException replaced with SQLFeatureNotSupportedException (all update*, getRef, getArray, getURL, getRowId, getNClob, getSQLXML, getAsciiStream, getUnicodeStream, getNCharacterStream).
  • getBinaryStream(int/String) over getBytes and getCharacterStream(int/String) over getString; SQL NULL returns null.
  • Read-only getBlob(int/String) and getClob(int/String) over the materialized value, with the full read side of java.sql.Blob/Clob; write methods throw SQLFeatureNotSupportedException.
  • getObject(int, Map) and getObject(String, Map) reject a non-empty map with SQLFeatureNotSupportedException("Type maps are not supported"); null and empty maps keep the existing behavior.
  • findColumn(null) throws SQLException("column label cannot be null") instead of NullPointerException.
  • LibsqlDatabaseMetaData: 14 unsupported metadata methods now throw SQLFeatureNotSupportedException.

#27 answer

Read side supported: getBlob/getClob and the full read surface of Blob/Clob (length, getBytes/getSubString, streams, position, free), plus getBinaryStream and getCharacterStream.

Write side not supported: PreparedStatement.setBlob/setClob and the Blob/Clob mutators are outside this PR's Files block and still throw SQLFeatureNotSupportedException. getAsciiStream, getUnicodeStream, and getNCharacterStream also remain unsupported (see divergences).

Divergences

  • xerial supports getAsciiStream, getUnicodeStream, and getNCharacterStream; this PR leaves them unsupported because the plan's Build limits stream implementation to getBinaryStream and getCharacterStream. They now throw the checked JDBC exception, so catch (SQLException) callers survive.
  • xerial returns unsupported for getBlob; this driver implements it because Hrana already carries the decoded blob bytes and [Bug]: check for BLOB support #27 asks for blob support. It is read-only.
  • xerial throws unsupported for getObject(Map) unconditionally; this driver accepts null and empty maps and rejects only a non-empty map, matching fix(jdbc): reject unsupported type maps and report holdability #95's setTypeMap contract.

Evidence

Red (trunk 1c240cd with these test files, /tmp/xerial-parity-i114/lane-1-regression.log): 67 tests, 4 failures and 4 errors. The new stream, blob, map, findColumn, and sweep cases fail on UnsupportedOperationException, the ignored type map, and the null-label NPE.

Green (head 47ea3f2, same log): 67 tests, 0 failures, BUILD SUCCESS.

Lanes (logs under /tmp/xerial-parity-i114/):

  1. Regression, trunk red to head green: pass.
  2. Byte-for-byte stream content: 4 tests pass.
  3. Unchecked-exception sweep over both classes: 2 tests pass, no UnsupportedOperationException.
  4. ./mvnw -pl libsql-jdbc test: 273 tests, BUILD SUCCESS.
  5. ./mvnw -pl libsql-conformance -am verify: 123 tests, 1 skipped, BUILD SUCCESS, no new divergence.
  6. ./mvnw -pl libsql-conformance -am -Pxerial-control verify: 100 tests, 1 skipped, BUILD SUCCESS.
  7. ./mvnw spotless:check: BUILD SUCCESS.
  8. ./mvnw test: BUILD SUCCESS.
  9. [Bug]: check for BLOB support #27 surface: recorded in lane-9-specific.log.
  10. ./mvnw -pl libsql-jdbc -am package -DskipTests: jar built.

Perf: ./mvnw -pl libsql-jdbc test medians over three interleaved runs, trunk 2.159 s versus head 2.167 s, +0.4 percent, within the 10 percent rule.

Files touched: only the four files in the plan's Files block. Base 1c240cd, head 47ea3f2.

… getters

Replace the remaining UnsupportedOperationException paths in LibsqlResultSet
and LibsqlDatabaseMetaData with SQLFeatureNotSupportedException, implement
getBinaryStream/getCharacterStream and the read-only getBlob/getClob surface,
reject non-empty type maps in getObject(Map), and reject a null findColumn
label with SQLException.
@magnusp
magnusp merged commit 3adf8e3 into main Oct 23, 2026
6 checks passed
@magnusp
magnusp deleted the fix/i114-unsupported-methods branch October 23, 2026 01:25
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.

Unsupported ResultSet and DatabaseMetaData methods throw UnsupportedOperationException [Bug]: check for BLOB support

1 participant