HHH-18296 call set client_min_messages = WARNING before dropping tables on Postgres
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
ea468e774b
commit
ad55fd0010
|
@ -2373,6 +2373,15 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A command to execute before dropping tables.
|
||||
*
|
||||
* @return A SQL statement, or {@code null}
|
||||
*/
|
||||
public String getBeforeDropStatement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The command used to drop a table with the given name, usually
|
||||
* {@code drop table tab_name}.
|
||||
|
@ -2380,7 +2389,12 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
|
|||
* @param tableName The name of the table to drop
|
||||
*
|
||||
* @return The {@code drop table} statement as a string
|
||||
*
|
||||
* @deprecated No longer used
|
||||
*
|
||||
* @see StandardTableExporter#getSqlDropStrings
|
||||
*/
|
||||
@Deprecated(since = "6.6")
|
||||
public String getDropTableString(String tableName) {
|
||||
final StringBuilder buf = new StringBuilder( "drop table " );
|
||||
if ( supportsIfExistsBeforeTableName() ) {
|
||||
|
|
|
@ -783,6 +783,14 @@ public class PostgreSQLDialect extends Dialect {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBeforeDropStatement() {
|
||||
// by default, the Postgres driver reports
|
||||
// NOTICE: table "nonexistent" does not exist, skipping
|
||||
// as a JDBC SQLWarning
|
||||
return "set client_min_messages = WARNING";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlterColumnTypeString(String columnName, String columnType, String columnDefinition) {
|
||||
// would need multiple statements to 'set not null'/'drop not null', 'set default'/'drop default', 'set generated', etc
|
||||
|
|
|
@ -63,6 +63,7 @@ import org.jboss.logging.Logger;
|
|||
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.setOfSize;
|
||||
import static org.hibernate.tool.schema.internal.Helper.applyScript;
|
||||
import static org.hibernate.tool.schema.internal.Helper.applySqlString;
|
||||
import static org.hibernate.tool.schema.internal.Helper.applySqlStrings;
|
||||
import static org.hibernate.tool.schema.internal.Helper.createSqlStringGenerationContext;
|
||||
import static org.hibernate.tool.schema.internal.Helper.interpretFormattingEnabled;
|
||||
|
@ -209,6 +210,8 @@ public class SchemaDropperImpl implements SchemaDropper {
|
|||
|
||||
// NOTE : init commands are irrelevant for dropping...
|
||||
|
||||
applySqlString( dialect.getBeforeDropStatement(), formatter, options, targets );
|
||||
|
||||
final SqlStringGenerationContext context = createSqlStringGenerationContext( options, metadata );
|
||||
// Reverse the list on drop to retain possible dependencies
|
||||
dropAuxiliaryObjectsBeforeTables( metadata, options, dialect, formatter, context, targets );
|
||||
|
|
Loading…
Reference in New Issue