{"record":{"id":"1ba1ea2620be8a0c","repo":"apache/shardingsphere","slug":"1295-1ba1ea","errorCode":"1295","errorMessage":"This command is not supported in the prepared statement protocol yet","messagePattern":"This command is not supported in the prepared statement protocol yet","errorType":"exception","errorClass":"UnsupportedPreparedStatementException","httpStatus":null,"severity":"error","filePath":"proxy/frontend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java","lineNumber":100,"sourceCode":"        failedIfContainsMultiStatements();\n        MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();\n        SQLParserRule sqlParserRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);\n        SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(databaseType).parse(packet.getSQL(), true);\n        ShardingSpherePreconditions.checkState(MySQLComStmtPrepareChecker.isAllowedStatement(sqlStatement), UnsupportedPreparedStatementException::new);\n        SQLStatementContext sqlStatementContext = new SQLBindEngine(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(),\n                connectionSession.getCurrentDatabaseName(), packet.getHintValueContext()).bind(sqlStatement);\n        int statementId = MySQLStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId());\n        MySQLServerPreparedStatement serverPreparedStatement = new MySQLServerPreparedStatement(packet.getSQL(), sqlStatementContext, packet.getHintValueContext());\n        connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(statementId, serverPreparedStatement);\n        return createPackets(sqlStatementContext, statementId, serverPreparedStatement);\n    }\n    \n    private void failedIfContainsMultiStatements() {\n        // TODO Multi statements should be identified by SQL Parser instead of checking if sql contains \";\".\n        if (connectionSession.getAttributeMap().hasAttr(MySQLConstants.OPTION_MULTI_STATEMENTS_ATTRIBUTE_KEY)\n                && MySQLComSetOptionPacket.MYSQL_OPTION_MULTI_STATEMENTS_ON == connectionSession.getAttributeMap().attr(MySQLConstants.OPTION_MULTI_STATEMENTS_ATTRIBUTE_KEY).get()\n                && packet.getSQL().contains(\";\")) {\n            throw new UnsupportedPreparedStatementException();\n        }\n    }\n    \n    private Collection<DatabasePacket> createPackets(final SQLStatementContext sqlStatementContext, final int statementId, final MySQLServerPreparedStatement serverPreparedStatement) {\n        Collection<Projection> projections = getProjections(sqlStatementContext);\n        Collection<DatabasePacket> result = new ArrayList<>(sqlStatementContext.getSqlStatement().getParameterCount() + projections.size() + 3);\n        int parameterCount = sqlStatementContext.getSqlStatement().getParameterCount();\n        ShardingSpherePreconditions.checkState(parameterCount <= MAX_PARAMETER_COUNT, TooManyPlaceholdersException::new);\n        result.add(new MySQLComStmtPrepareOKPacket(statementId, projections.size(), parameterCount, 0));\n        int characterSet = connectionSession.getAttributeMap().attr(MySQLConstants.CHARACTER_SET_ATTRIBUTE_KEY).get().getId();\n        int statusFlags = ServerStatusFlagCalculator.calculateFor(connectionSession, true);\n        if (parameterCount > 0) {\n            result.addAll(createParameterColumnDefinition41Packets(sqlStatementContext, characterSet, serverPreparedStatement));\n            result.add(new MySQLEofPacket(statusFlags));\n        }\n        if (!projections.isEmpty() && sqlStatementContext instanceof SelectStatementContext) {\n            result.addAll(createProjectionColumnDefinition41Packets((SelectStatementContext) sqlStatementContext, characterSet, serverPreparedStatement));\n            result.add(new MySQLEofPacket(statusFlags));","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/frontend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java#L82-L118","documentation":"Error \"This command is not supported in the prepared statement protocol yet\" thrown in apache/shardingsphere.","triggerScenarios":"COM_STMT_PREPARE is used for a statement type the proxy cannot prepare.","commonSituations":"Preparing unsupported SQL (certain DDL or administrative statements) through the MySQL binary protocol.","solutions":["Use statements that are supported in the prepared statement protocol.","Fall back to text protocol (COM_QUERY) for unsupported statement types.","Check the ShardingSphere documentation for the list of statements supported by COM_STMT_PREPARE."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}