}
private void dropTableCommon(Session session, TableName tableName, final DropBehavior dropBehavior,
final boolean isInternal, final boolean mustBeMemory) {
checkTableName(session, tableName, true, isInternal);
final AkibanInformationSchema oldAIS = getAISForChange(session, !isInternal);
final Table table = oldAIS.getTable(tableName);
final List<TableName> tables = new ArrayList<>();
final Set<String> schemas = new HashSet<>();
final List<Integer> tableIDs = new ArrayList<>();
final Set<TableName> sequences = new HashSet<>();
// Collect all tables in branch below this point
table.visit(new AbstractVisitor() {
@Override
public void visit(Table table) {
if(mustBeMemory && !table.hasMemoryTableFactory()) {
throw new IllegalArgumentException("Cannot un-register non-memory table");
}
if((dropBehavior == DropBehavior.RESTRICT) && !table.getChildJoins().isEmpty()) {
throw new ReferencedTableException (table);
}
TableName name = table.getName();
tables.add(name);
schemas.add(name.getSchemaName());
tableIDs.add(table.getTableId());
for (Column column : table.getColumnsIncludingInternal()) {
if (column.getIdentityGenerator() != null) {
sequences.add(column.getIdentityGenerator().getSequenceName());
}
}
}
});
final AkibanInformationSchema newAIS = removeTablesFromAIS(oldAIS, tables, sequences);
for(Integer tableID : tableIDs) {
clearTableStatus(session, oldAIS.getTable(tableID));
}