SonarSource/sonarqube · error · java.lang.IllegalStateException
Unsupported dialect for drop of index:
Error message
Unsupported dialect for drop of index:
What it means
DropIndexChange.createDropIndexSqlStatement builds DROP INDEX SQL per dialect; MsSql requires "ON <table>", Oracle plain DROP INDEX, H2/PostgreSQL support IF EXISTS. An unknown dialect id throws IllegalStateException "Unsupported dialect for drop of index: <dialect>".
Source
Thrown at server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/DropIndexChange.java:64
@Override
public void execute(Context context) throws SQLException {
findExistingIndexName()
.map(index -> createDropIndexSqlStatement(getDialect(), index))
.ifPresent(context::execute);
}
private Optional<String> findExistingIndexName() throws SQLException {
try (Connection connection = getDatabase().getDataSource().getConnection()) {
return DatabaseUtils.findExistingIndex(connection, tableName, indexName);
}
}
private String createDropIndexSqlStatement(Dialect dialect, String actualIndexName) {
return switch (dialect.getId()) {
case MsSql.ID -> "DROP INDEX " + actualIndexName + " ON " + tableName;
case Oracle.ID -> "DROP INDEX " + actualIndexName;
case H2.ID, PostgreSql.ID -> "DROP INDEX IF EXISTS " + actualIndexName;
default -> throw new IllegalStateException("Unsupported dialect for drop of index: " + dialect);
};
}
}
View on GitHub (pinned to 184c821202)
Solutions
- Confirm the configured dialect is one of the four supported engines.
- If a new dialect is required, add a case to createDropIndexSqlStatement with correct DROP INDEX syntax.
- Grep for switch (dialect.getId()) across sonar-db-migration to find all builders needing the new case.
Example fix
// before
default -> throw new IllegalStateException("Unsupported dialect for drop of index: " + dialect);
// after
case MySql.ID -> "DROP INDEX " + actualIndexName;
default -> throw new IllegalStateException("Unsupported dialect for drop of index: " + dialect); Defensive patterns
Strategy: validation
Validate before calling
if (!List.of(MsSql.ID, Oracle.ID, H2.ID, PostgreSql.ID).contains(dialect.getId())) {
throw new IllegalArgumentException("DROP INDEX unsupported for " + dialect.getId());
} Type guard
boolean supportsDropIndex(Dialect d) { return Set.of(MsSql.ID, Oracle.ID, H2.ID, PostgreSql.ID).contains(d.getId()); } Try / catch
try {
new DropIndexChange(dialect, tableName, indexName).execute(context);
} catch (IllegalStateException e) {
LOG.error("Index drop unsupported: {}", e.getMessage());
} Prevention
- Remember MsSql needs 'ON <table>' while others drop by name — don't reuse SQL across engines.
- Extend DropIndexChange when adding a new dialect id.
- Test every DropIndexChange-based migration against all supported dialects.
When it happens
Trigger: A DropIndexChange step executing DROP INDEX on a Dialect whose id is not mssql, oracle, h2, or postgresql.
Common situations: Unsupported database engines; new dialect integrated without updating DropIndexChange; corrupted/incorrect sonar.jdbc.dialect configuration.
Related errors
- Unsupported dialect for drop of constraint:
- Unsupported database '%s'
- Unsupported DB:
- Unsupported dialect id
- Unsupported dialect id
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/9be47bad256c16c0.
Report an issue: GitHub.