OtterMind/Chat2DB · error · BusinessException

database.delete.notSupportSchema

database.delete.notSupportSchema

Error message

database.delete.notSupportSchema

What it means

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.

Source

Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDatabaseObjectDeleteServiceImpl.java:234

                .sqlPreview(sqlPreview)
                .objectType(objectType)
                .dbType(dbType)
                .build();
    }

    private String databaseConfirmName(String databaseName) {
        return databaseName;
    }

    private String buildDropDatabase(String dbType, String databaseName) {
        return Chat2DBContext.getDbMetaData(dbType).getSqlBuilder().ddl().database().buildDropDatabase(databaseName);
    }

    private void assertSchemaDeletionSupported(String dbType) {
        DBConfig dbConfig = Chat2DBContext.getDBConfig(dbType);
        if (dbConfig == null || !dbConfig.isSupportSchema()
                || !DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)) {
            throw new BusinessException("database.delete.notSupportSchema");
        }
    }

    private void rejectSystemSchema(String dbType, String schemaName) {
        if (DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)) {
            String lowerSchemaName = StringUtils.lowerCase(schemaName);
            if (POSTGRESQL_SYSTEM_SCHEMAS.contains(lowerSchemaName)
                    || StringUtils.startsWith(lowerSchemaName, "pg_toast")
                    || StringUtils.startsWith(lowerSchemaName, "pg_temp")) {
                throw new BusinessException("database.delete.systemSchemaForbidden");
            }
        }
    }

    private void assertSchemaExists(Connection connection, String databaseName, String schemaName) {
        List<Schema> schemas = Chat2DBContext.getDbMetaData().schemas(connection, databaseName);
        boolean exists = schemas != null && schemas.stream()
                .anyMatch(schema -> StringUtils.equals(schema.getName(), schemaName));

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Use a PostgreSQL connection for schema deletion operations.
  2. For MySQL, delete at the database level instead (MySQL treats schema≈database).
  3. If extending to another schema-capable dialect, update the assertSchemaDeletionSupported gate accordingly.

Example fix

// before
prepareSchemaDelete(req); // dbType=MYSQL -> notSupportSchema

// after
if ("POSTGRESQL".equalsIgnoreCase(profile.getDbType())) {
    prepareSchemaDelete(req);
}
Defensive patterns

Strategy: validation

Validate before calling

DBConfig cfg = Chat2DBContext.getDBConfig(dbType);
if (cfg == null || !cfg.isSupportSchema() || !"POSTGRESQL".equalsIgnoreCase(dbType)) {
    // do not call prepareSchemaDelete / executeSchemaDelete
}

Prevention

When it happens

Trigger: 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.

Common situations: Selecting a MySQL datasource and attempting schema-level delete; selecting a flat-schema dialect; a plugin DBConfig with isSupportSchema incorrectly false.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/ee8324f04ccb5ebe. Report an issue: GitHub.