apache/shardingsphere · error · SQLFeatureNotSupportedException
updateBinaryStream
Error message
updateBinaryStream
What it means
The federation ResultSet throws SQLFeatureNotSupportedException("updateBinaryStream") from AbstractUnsupportedUpdateOperationSQLFederationResultSet. SQL federation computes merged, read-only results for cross-shard queries (federation engine with Calcite), so binary column updates in place have no backing cursor and every updateBinaryStream overload is an unconditional throw.
Source
Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java:224
@Override
public final void updateAsciiStream(final String columnLabel, final InputStream x, final int length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateAsciiStream");
}
@Override
public final void updateAsciiStream(final int columnIndex, final InputStream inputStream, final long length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateAsciiStream");
}
@Override
public final void updateAsciiStream(final String columnLabel, final InputStream inputStream, final long length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateAsciiStream");
}
@Override
public final void updateBinaryStream(final int columnIndex, final InputStream x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateBinaryStream");
}
@Override
public final void updateBinaryStream(final String columnLabel, final InputStream x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateBinaryStream");
}
@Override
public final void updateBinaryStream(final int columnIndex, final InputStream x, final int length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateBinaryStream");
}
@Override
public final void updateBinaryStream(final String columnLabel, final InputStream x, final int length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateBinaryStream");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use an explicit UPDATE statement with setBinaryStream to write binary data.
- Keep the query off the federation path by adjusting SQL or sharding/federation configuration.
- Lint the codebase for ResultSet.update* usage and convert all such flows to statement-based writes.
Example fix
// before
rs.updateBinaryStream(2, binIn); // throws
rs.updateRow();
// after
PreparedStatement ps = conn.prepareStatement("UPDATE t_file SET data = ? WHERE id = ?");
ps.setBinaryStream(1, binIn);
ps.setLong(2, id);
ps.executeUpdate(); Defensive patterns
Strategy: try-catch
Validate before calling
if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE
|| rs instanceof org.apache.shardingsphere.sqlfederation.resultset.SQLFederationResultSet) {
// use UPDATE + setBinaryStream instead
} Type guard
boolean isFederationResultSet(ResultSet rs) {
return rs instanceof org.apache.shardingsphere.sqlfederation.resultset.SQLFederationResultSet;
} Try / catch
try {
rs.updateBinaryStream(col, in);
} catch (SQLFeatureNotSupportedException e) {
// fall back to PreparedStatement UPDATE with setBinaryStream
} Prevention
- Write BLOBs with INSERT/UPDATE statements, not positioned result-set updates.
- Check result-set concurrency before attempting updates.
- Keep binary-write code driver-agnostic by never relying on updatable cursors.
When it happens
Trigger: Calling rs.updateBinaryStream(columnIndex, inputStream) (two-arg, no length) on a federation ResultSet — e.g. writing BLOB bytes after a federated SELECT — before rs.updateRow().
Common situations: Code that updates BLOB columns via positioned updates; enabling SQL federation so a formerly single-shard query now returns SQLFederationResultSet; porting an app from a raw MySQL/PostgreSQL connection to ShardingSphere.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/e01d1c0dc7b70c77.
Report an issue: GitHub.