@Override public void dropTables(final Set<TableReference> tableRefs) throws InsufficientConsistencyException { if (tableRefs.isEmpty()) { return; } run((Function<DSLContext, Void>) ctx -> { for (TableReference tableRef : tableRefs) { ctx.dropTableIfExists(tableName(tableRef)).execute(); } ctx.deleteFrom(METADATA_TABLE) .where(TABLE_NAME.in(tableRefs)) .execute(); return null; }); }
private static final DDLQuery parseDropTable(ParserContext ctx, boolean temporary) { boolean ifExists = parseKeywordIf(ctx, "IF EXISTS"); Table<?> tableName = parseTableName(ctx); boolean cascade = parseKeywordIf(ctx, "CASCADE"); boolean restrict = !cascade && parseKeywordIf(ctx, "RESTRICT"); DropTableStep s1; DropTableFinalStep s2; s1 = ifExists ? ctx.dsl.dropTableIfExists(tableName) : temporary ? ctx.dsl.dropTemporaryTable(tableName) : ctx.dsl.dropTable(tableName); s2 = cascade ? s1.cascade() : restrict ? s1.restrict() : s1; return s2; }