AkibanInformationSchema oldAIS = getAISForChange(session);
Set<String> schemas = new HashSet<>();
List<Integer> tableIDs = new ArrayList<>(alteredTables.size());
for(ChangedTableDescription desc : alteredTables) {
TableName oldName = desc.getOldName();
TableName newName = desc.getNewName();
checkTableName(session, oldName, true, false);
if(!oldName.equals(newName)) {
checkTableName(session, newName, false, false);
}
Table newTable = desc.getNewDefinition();
if(newTable != null) {
AISInvariants.checkJoinTo(newTable.getParentJoin(), newName, false);
if(newTable.getColumns().isEmpty()) {
throw new NoColumnsInTableException(newName);
}
}
schemas.add(oldName.getSchemaName());
schemas.add(newName.getSchemaName());
tableIDs.add(oldAIS.getTable(oldName).getTableId());
}
AISMerge merge = AISMerge.newForModifyTable(aisCloner, getNameGenerator(session), oldAIS, alteredTables);
merge.merge();