String catPrependedName = MetaStoreUtils.prependCatalogToDbName(catName, name, conf); Set<String> uniqueTableNames = new HashSet<>(get_all_tables(catPrependedName)); List<String> allFunctions = get_functions(catPrependedName, "*");
private void drop_database_core(RawStore ms, final String name, final boolean deleteData) throws NoSuchObjectException, InvalidOperationException, MetaException, IOException { boolean success = false; Database db = null; try { ms.openTransaction(); db = ms.getDatabase(name); if (!get_all_tables(db.getName()).isEmpty()) { throw new InvalidOperationException("Database " + db.getName() + " is not empty"); } Path path = new Path(db.getLocationUri()).getParent(); if (!wh.isWritable(path)) { throw new MetaException("Database not dropped since " + path + " is not writable by " + hiveConf.getUser()); } if (ms.dropDatabase(name)) { success = ms.commitTransaction(); } } finally { if (!success) { ms.rollbackTransaction(); } else if (deleteData) { wh.deleteDir(new Path(db.getLocationUri()), true); // it is not a terrible thing even if the data is not deleted } } }
List<String> allTables = get_all_tables(db.getName()); if (!cascade && !allTables.isEmpty()) { throw new InvalidOperationException("Database " + db.getName() + " is not empty");
String catPrependedName = MetaStoreUtils.prependCatalogToDbName(catName, name, conf); Set<String> uniqueTableNames = new HashSet<>(get_all_tables(catPrependedName)); List<String> allFunctions = get_functions(catPrependedName, "*");
List<String> allTables = get_all_tables(db.getName()); List<String> allFunctions = get_functions(db.getName(), "*");
List<String> allTables = get_all_tables(db.getName()); List<String> allFunctions = get_functions(db.getName(), "*");
/** * Drop the privileges on the database. Note that child tables will be * dropped individually by client, so we just need to handle the removing * the db privileges. The table drop should cleanup the table privileges. */ @Override public void onDropDatabase(DropDatabaseEvent dbEvent) throws MetaException { // don't sync paths/privileges if the operation has failed if (!dbEvent.getStatus()) { LOGGER.debug("Skip syncing paths/privileges with Sentry server for onDropDatabase event," + " since the operation failed. \n"); return; } String authzObj = dbEvent.getDatabase().getName(); for (SentryMetastoreListenerPlugin plugin : sentryPlugins) { List<String> tNames = dbEvent.getHandler().get_all_tables(authzObj); plugin.removeAllPaths(authzObj, tNames); } if (!syncWithPolicyStore(AuthzConfVars.AUTHZ_SYNC_DROP_WITH_POLICY_STORE)) { return; } dropSentryDbPrivileges(dbEvent.getDatabase().getName()); }