}
private int alterDatabase(AlterDatabaseDesc alterDbDesc) throws HiveException {
String dbName = alterDbDesc.getDatabaseName();
Database database = db.getDatabase(dbName);
Map<String, String> newParams = alterDbDesc.getDatabaseProperties();
if (database != null) {
Map<String, String> params = database.getParameters();
// if both old and new params are not null, merge them
if (params != null && newParams != null) {
params.putAll(newParams);
database.setParameters(params);
} else { // if one of them is null, replace the old params with the new one
database.setParameters(newParams);
}
db.alterDatabase(database.getName(), database);
} else {
throw new HiveException(ErrorMsg.DATABASE_NOT_EXISTS, dbName);
}
return 0;
}