/** * @param schemaTable * @param name * @param generateAutoIndexName * @throws SqlJetException */ private boolean doDropIndex(String indexName, boolean allowAutoIndex, boolean throwIfFial) throws SqlJetException { if (!indexDefs.containsKey(indexName)) { if (throwIfFial) throw new SqlJetException(SqlJetErrorCode.MISUSE); return false; } final SqlJetBaseIndexDef indexDef = (SqlJetBaseIndexDef) indexDefs.get(indexName); if (!allowAutoIndex && indexDef.isImplicit()) { if (throwIfFial) throw new SqlJetException( SqlJetErrorCode.MISUSE, String.format(CANT_DELETE_IMPLICIT_INDEX, indexName)); return false; } final ISqlJetBtreeSchemaTable schemaTable = openSchemaTable(true); try { schemaTable.lock(); try { if (!schemaTable.goToRow(indexDef.getRowId()) || !INDEX_TYPE.equals(schemaTable.getTypeField())) { if (throwIfFial) throw new SqlJetException(SqlJetErrorCode.INTERNAL); return false; } final String n = schemaTable.getNameField(); if (null == n || !indexName.equals(n)) { if (throwIfFial) throw new SqlJetException(SqlJetErrorCode.INTERNAL); return false; } if (!allowAutoIndex && schemaTable.isNull(ISqlJetBtreeSchemaTable.SQL_FIELD)) { if (throwIfFial) throw new SqlJetException( SqlJetErrorCode.MISUSE, String.format(CANT_DELETE_IMPLICIT_INDEX, indexName)); return false; } schemaTable.delete(); } finally { schemaTable.unlock(); } } finally { schemaTable.close(); } final int page = indexDef.getPage(); final int moved = btree.dropTable(page); if (moved != 0) { movePage(page, moved); } return true; }