[jOOQ/jOOQ#9163] Standardise DROP INDEX
This commit is contained in:
parent
10406c2a1a
commit
8cc0de6194
@ -9787,6 +9787,60 @@ public interface DSLContext extends Scope {
|
||||
@Support({ FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
DropDomainCascadeStep dropDomainIfExists(Domain<?> domain);
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndex(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexOnStep dropIndex(String index);
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndex(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexOnStep dropIndex(Name index);
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndex(Index)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexOnStep dropIndex(Index index);
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndexIfExists(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
DropIndexOnStep dropIndexIfExists(String index);
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndexIfExists(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
DropIndexOnStep dropIndexIfExists(Name index);
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndexIfExists(Index)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
DropIndexOnStep dropIndexIfExists(Index index);
|
||||
|
||||
/**
|
||||
* The <code>DROP SCHEMA</code> statement.
|
||||
*
|
||||
@ -11153,69 +11207,6 @@ public interface DSLContext extends Scope {
|
||||
@Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES })
|
||||
DropTableStep dropTemporaryTableIfExists(Table<?> table);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndex(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexOnStep dropIndex(String index);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndex(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexOnStep dropIndex(Name index);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSL#dropIndex(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexOnStep dropIndex(Index index);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* If your database doesn't natively support <code>IF EXISTS</code>, this is
|
||||
* emulated by catching (and ignoring) the relevant {@link SQLException}.
|
||||
*
|
||||
* @see DSL#dropIndexIfExists(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
DropIndexOnStep dropIndexIfExists(String index);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* If your database doesn't natively support <code>IF EXISTS</code>, this is
|
||||
* emulated by catching (and ignoring) the relevant {@link SQLException}.
|
||||
*
|
||||
* @see DSL#dropIndexIfExists(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
DropIndexOnStep dropIndexIfExists(Name index);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* If your database doesn't natively support <code>IF EXISTS</code>, this is
|
||||
* emulated by catching (and ignoring) the relevant {@link SQLException}.
|
||||
*
|
||||
* @see DSL#dropIndexIfExists(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
DropIndexOnStep dropIndexIfExists(Index index);
|
||||
|
||||
/**
|
||||
* Create a new DSL truncate statement.
|
||||
* <p>
|
||||
|
||||
@ -37,15 +37,14 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
/**
|
||||
* A {@link Query} that can drop indexes.
|
||||
* A step in the construction of the <code>DROP INDEX</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
@ -64,24 +63,21 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface DropIndexCascadeStep extends DropIndexFinalStep {
|
||||
|
||||
/**
|
||||
* Add the <code>CASCADE</code> clause to the <code>DROP INDEX</code>
|
||||
* statement.
|
||||
* Add the <code>CASCADE</code> clause to the <code>DROP INDEX</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES })
|
||||
@NotNull
|
||||
DropIndexFinalStep cascade();
|
||||
|
||||
/**
|
||||
* Add the <code>RESTRICT</code> clause to the <code>DROP INDEX</code>
|
||||
* statement.
|
||||
* Add the <code>RESTRICT</code> clause to the <code>DROP INDEX</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES })
|
||||
@NotNull
|
||||
DropIndexFinalStep restrict();
|
||||
}
|
||||
|
||||
@ -37,9 +37,14 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
/**
|
||||
* A {@link Query} that can drop indexes.
|
||||
* A step in the construction of the <code>DROP INDEX</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
@ -58,9 +63,7 @@ package org.jooq;
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface DropIndexFinalStep extends DDLQuery {
|
||||
|
||||
}
|
||||
|
||||
@ -37,36 +37,14 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* A {@link Query} that can drop indexes.
|
||||
* A step in the construction of the <code>DROP INDEX</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
@ -85,50 +63,43 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface DropIndexOnStep extends DropIndexCascadeStep {
|
||||
|
||||
/**
|
||||
* Specify the table expression on which to drop an index.
|
||||
* Add the <code>ON</code> clause to the <code>DROP INDEX</code> statement.
|
||||
* <p>
|
||||
* {@link SQLDialect#MYSQL}, {@link SQLDialect#MARIADB}, and
|
||||
* {@link SQLDialect#SQLSERVER} use table-scoped index names, not
|
||||
* schema-scoped names. This means that in these databases, the
|
||||
* <code>ON</code> clause is mandatory in order to unambiguously identify an
|
||||
* index. In all other databases, the <code>ON</code> clause will simply be
|
||||
* ignored for compatibility reasons.
|
||||
* {@link SQLDialect#MYSQL}, {@link SQLDialect#MARIADB}, and {@link SQLDialect#SQLSERVER}
|
||||
* use table-scoped index names, not schema-scoped names. This means that in these databases,
|
||||
* the ON clause is mandatory in order to unambiguously identify an index. In all other
|
||||
* databases, the ON clause will simply be ignored for compatibility reasons.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexCascadeStep on(Table<?> table);
|
||||
@NotNull
|
||||
DropIndexCascadeStep on(String on);
|
||||
|
||||
/**
|
||||
* Specify the table expression on which to drop an index.
|
||||
* Add the <code>ON</code> clause to the <code>DROP INDEX</code> statement.
|
||||
* <p>
|
||||
* {@link SQLDialect#MYSQL}, {@link SQLDialect#MARIADB}, and
|
||||
* {@link SQLDialect#SQLSERVER} use table-scoped index names, not
|
||||
* schema-scoped names. This means that in these databases, the
|
||||
* <code>ON</code> clause is mandatory in order to unambiguously identify an
|
||||
* index. In all other databases, the <code>ON</code> clause will simply be
|
||||
* ignored for compatibility reasons.
|
||||
* {@link SQLDialect#MYSQL}, {@link SQLDialect#MARIADB}, and {@link SQLDialect#SQLSERVER}
|
||||
* use table-scoped index names, not schema-scoped names. This means that in these databases,
|
||||
* the ON clause is mandatory in order to unambiguously identify an index. In all other
|
||||
* databases, the ON clause will simply be ignored for compatibility reasons.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexCascadeStep on(String tableName);
|
||||
@NotNull
|
||||
DropIndexCascadeStep on(Name on);
|
||||
|
||||
/**
|
||||
* Specify the table expression on which to drop an index.
|
||||
* Add the <code>ON</code> clause to the <code>DROP INDEX</code> statement.
|
||||
* <p>
|
||||
* {@link SQLDialect#MYSQL}, {@link SQLDialect#MARIADB}, and
|
||||
* {@link SQLDialect#SQLSERVER} use table-scoped index names, not
|
||||
* schema-scoped names. This means that in these databases, the
|
||||
* <code>ON</code> clause is mandatory in order to unambiguously identify an
|
||||
* index. In all other databases, the <code>ON</code> clause will simply be
|
||||
* ignored for compatibility reasons.
|
||||
* {@link SQLDialect#MYSQL}, {@link SQLDialect#MARIADB}, and {@link SQLDialect#SQLSERVER}
|
||||
* use table-scoped index names, not schema-scoped names. This means that in these databases,
|
||||
* the ON clause is mandatory in order to unambiguously identify an index. In all other
|
||||
* databases, the ON clause will simply be ignored for compatibility reasons.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
DropIndexCascadeStep on(Name tableName);
|
||||
@NotNull
|
||||
DropIndexCascadeStep on(Table<?> on);
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ implements
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final AlterIndexImpl on(String on) {
|
||||
return on(DSL.table(DSL.name(on)));
|
||||
|
||||
@ -7799,6 +7799,72 @@ public class DSL {
|
||||
return dsl().dropDomainIfExists(domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndex(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static org.jooq.DropIndexOnStep dropIndex(String index) {
|
||||
return dsl().dropIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndex(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static org.jooq.DropIndexOnStep dropIndex(Name index) {
|
||||
return dsl().dropIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndex(Index)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static org.jooq.DropIndexOnStep dropIndex(Index index) {
|
||||
return dsl().dropIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndexIfExists(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
public static org.jooq.DropIndexOnStep dropIndexIfExists(String index) {
|
||||
return dsl().dropIndexIfExists(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndexIfExists(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
public static org.jooq.DropIndexOnStep dropIndexIfExists(Name index) {
|
||||
return dsl().dropIndexIfExists(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP INDEX IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndexIfExists(Index)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
public static org.jooq.DropIndexOnStep dropIndexIfExists(Index index) {
|
||||
return dsl().dropIndexIfExists(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP SCHEMA</code> statement.
|
||||
*
|
||||
@ -9232,81 +9298,6 @@ public class DSL {
|
||||
return dsl().dropTableIfExists(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndex(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static DropIndexOnStep dropIndex(String index) {
|
||||
return dsl().dropIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndex(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static DropIndexOnStep dropIndex(Name index) {
|
||||
return dsl().dropIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX</code> statement.
|
||||
*
|
||||
* @see DSLContext#dropIndex(Index)
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static DropIndexOnStep dropIndex(Index index) {
|
||||
return dsl().dropIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* If your database doesn't natively support <code>IF EXISTS</code>, this is
|
||||
* emulated by catching (and ignoring) the relevant {@link SQLException}.
|
||||
*
|
||||
* @see DSLContext#dropIndexIfExists(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
public static DropIndexOnStep dropIndexIfExists(String index) {
|
||||
return dsl().dropIndexIfExists(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* If your database doesn't natively support <code>IF EXISTS</code>, this is
|
||||
* emulated by catching (and ignoring) the relevant {@link SQLException}.
|
||||
*
|
||||
* @see DSLContext#dropIndexIfExists(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
public static DropIndexOnStep dropIndexIfExists(Name index) {
|
||||
return dsl().dropIndexIfExists(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP INDEX IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* If your database doesn't natively support <code>IF EXISTS</code>, this is
|
||||
* emulated by catching (and ignoring) the relevant {@link SQLException}.
|
||||
*
|
||||
* @see DSLContext#dropIndexIfExists(Index)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, SQLITE })
|
||||
public static DropIndexOnStep dropIndexIfExists(Index index) {
|
||||
return dsl().dropIndexIfExists(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL truncate statement.
|
||||
* <p>
|
||||
|
||||
@ -3056,6 +3056,36 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
return new DropDomainImpl(configuration(), domain, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropIndexOnStep dropIndex(String index) {
|
||||
return new DropIndexImpl(configuration(), DSL.index(DSL.name(index)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropIndexOnStep dropIndex(Name index) {
|
||||
return new DropIndexImpl(configuration(), DSL.index(index), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropIndexOnStep dropIndex(Index index) {
|
||||
return new DropIndexImpl(configuration(), index, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropIndexOnStep dropIndexIfExists(String index) {
|
||||
return new DropIndexImpl(configuration(), DSL.index(DSL.name(index)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropIndexOnStep dropIndexIfExists(Name index) {
|
||||
return new DropIndexImpl(configuration(), DSL.index(index), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropIndexOnStep dropIndexIfExists(Index index) {
|
||||
return new DropIndexImpl(configuration(), index, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropSchemaStep dropSchema(String schema) {
|
||||
return new DropSchemaImpl(configuration(), DSL.schema(DSL.name(schema)), false);
|
||||
@ -3777,36 +3807,6 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
return new DropTableImpl(configuration(), table, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropIndexOnStep dropIndex(String index) {
|
||||
return dropIndex(name(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropIndexOnStep dropIndex(Name index) {
|
||||
return dropIndex(index(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropIndexOnStep dropIndex(Index index) {
|
||||
return new DropIndexImpl(configuration(), index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropIndexOnStep dropIndexIfExists(String index) {
|
||||
return dropIndexIfExists(name(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropIndexOnStep dropIndexIfExists(Name index) {
|
||||
return dropIndexIfExists(index(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropIndexOnStep dropIndexIfExists(Index index) {
|
||||
return new DropIndexImpl(configuration(), index, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TruncateIdentityStep<Record> truncate(String table) {
|
||||
return truncateTable(table);
|
||||
|
||||
@ -37,115 +37,117 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.DROP_INDEX;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Keywords.K_CASCADE;
|
||||
import static org.jooq.impl.Keywords.K_DROP_INDEX;
|
||||
import static org.jooq.impl.Keywords.K_IF_EXISTS;
|
||||
import static org.jooq.impl.Keywords.K_ON;
|
||||
import static org.jooq.impl.Keywords.K_RESTRICT;
|
||||
import static org.jooq.impl.Tools.beginTryCatch;
|
||||
import static org.jooq.impl.Tools.endTryCatch;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.Set;
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DropIndexOnStep;
|
||||
import org.jooq.Index;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Table;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>DROP INDEX</code> statement.
|
||||
*/
|
||||
final class DropIndexImpl extends AbstractRowCountQuery implements
|
||||
@SuppressWarnings({ "hiding", "rawtypes", "unused" })
|
||||
final class DropIndexImpl
|
||||
extends
|
||||
AbstractRowCountQuery
|
||||
implements
|
||||
DropIndexOnStep,
|
||||
DropIndexCascadeStep,
|
||||
DropIndexFinalStep
|
||||
{
|
||||
|
||||
// Cascading interface implementations for DROP INDEX behaviour
|
||||
DropIndexOnStep {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 8904572826501186329L;
|
||||
private static final Clause[] CLAUSES = { DROP_INDEX };
|
||||
private static final Set<SQLDialect> NO_SUPPORT_IF_EXISTS = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD);
|
||||
private static final Set<SQLDialect> REQUIRES_ON = SQLDialect.supportedBy(MARIADB, MYSQL);
|
||||
private final Index index;
|
||||
private final boolean dropIndexIfExists;
|
||||
private Table<?> on;
|
||||
private Boolean cascade;
|
||||
|
||||
private final Index index;
|
||||
private final boolean ifExists;
|
||||
private Table<?> on;
|
||||
private Boolean cascade;
|
||||
|
||||
DropIndexImpl(Configuration configuration, Index index) {
|
||||
this(configuration, index, false);
|
||||
DropIndexImpl(
|
||||
Configuration configuration,
|
||||
Index index,
|
||||
boolean dropIndexIfExists
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
index,
|
||||
dropIndexIfExists,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
DropIndexImpl(Configuration configuration, Index index, boolean ifExists) {
|
||||
DropIndexImpl(
|
||||
Configuration configuration,
|
||||
Index index,
|
||||
boolean dropIndexIfExists,
|
||||
Table<?> on,
|
||||
Boolean cascade
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.index = index;
|
||||
this.ifExists = ifExists;
|
||||
this.on = index.getTable();
|
||||
this.dropIndexIfExists = dropIndexIfExists;
|
||||
this.on = on;
|
||||
this.cascade = cascade;
|
||||
}
|
||||
|
||||
final Index $index() { return index; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final Table<?> $on() { return on; }
|
||||
final Index $index() { return index; }
|
||||
final boolean $dropIndexIfExists() { return dropIndexIfExists; }
|
||||
final Table<?> $on() { return on; }
|
||||
final Boolean $cascade() { return cascade; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: DropIndex API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final DropIndexImpl on(Table<?> table) {
|
||||
this.on = table;
|
||||
public final DropIndexImpl on(String on) {
|
||||
return on(DSL.table(DSL.name(on)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DropIndexImpl on(Name on) {
|
||||
return on(DSL.table(on));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DropIndexImpl on(Table<?> on) {
|
||||
this.on = on;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DropIndexImpl on(String tableName) {
|
||||
return on(name(tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DropIndexImpl on(Name tableName) {
|
||||
return on(table(tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DropIndexImpl cascade() {
|
||||
cascade = true;
|
||||
this.cascade = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DropIndexImpl restrict() {
|
||||
cascade = false;
|
||||
this.cascade = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES = { Clause.DROP_INDEX };
|
||||
private static final Set<SQLDialect> NO_SUPPORT_IF_EXISTS = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD);
|
||||
private static final Set<SQLDialect> REQUIRES_ON = SQLDialect.supportedBy(MARIADB, MYSQL);
|
||||
|
||||
private final boolean supportsIfExists(Context<?> ctx) {
|
||||
return !NO_SUPPORT_IF_EXISTS.contains(ctx.dialect());
|
||||
@ -153,20 +155,19 @@ final class DropIndexImpl extends AbstractRowCountQuery implements
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifExists && !supportsIfExists(ctx)) {
|
||||
if (dropIndexIfExists && !supportsIfExists(ctx)) {
|
||||
beginTryCatch(ctx, DDLStatementType.DROP_INDEX);
|
||||
accept0(ctx);
|
||||
endTryCatch(ctx, DDLStatementType.DROP_INDEX);
|
||||
}
|
||||
else {
|
||||
else
|
||||
accept0(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
private void accept0(Context<?> ctx) {
|
||||
ctx.visit(K_DROP_INDEX).sql(' ');
|
||||
|
||||
if (ifExists && supportsIfExists(ctx))
|
||||
if (dropIndexIfExists && supportsIfExists(ctx))
|
||||
ctx.visit(K_IF_EXISTS).sql(' ');
|
||||
|
||||
|
||||
@ -187,4 +188,6 @@ final class DropIndexImpl extends AbstractRowCountQuery implements
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user