parent
9601267689
commit
0d5034c496
@ -58,7 +58,6 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DropStatementType.TABLE;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_SELECT_INTO_TABLE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -180,9 +179,9 @@ class CreateTableImpl<R extends Record> extends AbstractQuery implements
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifNotExists && !supportsIfNotExists(ctx)) {
|
||||
Utils.executeImmediateBegin(ctx, TABLE);
|
||||
Utils.executeImmediateBegin(ctx, DDLStatementType.CREATE_TABLE);
|
||||
accept0(ctx);
|
||||
Utils.executeImmediateEnd(ctx, TABLE);
|
||||
Utils.executeImmediateEnd(ctx, DDLStatementType.CREATE_TABLE);
|
||||
}
|
||||
else {
|
||||
accept0(ctx);
|
||||
@ -303,7 +302,7 @@ class CreateTableImpl<R extends Record> extends AbstractQuery implements
|
||||
ctx.keyword("table")
|
||||
.sql(' ');
|
||||
|
||||
if (ifNotExists)
|
||||
if (ifNotExists && supportsIfNotExists(ctx))
|
||||
ctx.keyword("if not exists")
|
||||
.sql(' ');
|
||||
|
||||
|
||||
@ -56,7 +56,6 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.DropStatementType.VIEW;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
@ -119,9 +118,9 @@ class CreateViewImpl<R extends Record> extends AbstractQuery implements
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifNotExists && !supportsIfNotExists(ctx)) {
|
||||
Utils.executeImmediateBegin(ctx, VIEW);
|
||||
Utils.executeImmediateBegin(ctx, DDLStatementType.CREATE_VIEW);
|
||||
accept0(ctx);
|
||||
Utils.executeImmediateEnd(ctx, VIEW);
|
||||
Utils.executeImmediateEnd(ctx, DDLStatementType.CREATE_VIEW);
|
||||
}
|
||||
else {
|
||||
accept0(ctx);
|
||||
@ -141,7 +140,7 @@ class CreateViewImpl<R extends Record> extends AbstractQuery implements
|
||||
.keyword("create view")
|
||||
.sql(' ');
|
||||
|
||||
if (ifNotExists)
|
||||
if (ifNotExists && supportsIfNotExists(ctx))
|
||||
ctx.keyword("if not exists")
|
||||
.sql(' ');
|
||||
|
||||
|
||||
@ -43,6 +43,14 @@ package org.jooq.impl;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
enum DropStatementType {
|
||||
INDEX, SEQUENCE, TABLE, VIEW
|
||||
enum DDLStatementType {
|
||||
CREATE_INDEX,
|
||||
CREATE_SEQUENCE,
|
||||
CREATE_TABLE,
|
||||
CREATE_VIEW,
|
||||
|
||||
DROP_INDEX,
|
||||
DROP_SEQUENCE,
|
||||
DROP_TABLE,
|
||||
DROP_VIEW
|
||||
}
|
||||
@ -52,7 +52,6 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.DropStatementType.INDEX;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
@ -122,9 +121,9 @@ class DropIndexImpl extends AbstractQuery implements
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifExists && !supportsIfExists(ctx)) {
|
||||
Utils.executeImmediateBegin(ctx, INDEX);
|
||||
Utils.executeImmediateBegin(ctx, DDLStatementType.DROP_INDEX);
|
||||
accept0(ctx);
|
||||
Utils.executeImmediateEnd(ctx, INDEX);
|
||||
Utils.executeImmediateEnd(ctx, DDLStatementType.DROP_INDEX);
|
||||
}
|
||||
else {
|
||||
accept0(ctx);
|
||||
|
||||
@ -52,7 +52,6 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DropStatementType.SEQUENCE;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
@ -99,9 +98,9 @@ class DropSequenceImpl extends AbstractQuery implements
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifExists && !supportsIfExists(ctx)) {
|
||||
Utils.executeImmediateBegin(ctx, SEQUENCE);
|
||||
Utils.executeImmediateBegin(ctx, DDLStatementType.DROP_SEQUENCE);
|
||||
accept0(ctx);
|
||||
Utils.executeImmediateEnd(ctx, SEQUENCE);
|
||||
Utils.executeImmediateEnd(ctx, DDLStatementType.DROP_SEQUENCE);
|
||||
}
|
||||
else {
|
||||
accept0(ctx);
|
||||
|
||||
@ -50,7 +50,6 @@ import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DropStatementType.TABLE;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
@ -115,9 +114,9 @@ class DropTableImpl extends AbstractQuery implements
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifExists && !supportsIfExists(ctx)) {
|
||||
Utils.executeImmediateBegin(ctx, TABLE);
|
||||
Utils.executeImmediateBegin(ctx, DDLStatementType.DROP_TABLE);
|
||||
accept0(ctx);
|
||||
Utils.executeImmediateEnd(ctx, TABLE);
|
||||
Utils.executeImmediateEnd(ctx, DDLStatementType.DROP_TABLE);
|
||||
}
|
||||
else {
|
||||
accept0(ctx);
|
||||
|
||||
@ -51,7 +51,6 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DropStatementType.VIEW;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
@ -99,9 +98,9 @@ class DropViewImpl extends AbstractQuery implements
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifExists && !supportsIfExists(ctx)) {
|
||||
Utils.executeImmediateBegin(ctx, VIEW);
|
||||
Utils.executeImmediateBegin(ctx, DDLStatementType.DROP_VIEW);
|
||||
accept0(ctx);
|
||||
Utils.executeImmediateEnd(ctx, VIEW);
|
||||
Utils.executeImmediateEnd(ctx, DDLStatementType.DROP_VIEW);
|
||||
}
|
||||
else {
|
||||
accept0(ctx);
|
||||
|
||||
@ -54,6 +54,14 @@ import static org.jooq.conf.ParamType.NAMED_OR_INLINED;
|
||||
import static org.jooq.conf.SettingsTools.getBackslashEscaping;
|
||||
import static org.jooq.conf.SettingsTools.reflectionCaching;
|
||||
import static org.jooq.conf.SettingsTools.updatablePrimaryKeys;
|
||||
import static org.jooq.impl.DDLStatementType.CREATE_INDEX;
|
||||
import static org.jooq.impl.DDLStatementType.CREATE_SEQUENCE;
|
||||
import static org.jooq.impl.DDLStatementType.CREATE_TABLE;
|
||||
import static org.jooq.impl.DDLStatementType.CREATE_VIEW;
|
||||
import static org.jooq.impl.DDLStatementType.DROP_INDEX;
|
||||
import static org.jooq.impl.DDLStatementType.DROP_SEQUENCE;
|
||||
import static org.jooq.impl.DDLStatementType.DROP_TABLE;
|
||||
import static org.jooq.impl.DDLStatementType.DROP_VIEW;
|
||||
import static org.jooq.impl.DSL.concat;
|
||||
import static org.jooq.impl.DSL.escape;
|
||||
import static org.jooq.impl.DSL.getDataType;
|
||||
@ -61,10 +69,6 @@ import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.DefaultExecuteContext.localConnection;
|
||||
import static org.jooq.impl.DropStatementType.INDEX;
|
||||
import static org.jooq.impl.DropStatementType.SEQUENCE;
|
||||
import static org.jooq.impl.DropStatementType.TABLE;
|
||||
import static org.jooq.impl.DropStatementType.VIEW;
|
||||
import static org.jooq.impl.Identifiers.QUOTES;
|
||||
import static org.jooq.impl.Identifiers.QUOTE_END_DELIMITER;
|
||||
import static org.jooq.impl.Identifiers.QUOTE_END_DELIMITER_ESCAPED;
|
||||
@ -2779,7 +2783,7 @@ final class Utils {
|
||||
* <code>IF EXISTS</code> is not supported.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
static final void executeImmediateBegin(Context<?> ctx, DropStatementType type) {
|
||||
static final void executeImmediateBegin(Context<?> ctx, DDLStatementType type) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
@ -2840,7 +2844,7 @@ final class Utils {
|
||||
* <code>BEGIN EXECUTE IMMEDIATE '...' EXCEPTION WHEN ... END;</code>, if
|
||||
* <code>IF EXISTS</code> is not supported.
|
||||
*/
|
||||
static final void executeImmediateEnd(Context<?> ctx, DropStatementType type) {
|
||||
static final void executeImmediateEnd(Context<?> ctx, DDLStatementType type) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
@ -2885,6 +2889,10 @@ final class Utils {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user