{"record":{"id":"73a2e28af36cfb55","repo":"OtterMind/Chat2DB","slug":"database-delete-notsupportschema-73a2e2","errorCode":"database.delete.notSupportSchema","errorMessage":"database.delete.notSupportSchema","messagePattern":"database\\.delete\\.notSupportSchema","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-mysql/src/main/java/ai/chat2db/plugin/mysql/MysqlDBManager.java","lineNumber":235,"sourceCode":"        if (StringUtils.isEmpty(database)) {\n            return;\n        }\n        try {\n            DefaultSQLExecutor.getInstance().execute(connection, String.format(SQL_SELECT_DATABASE_TEMPLATE, format(database)));\n        } catch (SQLException e) {\n            throw new RuntimeException(e);\n        }\n    }\n\n\n    @Override\n    public void dropDatabase(Connection connection, String databaseName) {\n        executeDropSql(connection, new MysqlSqlBuilder().ddl().database().buildDropDatabase(databaseName));\n    }\n\n    @Override\n    public void dropSchema(Connection connection, String databaseName, String schemaName) {\n        throw new BusinessException(\"database.delete.notSupportSchema\");\n    }\n\n    void executeDropSql(Connection connection, String sql) {\n        DefaultSQLExecutor.getInstance().execute(connection, sql, resultSet -> null);\n    }\n\n    @Override\n    public String dropTable(Connection connection, String databaseName, String schemaName, String tableName) {\n        return String.format(SQL_DROP_TABLE_TEMPLATE, format(tableName));\n    }\n\n    @Override\n    public String truncateTable(Connection connection, String databaseName, String schemaName, String tableName) {\n        return String.format(SQL_TRUNCATE_TABLE_TEMPLATE, format(tableName));\n    }\n\n    @Override\n    public void copyTable(Connection connection, String databaseName, String schemaName, String tableName, String newTableName, boolean copyData) {","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-mysql/src/main/java/ai/chat2db/plugin/mysql/MysqlDBManager.java#L217-L253","documentation":"Thrown by MysqlDBManager.dropSchema because MySQL has no separate schema concept: a MySQL 'schema' is synonymous with a database. The method unconditionally throws BusinessException('database.delete.notSupportSchema') to signal the operation is not applicable to this dialect. The frontend should route schema-level deletes to dropDatabase for MySQL connections.","triggerScenarios":"Calling dbManager.dropSchema(connection, databaseName, schemaName) on a MySQL-backed connection. Any non-null arguments produce this because the body never inspects them.","commonSituations":"Generic multi-dialect UI code invokes dropSchema uniformly across plugins; on a MySQL datasource this hits the no-op branch. Also occurs when migrating schema objects from a schema-aware dialect (PostgreSQL/Oracle) and replaying the same calls against MySQL.","solutions":["Gate dropSchema calls behind a dialect capability check: on MySQL, call dropDatabase instead and do not call dropSchema.","Inspect the connection's DB type before invoking and branch to the MySQL-specific path.","If using the generic DBManager interface, treat BusinessException with this code as 'unsupported' and degrade gracefully in the UI.","Confirm the caller is not sending a real schema name expecting a schema-scoped drop on MySQL."],"exampleFix":"// before\ndbManager.dropSchema(connection, databaseName, schemaName);\n\n// after\nif (isMysql(connection)) {\n    dbManager.dropDatabase(connection, databaseName);\n} else {\n    dbManager.dropSchema(connection, databaseName, schemaName);\n}","handlingStrategy":"validation","validationCode":"if (supportsSchemas(connection)) {\n    dbManager.dropSchema(connection, databaseName, schemaName);\n} else {\n    dbManager.dropDatabase(connection, databaseName);\n}","typeGuard":"static boolean mysqlSupportsSchema() {\n    return false; // MySQL treats schema == database\n}","tryCatchPattern":"try {\n    dbManager.dropSchema(connection, databaseName, schemaName);\n} catch (BusinessException e) {\n    if (\"database.delete.notSupportSchema\".equals(e.getCode())) {\n        dbManager.dropDatabase(connection, databaseName);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Branch schema-level deletes by dialect before calling the generic interface.","On MySQL, route schema deletes to dropDatabase.","Treat 'notSupportSchema' codes as unsupported-operation signals, not errors to retry.","Keep a dialect capability map so UI options match the connected database."],"tags":["mysql","ddl","unsupported-operation","schema"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}