{"record":{"id":"4870014f7e9d68fc","repo":"apache/shardingsphere","slug":"30001","errorCode":"30001","errorMessage":"Unsupported SQL operation: %s.","messagePattern":"Unsupported SQL operation: (.+?)\\.","errorType":"exception","errorClass":"UnsupportedSQLOperationException","httpStatus":null,"severity":"error","filePath":"proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateProxyBackendHandlerFactory.java","lineNumber":58,"sourceCode":"     * Create new instance of database operate backend handler.\n     *\n     * @param sqlStatement SQL statement\n     * @param connectionSession connection session\n     * @return created instance\n     */\n    public static ProxyBackendHandler newInstance(final SQLStatement sqlStatement, final ConnectionSession connectionSession) {\n        return createProxyBackendHandler(sqlStatement, connectionSession);\n    }\n    \n    private static ProxyBackendHandler createProxyBackendHandler(final SQLStatement sqlStatement, final ConnectionSession connectionSession) {\n        ContextManager contextManager = ProxyContext.getInstance().getContextManager();\n        if (sqlStatement instanceof CreateDatabaseStatement) {\n            return new CreateDatabaseProxyBackendHandler((CreateDatabaseStatement) sqlStatement, contextManager);\n        }\n        if (sqlStatement instanceof DropDatabaseStatement) {\n            return new DropDatabaseProxyBackendHandler((DropDatabaseStatement) sqlStatement, contextManager, connectionSession);\n        }\n        throw new UnsupportedSQLOperationException(sqlStatement.getClass().getName());\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateProxyBackendHandlerFactory.java#L40-L61","documentation":"UnsupportedSQLOperationException (error code 30001) thrown by DatabaseOperateProxyBackendHandlerFactory.createProxyBackendHandler when a parsed SQLStatement reaches this factory but is neither a CreateDatabaseStatement nor a DropDatabaseStatement. The factory only builds handlers for database-level CREATE/DROP operations; any other statement type is a programming or routing error at the caller.","triggerScenarios":"Calling DatabaseOperateProxyBackendHandlerFactory.newInstance(sqlStatement, connectionSession) with a statement class outside {CreateDatabaseStatement, DropDatabaseStatement} — e.g. a new database-operate statement type added to the parser without a matching handler branch here.","commonSituations":"Extending the proxy with new DDL statement types and forgetting to register a handler; version skew where the parser (dialect frontend) produces statement classes newer than the backend handler factory knows; misconfigured statement classification in a custom frontend protocol.","solutions":["Route only CREATE/DROP DATABASE statements to this factory; other statements belong in the regular SQL or DistSQL handler factories","If you added a new database-operate statement type, add an instanceof branch constructing the proper ProxyBackendHandler before the throw","Align frontend parser and backend-core versions so recognized statement types match"],"exampleFix":"// before\nif (sqlStatement instanceof CreateDatabaseStatement) { ... }\nif (sqlStatement instanceof DropDatabaseStatement) { ... }\nthrow new UnsupportedSQLOperationException(sqlStatement.getClass().getName());\n\n// after (supporting a new statement type)\nif (sqlStatement instanceof CreateDatabaseStatement) { ... }\nif (sqlStatement instanceof DropDatabaseStatement) { ... }\nif (sqlStatement instanceof AlterDatabaseStatement) {\n    return new AlterDatabaseProxyBackendHandler((AlterDatabaseStatement) sqlStatement, contextManager);\n}\nthrow new UnsupportedSQLOperationException(sqlStatement.getClass().getName());","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"private boolean isSupportedDatabaseOperateStatement(final SQLStatement stmt) {\n    return stmt instanceof CreateDatabaseStatement || stmt instanceof DropDatabaseStatement;\n}","tryCatchPattern":"try {\n    handler = DatabaseOperateProxyBackendHandlerFactory.newInstance(stmt, connectionSession);\n} catch (final UnsupportedSQLOperationException ex) {\n    // statement was routed to the wrong factory; route to the standard SQL handler chain instead\n}","preventionTips":["When adding database-operate statement types, add the handler branch in the same change and a routing test","Keep frontend parser and backend-core versions aligned in custom builds"],"tags":["sql","proxy","unsupported-operation","factory","ddl"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}