apache/shardingsphere · error · UnsupportedSQLOperationException
30001
30001
Error message
Unsupported SQL operation: %s.
What it means
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.
Source
Thrown at proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateProxyBackendHandlerFactory.java:58
* Create new instance of database operate backend handler.
*
* @param sqlStatement SQL statement
* @param connectionSession connection session
* @return created instance
*/
public static ProxyBackendHandler newInstance(final SQLStatement sqlStatement, final ConnectionSession connectionSession) {
return createProxyBackendHandler(sqlStatement, connectionSession);
}
private static ProxyBackendHandler createProxyBackendHandler(final SQLStatement sqlStatement, final ConnectionSession connectionSession) {
ContextManager contextManager = ProxyContext.getInstance().getContextManager();
if (sqlStatement instanceof CreateDatabaseStatement) {
return new CreateDatabaseProxyBackendHandler((CreateDatabaseStatement) sqlStatement, contextManager);
}
if (sqlStatement instanceof DropDatabaseStatement) {
return new DropDatabaseProxyBackendHandler((DropDatabaseStatement) sqlStatement, contextManager, connectionSession);
}
throw new UnsupportedSQLOperationException(sqlStatement.getClass().getName());
}
}
View on GitHub (pinned to e952770a21)
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
Example fix
// before
if (sqlStatement instanceof CreateDatabaseStatement) { ... }
if (sqlStatement instanceof DropDatabaseStatement) { ... }
throw new UnsupportedSQLOperationException(sqlStatement.getClass().getName());
// after (supporting a new statement type)
if (sqlStatement instanceof CreateDatabaseStatement) { ... }
if (sqlStatement instanceof DropDatabaseStatement) { ... }
if (sqlStatement instanceof AlterDatabaseStatement) {
return new AlterDatabaseProxyBackendHandler((AlterDatabaseStatement) sqlStatement, contextManager);
}
throw new UnsupportedSQLOperationException(sqlStatement.getClass().getName()); Defensive patterns
Strategy: type-guard
Type guard
private boolean isSupportedDatabaseOperateStatement(final SQLStatement stmt) {
return stmt instanceof CreateDatabaseStatement || stmt instanceof DropDatabaseStatement;
} Try / catch
try {
handler = DatabaseOperateProxyBackendHandlerFactory.newInstance(stmt, connectionSession);
} catch (final UnsupportedSQLOperationException ex) {
// statement was routed to the wrong factory; route to the standard SQL handler chain instead
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- 30001
- Statement is not supported by the MCP contract.
- Algorithm `%s` is unsupported to decrypt
- 40
- getUnicodeStream
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/4870014f7e9d68fc.
Report an issue: GitHub.