Top Description Inners Fields Constructors Methods
liquibase.change

public abstract Class AbstractSQLChange

extends AbstractChange
implements DbmsTargetedChange
Class Inheritance
All Implemented Interfaces
liquibase.change.DbmsTargetedChange
Known Direct Subclasses
liquibase.change.core.RawSQLChange, liquibase.change.core.SQLFileChange
Annotations
@SuppressWarnings:java:S5998
Imports
liquibase.ChecksumVersion, .GlobalConfiguration, .Scope, liquibase.change.core.RawSQLChange, liquibase.changeset.ChangeSetService, .ChangeSetServiceFactory, liquibase.database.Database, liquibase.database.core.Db2zDatabase, .MSSQLDatabase, liquibase.exception.DatabaseException, .UnexpectedLiquibaseException, .ValidationErrors, .Warnings, liquibase.statement.SqlStatement, liquibase.statement.core.RawCompoundStatement, .RawSqlStatement, liquibase.util.BooleanUtil, .StringUtil, java.io.ByteArrayInputStream, .IOException, .InputStream, .PushbackInputStream, java.util.ArrayList, .List

A common parent for all raw SQL related changes regardless of where the sql was sourced from.

Implements the necessary logic to choose how the SQL string should be parsed to generate the statements.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private String
protected String
private String
private Boolean
private Boolean
private boolean
private boolean
splitStatementsSet

Deprecated To be removed when splitStatements is changed to be type Boolean
private String
private boolean
Inherited from liquibase.change.AbstractChange:
NODENAME_COLUMN

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public ChangeStatus
checkStatus(Database database)

Overrides liquibase.change.AbstractChange.checkStatus.

Implements liquibase.change.Change.checkStatus.

Validate that this change executed successfully against the given database.

public CheckSum
generateCheckSum()

Overrides liquibase.change.AbstractChange.generateCheckSum.

Implements liquibase.change.Change.generateCheckSum.

Calculates the checksum based on the contained SQL.

public boolean
generateRollbackStatementsVolatile(Database database)

Overrides liquibase.change.AbstractChange.generateRollbackStatementsVolatile.

Implements liquibase.change.Change.generateRollbackStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateRollbackStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.

public SqlStatement[]
generateStatements(Database database)

Implements liquibase.change.Change.generateStatements.

Generates one or more SqlStatements depending on how the SQL should be parsed.

public boolean
public String
public String
getEndDelimiter()

Set the end delimiter used to split statements.

public String
getSql()

Return the raw SQL managed by this Change

public Boolean
public Boolean
isSplitStatements()

Return if the SQL should be split into multiple statements before passing it to the database.

public boolean
isSplitStatementsSet()
Deprecated To be removed when splitStatements is changed to be Boolean type

public Boolean
isStripComments()

Return if comments should be stripped from the SQL before passing it to the database.

protected String
public InputStream
public void
public void
setEndDelimiter(String
the end delimiter to set
endDelimiter
)

Sets the end delimiter for splitting SQL statements.

public void
setIgnoreOriginalSplitStatements(Boolean ignoreOriginalSplitStatements)
Deprecated

isOriginalSplitStatements is used by checksums v8 calculator only to define splitStatements behavior

public void
setOriginalSplitStatements(Boolean originalSplitStatements)
Deprecated

public void
setSplitStatements(Boolean splitStatements)

Set whether SQL should be split into multiple statements.

public void
setSql(String sql)

Set the raw SQL managed by this Change.

public void
setStripComments(Boolean stripComments)

Return true if comments should be stripped from the SQL before passing it to the database.

public boolean

Returns:

always true (in AbstractSQLChange)
supports
(Database database)

Overrides liquibase.change.AbstractChange.supports.

Implements liquibase.change.Change.supports.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#supports(liquibase.statement.SqlStatement, liquibase.database.Database) method on the SqlStatement objects returned by generateStatements.

public ValidationErrors
validate(Database database)

Overrides liquibase.change.AbstractChange.validate.

Implements liquibase.change.Change.validate.

Implementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to the liquibase.sqlgenerator.SqlGenerator#validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by generateStatements.

public Warnings
Inherited from liquibase.change.AbstractChange:
createChangeMetaDatacreateChangeParameterMetadatacreateDescriptionMetaDatacreateEmptyColumnConfigcreateExampleValueMetaDatacreateInversescreateMustEqualExistingMetaDatacreateRequiredDatabasesMetaDatacreateSerializationTypeMetaDatacreateSinceMetaDatacreateSupportedDatabasesMetaDatacustomLoadLogicequalsfinishInitializationgenerateRollbackStatementsgetAffectedDatabaseObjectsgetChangeSetgetDescriptiongetExcludedFieldFiltersgetResourceAccessorgetSerializableFieldNamespacegetSerializableFieldsgetSerializableFieldTypegetSerializableFieldValuegetSerializedObjectNamegetSerializedObjectNamespacehashCodeisInvalidPropertyloadmodifyserializeserializeValuesetChangeSetsetResourceAccessorshouldExecuteChangesupportsRollbacktoString

Field Detail

dbmsback to summary
private String dbms
encodingback to summary
protected String encoding
endDelimiterback to summary
private String endDelimiter
ignoreOriginalSplitStatementsback to summary
private Boolean ignoreOriginalSplitStatements

Deprecated

Annotations
@Deprecated
originalSplitStatementsback to summary
private Boolean originalSplitStatements

Deprecated

Annotations
@Deprecated
splitStatementsback to summary
private boolean splitStatements
splitStatementsSetback to summary
private boolean splitStatementsSet

Deprecated

To be removed when splitStatements is changed to be type Boolean

sqlback to summary
private String sql
stripCommentsback to summary
private boolean stripComments

Constructor Detail

AbstractSQLChangeback to summary
protected AbstractSQLChange()

Method Detail

checkStatusback to summary
public ChangeStatus checkStatus(Database database)

Overrides liquibase.change.AbstractChange.checkStatus.

Implements liquibase.change.Change.checkStatus.

Doc from liquibase.change.Change.checkStatus.

Validate that this change executed successfully against the given database. This will check that the update completed at a high level plus check details of the change. For example, a change to add a column will check that the column exists plus data type, default values, etc.

Annotations
@Override
generateCheckSumback to summary
public CheckSum generateCheckSum()

Overrides liquibase.change.AbstractChange.generateCheckSum.

Implements liquibase.change.Change.generateCheckSum.

Calculates the checksum based on the contained SQL.

Annotations
@Override
See Also
Change#generateCheckSum()
generateRollbackStatementsVolatileback to summary
public boolean generateRollbackStatementsVolatile(Database database)

Overrides liquibase.change.AbstractChange.generateRollbackStatementsVolatile.

Implements liquibase.change.Change.generateRollbackStatementsVolatile.

Doc from liquibase.change.AbstractChange.generateRollbackStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateRollbackStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.

Annotations
@Override
generateStatementsback to summary
public SqlStatement[] generateStatements(Database database)

Implements liquibase.change.Change.generateStatements.

Generates one or more SqlStatements depending on how the SQL should be parsed. If split statements is set to true then the SQL is split and each command is made into a separate SqlStatement.

If stripping comments is true then any comments are removed before the splitting is executed. The set SQL is passed through the java.sql.Connection#nativeSQL method if a connection is available.
Annotations
@Override
generateStatementsVolatileback to summary
public boolean generateStatementsVolatile(Database database)

Overrides liquibase.change.AbstractChange.generateStatementsVolatile.

Implements liquibase.change.Change.generateStatementsVolatile.

Doc from liquibase.change.AbstractChange.generateStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements. If zero or null SqlStatements are returned by generateStatements then this method returns false.

Annotations
@Override
getDbmsback to summary
public String getDbms()

Implements liquibase.change.DbmsTargetedChange.getDbms.

Returns:String

Doc from liquibase.change.DbmsTargetedChange.getDbms.

A comma separated list of dbms' that this change will be run for. Will run for all dbms' if empty or null.

Annotations
@Override
@DatabaseChangeProperty
since:3.0
exampleValue:h2, oracle
description:Specifies which database type(s) a changeset is to be used for. See valid database type names on Supported Databases docs page. Separate multiple databases with commas. Specify that a changeset is not applicable to a particular database type by prefixing with !. The keywords \'all\' and \'none\' are also available.
getEndDelimiterback to summary
public String getEndDelimiter()

Set the end delimiter used to split statements. Will return null if the default delimiter should be used.

Annotations
@DatabaseChangeProperty
description:Delimiter to apply to the end of the statement. Defaults to \';\', may be set to \'\'.
exampleValue:\\nGO
See Also
splitStatements
getSqlback to summary
public String getSql()

Return the raw SQL managed by this Change

Annotations
@DatabaseChangeProperty
serializationType:DIRECT_VALUE
isIgnoreOriginalSplitStatementsback to summary
public Boolean isIgnoreOriginalSplitStatements()

Deprecated

Annotations
@Deprecated
isSplitStatementsback to summary
public Boolean isSplitStatements()

Return if the SQL should be split into multiple statements before passing it to the database. By default, statements are split around ";" and "go" delimiters.

This will always return a non-null value and should be a boolean rather than a Boolean, but that breaks the Bean Standard.
Annotations
@DatabaseChangeProperty
description:Set to false to not have liquibase split statements on ;\'s and GO\'s. Defaults to true if not set
isSplitStatementsSetback to summary
public boolean isSplitStatementsSet()

Deprecated

To be removed when splitStatements is changed to be Boolean type

Annotations
@Deprecated
isStripCommentsback to summary
public Boolean isStripComments()

Return if comments should be stripped from the SQL before passing it to the database.

This will always return a non-null value and should be a boolean rather than a Boolean, but that breaks the Bean Standard.
Annotations
@DatabaseChangeProperty
description:Set to true to remove any comments in the SQL before executing, otherwise false. Defaults to false if not set
normalizeLineEndingsback to summary
protected String normalizeLineEndings(String string)
openSqlStreamback to summary
public InputStream openSqlStream() throws IOException
setDbmsback to summary
public void setDbms(final String dbms)

Implements liquibase.change.DbmsTargetedChange.setDbms.

Annotations
@Override
setEndDelimiterback to summary
public void setEndDelimiter(String endDelimiter)

Sets the end delimiter for splitting SQL statements. Set to null to use the default delimiter.

Parameters
endDelimiter:String

the end delimiter to set

setIgnoreOriginalSplitStatementsback to summary
public void setIgnoreOriginalSplitStatements(Boolean ignoreOriginalSplitStatements)

Deprecated

isOriginalSplitStatements is used by checksums v8 calculator only to define splitStatements behavior

Annotations
@Deprecated
setOriginalSplitStatementsback to summary
public void setOriginalSplitStatements(Boolean originalSplitStatements)

Deprecated

Annotations
@Deprecated
setSplitStatementsback to summary
public void setSplitStatements(Boolean splitStatements)

Set whether SQL should be split into multiple statements. Passing null sets stripComments to the default value (true).

setSqlback to summary
public void setSql(String sql)

Set the raw SQL managed by this Change. The passed sql is trimmed and set to null if an empty string is passed.

setStripCommentsback to summary
public void setStripComments(Boolean stripComments)

Return true if comments should be stripped from the SQL before passing it to the database. Passing null sets stripComments to the default value (false).

supportsback to summary
public boolean supports(Database database)

Overrides liquibase.change.AbstractChange.supports.

Implements liquibase.change.Change.supports.

Doc from liquibase.change.AbstractChange.supports.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#supports(liquibase.statement.SqlStatement, liquibase.database.Database) method on the SqlStatement objects returned by generateStatements. If no or null SqlStatements are returned by generateStatements then this method returns true. If generateStatementsVolatile(liquibase.database.Database) returns true, we cannot call generateStatements and so assume true.

Returns:boolean

always true (in AbstractSQLChange)

Annotations
@Override
validateback to summary
public ValidationErrors validate(Database database)

Overrides liquibase.change.AbstractChange.validate.

Implements liquibase.change.Change.validate.

Doc from liquibase.change.AbstractChange.validate.

Implementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to the liquibase.sqlgenerator.SqlGenerator#validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by generateStatements. If no or null SqlStatements are returned by generateStatements then this method returns no errors. If there are no parameters than this method returns no errors

Annotations
@Override
warnback to summary
public Warnings warn(Database database)

Overrides liquibase.change.AbstractChange.warn.

Implements liquibase.change.Change.warn.

Doc from liquibase.change.AbstractChange.warn.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by generateStatements. If a generated statement is not supported for the given database, no warning will be added since that is a validation error. If no or null SqlStatements are returned by generateStatements then this method returns no warnings.

Annotations
@Override
liquibase.change back to summary

public Class AbstractSQLChange.NormalizingStream

extends InputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final InputStream

Constructor Summary

AccessConstructor and Description
public
NormalizingStream(String endDelimiter, Boolean splitStatements, Boolean stripComments, InputStream stream)
Deprecated

public

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.

public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

private boolean
isWhiteSpace(int read)

public synchronized void
mark(int
the maximum limit of bytes that can be read before the mark position becomes invalid.
readLimit
)

Overrides java.io.InputStream.mark.

Marks the current position in this input stream.

public boolean
markSupported()

Overrides java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public synchronized void
reset()

Overrides java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

Inherited from java.io.InputStream:
nullInputStreamreadreadreadAllBytesreadNBytesreadNBytesskipskipNBytestransferTo

Field Detail

streamback to summary
private final InputStream stream

Constructor Detail

NormalizingStreamback to summary
public NormalizingStream(String endDelimiter, Boolean splitStatements, Boolean stripComments, InputStream stream)

Deprecated

Annotations
@Deprecated
NormalizingStreamback to summary
public NormalizingStream(InputStream stream)

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
isWhiteSpaceback to summary
private boolean isWhiteSpace(int read)
markback to summary
public synchronized void mark(int readLimit)

Overrides java.io.InputStream.mark.

Doc from java.io.InputStream.mark.

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit arguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

The general contract of mark is that, if the method markSupported returns true, the stream somehow remembers all the bytes read after the call to mark and stands ready to supply those same bytes again if and whenever the method reset is called. However, the stream is not required to remember any data at all if more than readlimit bytes are read from the stream before reset is called.

Marking a closed stream should not have any effect on the stream.

Parameters
readLimit:int

the maximum limit of bytes that can be read before the mark position becomes invalid.

Annotations
@Override
markSupportedback to summary
public boolean markSupported()

Overrides java.io.InputStream.markSupported.

Doc from java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an invariant property of a particular input stream instance.

Returns:boolean

true if this stream instance supports the mark and reset methods; false otherwise.

Annotations
@Override
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
resetback to summary
public synchronized void reset() throws IOException

Overrides java.io.InputStream.reset.

Doc from java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

The general contract of reset is:

  • If the method markSupported returns true, then:
    • If the method mark has not been called since the stream was created, or the number of bytes read from the stream since mark was last called is larger than the argument to mark at that last call, then an IOException might be thrown.
    • If such an IOException is not thrown, then the stream is reset to a state such that all the bytes read since the most recent call to mark (or since the start of the file, if mark has not been called) will be resupplied to subsequent callers of the read method, followed by any bytes that otherwise would have been the next input data as of the time of the call to reset.
  • If the method markSupported returns false, then:
    • The call to reset may throw an IOException.
    • If an IOException is not thrown, then the stream is reset to a fixed state that depends on the particular type of the input stream and how it was created. The bytes that will be supplied to subsequent callers of the read method depend on the particular type of the input stream.
Annotations
@Override
Exceptions
IOException:
if this stream has not been marked or if the mark has been invalidated.