assertNotNull("Found new table " + newName, oldTable);
runAlter(ChangeLevel.METADATA, oldName, newTable, NO_CHANGES, NO_CHANGES);
}
protected void runRenameColumn(TableName tableName, String oldColName, String newColName) {
AkibanInformationSchema aisCopy = aisCloner().clone(ddl().getAIS(session()));
Table tableCopy = aisCopy.getTable(tableName);
assertNotNull("Found table " + tableName, tableCopy);
Column oldColumn = tableCopy.getColumn(oldColName);
assertNotNull("Found old column " + oldColName, oldColumn);
// Have to do this manually as parser doesn't support it, duplicates much of the work in AlterTableDDL
List<Column> columns = new ArrayList<>(tableCopy.getColumns());
tableCopy.dropColumns();
for(Column column : columns) {
Column.create(tableCopy, column, (column == oldColumn) ? newColName : null, null);
}
Column newColumn = tableCopy.getColumn(newColName);
assertNotNull("Found new column " + newColName, newColumn);
List<TableIndex> indexes = new ArrayList<>(tableCopy.getIndexes());
for(TableIndex index : indexes) {
if(index.containsTableColumn(tableName, oldColName)) {
tableCopy.removeIndexes(Collections.singleton(index));
if (index.getConstraintName() != null) {
aisCopy.removeConstraint(index.getConstraintName());
}
TableIndex indexCopy = TableIndex.create(tableCopy, index);
for(IndexColumn iCol : index.getKeyColumns()) {
IndexColumn.create(indexCopy, (iCol.getColumn() == oldColumn) ? newColumn : iCol.getColumn(), iCol, iCol.getPosition());
}