private int dropDatabase(Hive db, DropDatabaseDesc dropDb)
throws HiveException {
try {
String dbName = dropDb.getDatabaseName();
ReplicationSpec replicationSpec = dropDb.getReplicationSpec();
if (replicationSpec.isInReplicationScope()) {
Database database = db.getDatabase(dbName);
if (database == null
|| !replicationSpec.allowEventReplacementInto(database.getParameters())) {
return 0;
}
}
db.dropDatabase(dbName, true, dropDb.getIfExists(), dropDb.isCasdade());
if (dropDb.isCasdade()) {
FunctionRegistry.unregisterPermanentFunctions(dbName);
}
} catch (NoSuchObjectException ex) {
throw new HiveException(ex, ErrorMsg.DATABASE_NOT_EXISTS, dropDb.getDatabaseName());
}
return 0;
}