{"record":{"id":"ee8324f04ccb5ebe","repo":"OtterMind/Chat2DB","slug":"database-delete-notsupportschema","errorCode":"database.delete.notSupportSchema","errorMessage":"database.delete.notSupportSchema","messagePattern":"database\\.delete\\.notSupportSchema","errorType":"validation","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDatabaseObjectDeleteServiceImpl.java","lineNumber":234,"sourceCode":"                .sqlPreview(sqlPreview)\n                .objectType(objectType)\n                .dbType(dbType)\n                .build();\n    }\n\n    private String databaseConfirmName(String databaseName) {\n        return databaseName;\n    }\n\n    private String buildDropDatabase(String dbType, String databaseName) {\n        return Chat2DBContext.getDbMetaData(dbType).getSqlBuilder().ddl().database().buildDropDatabase(databaseName);\n    }\n\n    private void assertSchemaDeletionSupported(String dbType) {\n        DBConfig dbConfig = Chat2DBContext.getDBConfig(dbType);\n        if (dbConfig == null || !dbConfig.isSupportSchema()\n                || !DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)) {\n            throw new BusinessException(\"database.delete.notSupportSchema\");\n        }\n    }\n\n    private void rejectSystemSchema(String dbType, String schemaName) {\n        if (DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)) {\n            String lowerSchemaName = StringUtils.lowerCase(schemaName);\n            if (POSTGRESQL_SYSTEM_SCHEMAS.contains(lowerSchemaName)\n                    || StringUtils.startsWith(lowerSchemaName, \"pg_toast\")\n                    || StringUtils.startsWith(lowerSchemaName, \"pg_temp\")) {\n                throw new BusinessException(\"database.delete.systemSchemaForbidden\");\n            }\n        }\n    }\n\n    private void assertSchemaExists(Connection connection, String databaseName, String schemaName) {\n        List<Schema> schemas = Chat2DBContext.getDbMetaData().schemas(connection, databaseName);\n        boolean exists = schemas != null && schemas.stream()\n                .anyMatch(schema -> StringUtils.equals(schema.getName(), schemaName));","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDatabaseObjectDeleteServiceImpl.java#L216-L252","documentation":"Thrown by assertSchemaDeletionSupported when the dbType's DBConfig does not support schemas (isSupportSchema()==false), is null, or the dbType is not PostgreSQL. Schema deletion is intentionally restricted to PostgreSQL only. This is a triple gate: supportSchema flag AND dbType==POSTGRESQL.","triggerScenarios":"Calling prepareSchemaDelete or executeSchemaDelete on a MySQL connection (MySQL is excluded despite supporting schemas), or on any non-PostgreSQL dialect, or on a dialect whose DBConfig.isSupportSchema() is false.","commonSituations":"Selecting a MySQL datasource and attempting schema-level delete; selecting a flat-schema dialect; a plugin DBConfig with isSupportSchema incorrectly false.","solutions":["Use a PostgreSQL connection for schema deletion operations.","For MySQL, delete at the database level instead (MySQL treats schema≈database).","If extending to another schema-capable dialect, update the assertSchemaDeletionSupported gate accordingly."],"exampleFix":"// before\nprepareSchemaDelete(req); // dbType=MYSQL -> notSupportSchema\n\n// after\nif (\"POSTGRESQL\".equalsIgnoreCase(profile.getDbType())) {\n    prepareSchemaDelete(req);\n}","handlingStrategy":"validation","validationCode":"DBConfig cfg = Chat2DBContext.getDBConfig(dbType);\nif (cfg == null || !cfg.isSupportSchema() || !\"POSTGRESQL\".equalsIgnoreCase(dbType)) {\n    // do not call prepareSchemaDelete / executeSchemaDelete\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict the delete-schema UI action to PostgreSQL connections only.","For MySQL, route schema deletion to the database-delete flow."],"tags":["schema-delete","dbtype-capability","postgresql","validation"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}