final String indexName = indexDef.getName();
final long rowId = indexDef.getRowId();
final int page = indexDef.getPage();
if (!schemaTable.goToRow(rowId)) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
final String typeField = schemaTable.getTypeField();
final String nameField = schemaTable.getNameField();
final String tableField = schemaTable.getTableField();
final int pageField = schemaTable.getPageField();
if (null == typeField || !INDEX_TYPE.equals(typeField)) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
if (null == nameField || !indexName.equals(nameField)) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
if (null == tableField || !tableName.equals(tableField)) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
if (0 == pageField || pageField != page) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
indexDef.setTableName(newTableName);
String newIndexName = indexName;
String alteredIndexSql = null;
if (index.isImplicit()) {
newIndexName = generateAutoIndexName(tableName, ++i);
indexDef.setName(newIndexName);
indexDefs.remove(indexName);
indexDefs.put(newIndexName, indexDef);
} else {
alteredIndexSql = getAlteredIndexSql(schemaTable.getSqlField(), alterTableName);
}
schemaTable.insertRecord(INDEX_TYPE, newIndexName, newTableName, page, alteredIndexSql);
} else {
throw new SqlJetException(SqlJetErrorCode.INTERNAL);
}
}
}