The DROP DATABASE statement.
| 69 | * The <code>DROP DATABASE</code> statement. |
| 70 | */ |
| 71 | @SuppressWarnings({ "unused" }) |
| 72 | final class DropDatabaseImpl |
| 73 | extends |
| 74 | AbstractDDLQuery |
| 75 | implements |
| 76 | QOM.DropDatabase, |
| 77 | DropDatabaseFinalStep |
| 78 | { |
| 79 | |
| 80 | final Catalog database; |
| 81 | final boolean ifExists; |
| 82 | |
| 83 | DropDatabaseImpl( |
| 84 | Configuration configuration, |
| 85 | Catalog database, |
| 86 | boolean ifExists |
| 87 | ) { |
| 88 | super(configuration); |
| 89 | |
| 90 | this.database = database; |
| 91 | this.ifExists = ifExists; |
| 92 | } |
| 93 | |
| 94 | // ------------------------------------------------------------------------- |
| 95 | // XXX: QueryPart API |
| 96 | // ------------------------------------------------------------------------- |
| 97 | |
| 98 | |
| 99 | |
| 100 | private static final Set<SQLDialect> NO_SUPPORT_IF_EXISTS = SQLDialect.supportedUntil(DERBY, FIREBIRD); |
| 101 | |
| 102 | private final boolean supportsIfExists(Context<?> ctx) { |
| 103 | return !NO_SUPPORT_IF_EXISTS.contains(ctx.dialect()); |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public final void accept(Context<?> ctx) { |
| 108 | if (ifExists && !supportsIfExists(ctx)) |
| 109 | tryCatch(ctx, DDLStatementType.DROP_DATABASE, c -> accept0(c)); |
| 110 | else |
| 111 | accept0(ctx); |
| 112 | } |
| 113 | |
| 114 | private void accept0(Context<?> ctx) { |
| 115 | ctx.visit(K_DROP).sql(' '); |
| 116 | |
| 117 | switch (ctx.family()) { |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | default: |
| 125 | ctx.visit(K_DATABASE); |
| 126 | break; |
| 127 | } |
| 128 |
nothing calls this directly
no test coverage detected
searching dependent graphs…