[jOOQ/jOOQ#9019] Render DROP TEMPORARY TABLE in MySQL

This commit is contained in:
Lukas Eder 2019-09-19 12:19:26 +02:00
parent e2901b626f
commit 1651ecb6a5
3 changed files with 21 additions and 11 deletions

View File

@ -9674,7 +9674,7 @@ public interface DSLContext extends Scope , AutoCloseable {
*
* @see DSL#dropTemporaryTable(String)
*/
@Support
@Support({ MARIADB, MYSQL, POSTGRES })
DropTableStep dropTemporaryTable(String table);
/**
@ -9682,7 +9682,7 @@ public interface DSLContext extends Scope , AutoCloseable {
*
* @see DSL#dropTemporaryTable(Name)
*/
@Support
@Support({ MARIADB, MYSQL, POSTGRES })
DropTableStep dropTemporaryTable(Name table);
/**
@ -9690,7 +9690,7 @@ public interface DSLContext extends Scope , AutoCloseable {
*
* @see DSL#dropTemporaryTable(Table)
*/
@Support
@Support({ MARIADB, MYSQL, POSTGRES })
DropTableStep dropTemporaryTable(Table<?> table);
/**

View File

@ -3528,17 +3528,17 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
@Override
public DropTableStep dropTemporaryTable(String table) {
return dropTable(name(table));
return dropTemporaryTable(name(table));
}
@Override
public DropTableStep dropTemporaryTable(Name table) {
return dropTable(table(table));
return dropTemporaryTable(table(table));
}
@Override
public DropTableStep dropTemporaryTable(Table<?> table) {
return new DropTableImpl(configuration(), table);
return new DropTableImpl(configuration(), table, false, true);
}
@Override

View File

@ -42,14 +42,19 @@ import static org.jooq.Clause.DROP_TABLE_TABLE;
// ...
// ...
// ...
// ...
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.FIREBIRD;
import static org.jooq.SQLDialect.MYSQL;
// ...
// ...
// ...
import static org.jooq.impl.Keywords.K_CASCADE;
import static org.jooq.impl.Keywords.K_DROP;
import static org.jooq.impl.Keywords.K_DROP_TABLE;
import static org.jooq.impl.Keywords.K_IF_EXISTS;
import static org.jooq.impl.Keywords.K_TABLE;
import static org.jooq.impl.Keywords.K_TEMPORARY;
import java.util.EnumSet;
@ -75,6 +80,7 @@ final class DropTableImpl extends AbstractRowCountQuery implements
private static final long serialVersionUID = 8904572826501186329L;
private static final Clause[] CLAUSES = { DROP_TABLE };
private static final EnumSet<SQLDialect> NO_SUPPORT_IF_EXISTS = EnumSet.of(DERBY, FIREBIRD);
private static final EnumSet<SQLDialect> TEMPORARY_SEMANTIC = EnumSet.of(MYSQL);
private final Table<?> table;
private final boolean temporary;
@ -137,12 +143,16 @@ final class DropTableImpl extends AbstractRowCountQuery implements
}
private void accept0(Context<?> ctx) {
ctx.start(DROP_TABLE_TABLE)
.visit(K_DROP_TABLE).sql(' ');
ctx.start(DROP_TABLE_TABLE);
// [#6371] [#9019] While many dialects do not require this keyword, in
// some dialects (e.g. MySQL), there is a semantic
// difference, e.g. with respect to transactions.
if (temporary && TEMPORARY_SEMANTIC.contains(ctx.family()))
ctx.visit(K_DROP).sql(' ').visit(K_TEMPORARY).sql(' ').visit(K_TABLE).sql(' ');
else
ctx.visit(K_DROP_TABLE).sql(' ');
// [#6371] The keyword isn't strictly required in any dialect we've seen so far.
if (temporary)
;
if (ifExists && supportsIfExists(ctx))
ctx.visit(K_IF_EXISTS).sql(' ');