apache/shardingsphere · error · UnsupportedPreparedStatementException

1295

1295

Error message

This command is not supported in the prepared statement protocol yet

What it means

Error "This command is not supported in the prepared statement protocol yet" thrown in apache/shardingsphere.

Source

Thrown at proxy/frontend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java:118

    private List<Object> readParameters(final MySQLServerPreparedStatement preparedStatement, final Set<Integer> longDataIndexes) throws SQLException {
        return packet.readParameters(getParameterTypes(preparedStatement), longDataIndexes, preparedStatement.getParameterColumnTypes());
    }
    
    private List<MySQLPreparedStatementParameterType> getParameterTypes(final MySQLServerPreparedStatement preparedStatement) {
        List<MySQLPreparedStatementParameterType> parameterTypes = preparedStatement.getParameterTypes();
        if (!parameterTypes.isEmpty()) {
            return parameterTypes;
        }
        List<MySQLPreparedStatementParameterType> originalTypes = packet.getNewParameterTypes();
        if (null != originalTypes && !originalTypes.isEmpty()) {
            return originalTypes;
        }
        int expectedParamCount = preparedStatement.getSqlStatementContext().getSqlStatement().getParameterCount();
        if (expectedParamCount <= 0) {
            return parameterTypes;
        }
        if (null == packet.getNullBitmap() || !isAllParametersNull(expectedParamCount)) {
            throw new UnsupportedPreparedStatementException();
        }
        List<MySQLPreparedStatementParameterType> result = new ArrayList<>(expectedParamCount);
        for (int i = 0; i < expectedParamCount; i++) {
            result.add(new MySQLPreparedStatementParameterType(MySQLBinaryColumnType.NULL, 0));
        }
        return result;
    }
    
    private boolean isAllParametersNull(final int expectedParamCount) {
        for (int i = 0; i < expectedParamCount; i++) {
            if (!packet.getNullBitmap().isNullParameter(i)) {
                return false;
            }
        }
        return true;
    }
    
    private MySQLServerPreparedStatement updateAndGetPreparedStatement() {

View on GitHub (pinned to e952770a21)

Solutions

  1. Avoid using this command inside the prepared statement protocol; use a plain text query instead.
  2. Check ShardingSphere release notes for supported prepared-statement commands.
  3. Execute the statement directly on the backend database if it cannot be routed.

When it happens

Trigger: COM_STMT_EXECUTE carries a command or cursor operation the proxy's prepared-statement protocol does not yet support.

Common situations: Cursor fetch or rarely used statement options sent by drivers through the binary protocol.


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/7466c9f7a0945bef. Report an issue: GitHub.