{"record":{"id":"0beef9529ea612ce","repo":"apache/shardingsphere","slug":"get-input-stream-from-s","errorCode":null,"errorMessage":"Get input stream from `%s`","messagePattern":"Get input stream from `(.+?)`","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/memory/MemoryMergedResult.java","lineNumber":93,"sourceCode":"    @Override\n    public final Object getValue(final int columnIndex, final Class<?> type) throws SQLException {\n        ShardingSpherePreconditions.checkNotContains(INVALID_MEMORY_TYPES, type, () -> new SQLFeatureNotSupportedException(String.format(\"Get value from `%s`\", type.getName())));\n        Object result = currentResultSetRow.getCell(columnIndex);\n        wasNull = null == result;\n        return result;\n    }\n    \n    @Override\n    public final Object getCalendarValue(final int columnIndex, final Class<?> type, @SuppressWarnings(\"UseOfObsoleteDateTimeApi\") final Calendar calendar) {\n        // TODO implement with calendar\n        Object result = currentResultSetRow.getCell(columnIndex);\n        wasNull = null == result;\n        return result;\n    }\n    \n    @Override\n    public final InputStream getInputStream(final int columnIndex, final String type) throws SQLException {\n        throw new SQLFeatureNotSupportedException(String.format(\"Get input stream from `%s`\", type));\n    }\n    \n    @Override\n    public Reader getCharacterStream(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"Get Character stream\");\n    }\n    \n    @Override\n    public final boolean wasNull() {\n        return wasNull;\n    }\n}\n","sourceCodeStart":75,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/memory/MemoryMergedResult.java#L75-L106","documentation":"MemoryMergedResult is the in-memory merge engine used for results that must be fully materialized and merged in ShardingSphere memory (e.g. GROUP BY, aggregate, pagination over merged rows). getInputStream(columnIndex, type) throws SQLFeatureNotSupportedException naming the requested stream type, because materialized memory rows cannot serve binary streams.","triggerScenarios":"Calling rs.getBinaryStream(i) / getAsciiStream(i) on a query whose results were merged in memory — any SELECT with aggregation, ORDER BY across shards, or LIMIT/OFFSET rewriting that routes to MemoryMergedResult.","commonSituations":"LOB-reading utility code applied uniformly to all result sets; queries that unexpectedly qualify for memory merge after adding GROUP BY/ORDER BY; migrations from single-DB drivers where getBinaryStream on BLOB columns worked.","solutions":["Read the column with rs.getBytes(i) or rs.getObject(i) instead of stream APIs for memory-merged results.","Restructure the query so LOB columns are fetched in a separate statement without merge-triggering clauses.","Catch SQLFeatureNotSupportedException and retry the read with getBytes."],"exampleFix":"// before\nInputStream blob = resultSet.getBinaryStream(3);\n\n// after\nbyte[] blob = resultSet.getBytes(3);","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try (InputStream in = rs.getBinaryStream(i)) { ... } catch (SQLFeatureNotSupportedException e) { byte[] data = rs.getBytes(i); ... }","preventionTips":["Avoid getBinaryStream on queries with GROUP BY/ORDER BY/LIMIT across shards.","Fetch LOB columns in a separate statement without merge clauses."],"tags":["jdbc","merge","memory-merge","stream"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}