{"record":{"id":"9be47bad256c16c0","repo":"SonarSource/sonarqube","slug":"unsupported-dialect-for-drop-of-index","errorCode":null,"errorMessage":"Unsupported dialect for drop of index: ","messagePattern":"Unsupported dialect for drop of index: ","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/DropIndexChange.java","lineNumber":64,"sourceCode":"  @Override\n  public void execute(Context context) throws SQLException {\n    findExistingIndexName()\n      .map(index -> createDropIndexSqlStatement(getDialect(), index))\n      .ifPresent(context::execute);\n  }\n\n  private Optional<String> findExistingIndexName() throws SQLException {\n    try (Connection connection = getDatabase().getDataSource().getConnection()) {\n      return DatabaseUtils.findExistingIndex(connection, tableName, indexName);\n    }\n  }\n\n  private String createDropIndexSqlStatement(Dialect dialect, String actualIndexName) {\n    return switch (dialect.getId()) {\n      case MsSql.ID -> \"DROP INDEX \" + actualIndexName + \" ON \" + tableName;\n      case Oracle.ID -> \"DROP INDEX \" + actualIndexName;\n      case H2.ID, PostgreSql.ID -> \"DROP INDEX IF EXISTS \" + actualIndexName;\n      default -> throw new IllegalStateException(\"Unsupported dialect for drop of index: \" + dialect);\n    };\n  }\n}\n","sourceCodeStart":46,"sourceCodeEnd":68,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/DropIndexChange.java#L46-L68","documentation":"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>\".","triggerScenarios":"A DropIndexChange step executing DROP INDEX on a Dialect whose id is not mssql, oracle, h2, or postgresql.","commonSituations":"Unsupported database engines; new dialect integrated without updating DropIndexChange; corrupted/incorrect sonar.jdbc.dialect configuration.","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."],"exampleFix":"// before\ndefault -> throw new IllegalStateException(\"Unsupported dialect for drop of index: \" + dialect);\n// after\ncase MySql.ID -> \"DROP INDEX \" + actualIndexName;\ndefault -> throw new IllegalStateException(\"Unsupported dialect for drop of index: \" + dialect);","handlingStrategy":"validation","validationCode":"if (!List.of(MsSql.ID, Oracle.ID, H2.ID, PostgreSql.ID).contains(dialect.getId())) {\n  throw new IllegalArgumentException(\"DROP INDEX unsupported for \" + dialect.getId());\n}","typeGuard":"boolean supportsDropIndex(Dialect d) { return Set.of(MsSql.ID, Oracle.ID, H2.ID, PostgreSql.ID).contains(d.getId()); }","tryCatchPattern":"try {\n  new DropIndexChange(dialect, tableName, indexName).execute(context);\n} catch (IllegalStateException e) {\n  LOG.error(\"Index drop unsupported: {}\", e.getMessage());\n}","preventionTips":["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."],"tags":["database","migration","unsupported-dialect","index"],"backgroundTag":"unsupported-enum-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}