{"record":{"id":"01804e92d02a65a4","repo":"apache/shardingsphere","slug":"expected-blr-message","errorCode":null,"errorMessage":"Expected blr_message","messagePattern":"Expected blr_message","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/batch/FirebirdParseBatchBlr.java","lineNumber":87,"sourceCode":"     * @param blrLength BLR length\n     * @return parsed message format\n     * @throws IllegalArgumentException when BLR format is structurally invalid\n     */\n    public static FirebirdParseBatchBlr parseForFraming(final ByteBuf blr, final int blrLength) {\n        if (blrLength < HEADER_LENGTH) {\n            throw new IllegalArgumentException(\"BLR is too short: \" + blrLength);\n        }\n        ByteBuf buffer = blr.duplicate();\n        final int startReaderIndex = buffer.readerIndex();\n        int version = buffer.readUnsignedByte();\n        if (BlrConstants.blr_version4 != version && BlrConstants.blr_version5 != version) {\n            throw new IllegalArgumentException(\"Unsupported BLR version: \" + version);\n        }\n        if (BlrConstants.blr_begin != buffer.readUnsignedByte()) {\n            throw new IllegalArgumentException(\"Expected blr_begin\");\n        }\n        if (BlrConstants.blr_message != buffer.readUnsignedByte()) {\n            throw new IllegalArgumentException(\"Expected blr_message\");\n        }\n        buffer.skipBytes(1);\n        FirebirdParseBatchBlr result = parseFormat(buffer);\n        validateTermination(buffer, startReaderIndex, blrLength);\n        return result;\n    }\n    \n    private static void validateTermination(final ByteBuf buffer, final int startReaderIndex, final int blrLength) {\n        if (remainingWithinBlr(buffer, startReaderIndex, blrLength) < 1 || BlrConstants.blr_end != buffer.readUnsignedByte()) {\n            throw new IllegalArgumentException(\"Expected blr_end\");\n        }\n        if (remainingWithinBlr(buffer, startReaderIndex, blrLength) < 1 || BlrConstants.blr_eoc != buffer.readUnsignedByte()) {\n            throw new IllegalArgumentException(\"Expected blr_eoc\");\n        }\n        if (0 != remainingWithinBlr(buffer, startReaderIndex, blrLength)) {\n            throw new IllegalArgumentException(\"Unexpected trailing bytes in BLR\");\n        }\n    }","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/batch/FirebirdParseBatchBlr.java#L69-L105","documentation":"SQLFeatureNotSupportedException thrown by updateBlob(String, InputStream) on SQL federation ResultSets. The label+stream overload of updateBlob is final and throws in AbstractUnsupportedUpdateOperationSQLFederationResultSet, consistent with the class's contract: federation supports only read navigation of merged shard results. Any attempt to stream binary data into a named column of the current row is rejected at call time.","triggerScenarios":"Calling rs.updateBlob(\"content\", inputStream) on a federated ResultSet before rs.updateRow(). Typical when upload code binds the BLOB column by its label.","commonSituations":"Attachment/file features that mutate rows while iterating a federated JOIN; persistence frameworks that map fields by label and call updateBlob during flush; environment change from direct driver to ShardingSphere proxy/JDBC.","solutions":["Issue UPDATE ... SET content = ? WHERE ... with ps.setBinaryStream instead","Validate concurrency mode with rs.getConcurrency() before iterating when edits are planned","Prevent federation for that query by rewriting SQL or adjusting federation settings"],"exampleFix":"// before\nrs.updateBlob(\"content\", uploadInputStream); // SQLFeatureNotSupportedException\n\n// after\ntry (PreparedStatement ps = conn.prepareStatement(\"UPDATE files SET content = ? WHERE id = ?\")) {\n    ps.setBinaryStream(1, uploadInputStream);\n    ps.setLong(2, rs.getLong(\"id\"));\n    ps.executeUpdate();\n}","handlingStrategy":"try-catch","validationCode":"if (rs.getConcurrency() == ResultSet.CONCUR_READ_ONLY) {\n    // label+stream updateBlob unsupported: use UPDATE + setBinaryStream\n}","typeGuard":null,"tryCatchPattern":"try {\n    rs.updateBlob(\"content\", inputStream);\n} catch (SQLFeatureNotSupportedException e) {\n    // federation cursor read-only; stream via PreparedStatement UPDATE\n}","preventionTips":["Bind uploads to DML, not cursor mutation","Manage stream lifecycle in the caller regardless of the exception","Probe concurrency mode once and branch"],"tags":["jdbc","resultset","sql-federation","read-only","blob","streaming"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}