Skip to content

Commit

Permalink
Merge branch '3.4.x'
Browse files Browse the repository at this point in the history
Conflicts:
	liquibase-cdi/pom.xml
	liquibase-core/pom.xml
	liquibase-core/src/test/java/liquibase/change/ChangeFactoryTest.java
	liquibase-debian/pom.xml
	liquibase-integration-tests/pom.xml
	liquibase-maven-plugin/pom.xml
	liquibase-osgi/pom.xml
	liquibase-rpm/pom.xml
	pom.xml
  • Loading branch information
nvoxland committed Nov 24, 2015
2 parents eb5c24e + b03a618 commit c777ea1
Show file tree
Hide file tree
Showing 44 changed files with 396 additions and 141 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ derby.log
.DS_Store
/tmp
/.metadata/

atlassian-ide-plugin.xml
_issues
47 changes: 45 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
Liquibase Core Changelog
===========================================

Changes in version 3.4.2 (2015.11.24)

- [CORE-2328] - AbstractExecutor should implement execute(Change)
- [CORE-2475] - Informix: Insert valueComputed not used correctly
- [CORE-2543] - Improved support for time stamps in oracle insert change data types
- [CORE-1778] - createSequence doesn't work on MSSQL
- [CORE-1840] - Liquibase fails when run on a computer that can't connect to the internet
- [CORE-2273] - Oracle char column snapshot not differentiating between a default value of 0 and '0'
- [CORE-2285] - Code in Liquibase class inconsistent
- [CORE-2317] - Custom ConfigurationValueProvider not working
- [CORE-2349] - loadUpdateData does not escape column names in "ON DUPLICATE" clause
- [CORE-2407] - Derby keywords not escaped when used as column/table names
- [CORE-2447] - In sybase, schema is bad preixed
- [CORE-2466] - Rollback referencing a change set in another file cannot be parsed
- [CORE-2467] - SSO with jtds MSSQL doesn't work after 3.3.5 for update - null user error
- [CORE-2469] - Error in method ColumnConfig.setValueNumeric(String)
- [CORE-2470] - MSSQL: FindForeignKeyConstraintsGeneratorMSSQL doesn't honor specified schema
- [CORE-2480] - Primary key exist works fine with 3.3.3 not with 3.4.0 in SQL SERVER
- [CORE-2481] - Primary key creation issue with informix
- [CORE-2482] - Number type issue with informix
- [CORE-2484] - dropAll command crashes because it drops sequences before tables
- [CORE-2487] - updateSql does not output anything for prepared statements
- [CORE-2490] - If you have more than one :name token in the where clause of a delete change, you get an Exception
- [CORE-2491] - Shouldn't a custom change produce a warning if run in updateSql mode
- [CORE-2492] - Logger extension liquibase-slf4j no longer usable with 3.4.1
- [CORE-2494] - Pgsql: Exporting/generating badly formatted SQL
- [CORE-2498] - Generation of TIMESTAMP(29) causing error in PSQL log TIMESTAMP(6) WITHOUT TIME ZONE
- [CORE-2500] - Fast check of ColumnExistsPrecondition causing transaction abort on PostgreSQL database
- [CORE-2505] - Missing keywords for H2 database
- [CORE-2510] - loadData on MySQL with > 50 rows fails
- [CORE-2544] - LogFactory does not get reset
- [CORE-2549] - Performance regression in resolving local host
- [CORE-2554] - updateSql command fails on validation when upgrading (2.0.5 ->3.4.1)
- [CORE-2566] - Maven - setting skip= true does not work
- [CORE-2571] - primaryKeyExists precondition generating wrong query
- [CORE-2576] - The 'dbms' attribute on <createProcedure> is not not taken into account when parsing changes
- [CORE-2579] - dropAll failed for Oracle 12c
- [CORE-2580] - Escape column, table and schema on ColumnExistsPrecondition
- [CORE-2588] - Bad cast
- [CORE-2590] - Default constraint names are not quoted
- [CORE-2596] - DatabaseChangeLogLock race condition exists if two nodes both try to create the table
- [CORE-2598] - Postgres generateChangeLog: "length for type varchar cannot exceed 10485760"

Changes in version 3.4.1 (2015.07.28)

- [CORE-998] - Changing index columns leads to wrong output order in the change log xml file.
Expand Down Expand Up @@ -811,8 +854,8 @@ Changes in version 3.0.3 (2013.08.29)
- [CORE-1375] - "group" is not included as a reserved word
- [CORE-1377] - liquibase version says 3.0.0-SNP
- [CORE-1380] - ^M present in liquibase unix running file (from jar on maven repo)
- - - - [CORE-1381] - DropAll: Not working with MsSql
- [CORE-1383] - Error attempting to re-create databasechangeloglock on second liquibase run if running in Oracle under SYSTEM user
- - - - - [CORE-1381] - DropAll: Not working with MsSql
- - [CORE-1383] - Error attempting to re-create databasechangeloglock on second liquibase run if running in Oracle under SYSTEM user
- [CORE-1387] - dropAll fails with oracle since version 3.0.2
- [CORE-1388] - MSSQLServer: 'REAL' dataype is returned with unnecessary size modifier during generateChangeLog
- [CORE-1389] - AddLookupTable fails when using QUOTE_ALL_OBJECTS
Expand Down
4 changes: 3 additions & 1 deletion liquibase-core/src/main/java/liquibase/Liquibase.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ public Liquibase(DatabaseChangeLog changeLog, ResourceAccessor resourceAccessor,
log = LogFactory.getLogger();
this.databaseChangeLog = changeLog;

this.changeLogFile = changeLog.getPhysicalFilePath();
if (changeLog != null) {
this.changeLogFile = changeLog.getPhysicalFilePath();
}
if (this.changeLogFile != null) {
changeLogFile = changeLogFile.replace('\\', '/'); //convert to standard / if using absolute path on windows
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,11 @@ public ValidationErrors validate(Database database) {
return changeValidationErrors;
}

String unsupportedWarning = ChangeFactory.getInstance().getChangeMetaData(this).getName() + " is not supported on " + database.getShortName();
if (!this.supports(database)) {
changeValidationErrors.addError(unsupportedWarning);
} else if (!generateStatementsVolatile(database)) {
boolean sawUnsupportedError = false;
SqlStatement[] statements;
statements = generateStatements(database);
if (!generateStatementsVolatile(database)) {
String unsupportedWarning = ChangeFactory.getInstance().getChangeMetaData(this).getName() + " is not supported on " + database.getShortName();
boolean sawUnsupportedError = false;

SqlStatement[] statements = generateStatements(database);
if (statements != null) {
for (SqlStatement statement : statements) {
boolean supported = SqlGeneratorFactory.getInstance().supports(statement, database);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public int compare(Class<? extends Change> o1, Class<? extends Change> o2) {
registry.get(name).add(changeClass);
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
}
}

public ChangeMetaData getChangeMetaData(String change) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public ColumnConfig setValueNumeric(String valueNumeric) {
if (valueNumeric == null || valueNumeric.equalsIgnoreCase("null")) {
this.valueNumeric = null;
} else {
String saved = new String(valueNumeric);
if (valueNumeric.startsWith("(")) {
valueNumeric = valueNumeric.replaceFirst("^\\(", "");
valueNumeric = valueNumeric.replaceFirst("\\)$", "");
Expand All @@ -234,7 +235,7 @@ public ColumnConfig setValueNumeric(String valueNumeric) {
try {
this.valueNumeric = ValueNumeric.of(Locale.US, valueNumeric);
} catch (ParseException e) {
this.valueComputed = new DatabaseFunction(valueNumeric);
this.valueComputed = new DatabaseFunction(saved);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import liquibase.change.*;
import liquibase.database.Database;
import liquibase.database.DatabaseList;
import liquibase.database.core.HsqlDatabase;
import liquibase.database.core.MSSQLDatabase;
import liquibase.database.core.OracleDatabase;
Expand Down Expand Up @@ -167,7 +168,7 @@ public ValidationErrors validate(Database database) {
validate.addError("Cannot specify either 'path' or a nested procedure text in "+ChangeFactory.getInstance().getChangeMetaData(this).getName());
}

if (this.getReplaceIfExists() != null) {
if (this.getReplaceIfExists() != null && (DatabaseList.definitionMatches(getDbms(), database, true))) {
if (database instanceof MSSQLDatabase) {
if (this.getReplaceIfExists() && this.getProcedureName() == null) {
validate.addError("procedureName is required if replaceIfExists = true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import liquibase.change.*;
import liquibase.database.Database;
import liquibase.database.core.InformixDatabase;
import liquibase.exception.DatabaseException;
import liquibase.exception.ValidationErrors;
import liquibase.snapshot.InvalidExampleException;
import liquibase.snapshot.SnapshotGeneratorFactory;
import liquibase.statement.InsertExecutablePreparedStatement;
import liquibase.statement.SqlStatement;
import liquibase.statement.core.InsertStatement;
import liquibase.structure.core.Column;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -92,9 +96,17 @@ public SqlStatement[] generateStatements(Database database) {
if (column.getValueClobFile() != null) {
needsPreparedStatement = true;
}
// TODO: This could be changed to check the column data types to see if we need the prepared statement
if (/*column.getValueText() != null &&*/ database instanceof InformixDatabase) {
needsPreparedStatement = true;

if (!needsPreparedStatement && database instanceof InformixDatabase) {
if (column.getValue() != null) {
try {
Column snapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(new Column(column), database);
if (snapshot != null) {
needsPreparedStatement = true;
}
} catch (Exception ignore) { //assume it's not a clob
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,11 @@ public ExecType execute(DatabaseChangeLog databaseChangeLog, ChangeExecListener
if (listener != null) {
listener.willRun(change, this, changeLog, database);
}
if (change.generateStatementsVolatile(database)) {
executor.comment("WARNING The following SQL is possibly incorrect, invalid, and/or may change on each run:");
}


database.executeStatements(change, databaseChangeLog, sqlVisitors);
log.info(change.getConfirmationMessage());
if (listener != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import liquibase.statement.core.UpdateChangeSetChecksumStatement;
import liquibase.util.ISODateFormat;
import liquibase.util.LiquibaseUtil;
import liquibase.util.StringUtils;
import liquibase.util.csv.CSVReader;
import liquibase.util.csv.CSVWriter;

Expand Down Expand Up @@ -160,6 +161,11 @@ public List<RanChangeSet> getRanChangeSets() throws DatabaseException {
reader = new FileReader(this.changeLogFile);
CSVReader csvReader = new CSVReader(reader);
String[] line = csvReader.readNext();

if (line == null) { //empty file
writeHeader(this.changeLogFile);
return new ArrayList<RanChangeSet>();
}
if (!line[COLUMN_ID].equals("ID")) {
throw new DatabaseException("Missing header in file "+this.changeLogFile.getAbsolutePath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class StandardChangeLogHistoryService extends AbstractChangeLogHistorySer
private List<RanChangeSet> ranChangeSetList;
private boolean serviceInitialized = false;
private Boolean hasDatabaseChangeLogTable = null;
private boolean databaseChecksumsCompatible = true;
private Integer lastChangeSetSequenceValue;

@Override
Expand Down Expand Up @@ -189,6 +190,7 @@ public void init() throws DatabaseException {
String md5sum = md5sumRS.get(0).get("MD5SUM").toString();
if (!md5sum.startsWith(CheckSum.getCurrentVersion() + ":")) {
executor.comment("DatabaseChangeLog checksums are an incompatible version. Setting them to null so they will be updated on next database update");
databaseChecksumsCompatible = false;
statementsToExecute.add(new RawSqlStatement(
"UPDATE " + getDatabase().escapeTableName(getLiquibaseCatalogName(), getLiquibaseSchemaName(), getDatabaseChangeLogTableName()) + " " +
"SET " + getDatabase().escapeObjectName("MD5SUM", Column.class) + " = NULL"));
Expand Down Expand Up @@ -240,7 +242,7 @@ public List<RanChangeSet> getRanChangeSets() throws DatabaseException {
String fileName = rs.get("FILENAME").toString();
String author = rs.get("AUTHOR").toString();
String id = rs.get("ID").toString();
String md5sum = rs.get("MD5SUM") == null ? null : rs.get("MD5SUM").toString();
String md5sum = rs.get("MD5SUM") == null || !databaseChecksumsCompatible ? null : rs.get("MD5SUM").toString();
String description = rs.get("DESCRIPTION") == null ? null : rs.get("DESCRIPTION").toString();
String comments = rs.get("COMMENTS") == null ? null : rs.get("COMMENTS").toString();
Object tmpDateExecuted = rs.get("DATEEXECUTED");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ConfigurationProperty getProperty(Class<? extends ConfigurationContainer>
protected <T extends ConfigurationContainer> T createConfiguration(Class<T> type) {
try {
T configuration = type.newInstance();
configuration.init(new SystemPropertyProvider());
configuration.init(configurationValueProviders);
return configuration;
} catch (Exception e) {
throw new UnexpectedLiquibaseException("Cannot create default configuration "+type.getName(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ protected boolean isDateOnly(final String isoDate) {
protected boolean isDateTime(final String isoDate) {
return isoDate.length() >= "yyyy-MM-ddThh:mm:ss".length();
}

protected boolean isTimestamp(final String isoDate) {
return isoDate.length() >= "yyyy-MM-ddThh:mm:ss.SSS".length();
}

protected boolean isTimeOnly(final String isoDate) {
return isoDate.length() == "hh:mm:ss".length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import liquibase.logging.Logger;

import java.sql.Driver;
import java.util.Arrays;
import java.util.Enumeration;

public class DerbyDatabase extends AbstractJdbcDatabase {
Expand All @@ -35,6 +36,8 @@ public DerbyDatabase() {
super.sequenceNextValueFunction = "NEXT VALUE FOR %s";
super.sequenceCurrentValueFunction = "(SELECT currentvalue FROM sys.syssequences WHERE sequencename = upper('%s'))";
determineDriverVersion();
//add reserved words from http://developer.mimer.com/validator/sql-reserved-words.tml
this.addReservedWords(Arrays.asList("ABSOLUTE", "ACTION", "ADD", "AFTER", "ALL", "ALLOCATE", "ALTER", "AND", "ANY", "ARE", "ARRAY", "AS", "ASC", "ASENSITIVE", "ASSERTION", "ASYMMETRIC", "AT", "ATOMIC", "AUTHORIZATION", "AVG", "BEFORE", "BEGIN", "BETWEEN", "BIGINT", "BINARY", "BIT", "BIT_LENGTH", "BLOB", "BOOLEAN", "BOTH", "BREADTH", "BY", "CALL", "CALLED", "CASCADE", "CASCADED", "CASE", "CAST", "CATALOG", "CHAR", "CHARACTER", "CHARACTER_LENGTH", "CHAR_LENGTH", "CHECK", "CLOB", "CLOSE", "COALESCE", "COLLATE", "COLLATION", "COLUMN", "COMMIT", "CONDITION", "CONNECT", "CONNECTION", "CONSTRAINT", "CONSTRAINTS", "CONSTRUCTOR", "CONTAINS", "CONTINUE", "CONVERT", "CORRESPONDING", "COUNT", "CREATE", "CROSS", "CUBE", "CURRENT", "CURRENT_DATE", "CURRENT_DEFAULT_TRANSFORM_GROUP", "CURRENT_PATH", "CURRENT_ROLE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_TRANSFORM_GROUP_FOR_TYPE", "CURRENT_USER", "CURSOR", "CYCLE", "DATA", "DATE", "DAY", "DEALLOCATE", "DEC", "DECIMAL", "DECLARE", "DEFAULT", "DEFERRABLE", "DEFERRED", "DELETE", "DEPTH", "DEREF", "DESC", "DESCRIBE", "DESCRIPTOR", "DETERMINISTIC", "DIAGNOSTICS", "DISCONNECT", "DISTINCT", "DO", "DOMAIN", "DOUBLE", "DROP", "DYNAMIC", "EACH", "ELEMENT", "ELSE", "ELSEIF", "END", "EQUALS", "ESCAPE", "EXCEPT", "EXCEPTION", "EXEC", "EXECUTE", "EXISTS", "EXIT", "EXTERNAL", "EXTRACT", "FALSE", "FETCH", "FILTER", "FIRST", "FLOAT", "FOR", "FOREIGN", "FOUND", "FREE", "FROM", "FULL", "FUNCTION", "GENERAL", "GET", "GLOBAL", "GO", "GOTO", "GRANT", "GROUP", "GROUPING", "HANDLER", "HAVING", "HOLD", "HOUR", "IDENTITY", "IF", "IMMEDIATE", "IN", "INDICATOR", "INITIALLY", "INNER", "INOUT", "INPUT", "INSENSITIVE", "INSERT", "INT", "INTEGER", "INTERSECT", "INTERVAL", "INTO", "IS", "ISOLATION", "ITERATE", "JOIN", "KEY", "LANGUAGE", "LARGE", "LAST", "LATERAL", "LEADING", "LEAVE", "LEFT", "LEVEL", "LIKE", "LOCAL", "LOCALTIME", "LOCALTIMESTAMP", "LOCATOR", "LOOP", "LOWER", "MAP", "MATCH", "MAX", "MEMBER", "MERGE", "METHOD", "MIN", "MINUTE", "MODIFIES", "MODULE", "MONTH", "MULTISET", "NAMES", "NATIONAL", "NATURAL", "NCHAR", "NCLOB", "NEW", "NEXT", "NO", "NONE", "NOT", "NULL", "NULLIF", "NUMERIC", "OBJECT", "OCTET_LENGTH", "OF", "OLD", "ON", "ONLY", "OPEN", "OPTION", "OR", "ORDER", "ORDINALITY", "OUT", "OUTER", "OUTPUT", "OVER", "OVERLAPS", "PAD", "PARAMETER", "PARTIAL", "PARTITION", "PATH", "POSITION", "PRECISION", "PREPARE", "PRESERVE", "PRIMARY", "PRIOR", "PRIVILEGES", "PROCEDURE", "PUBLIC", "RANGE", "READ", "READS", "REAL", "RECURSIVE", "REF", "REFERENCES", "REFERENCING", "RELATIVE", "RELEASE", "REPEAT", "RESIGNAL", "RESTRICT", "RESULT", "RETURN", "RETURNS", "REVOKE", "RIGHT", "ROLE", "ROLLBACK", "ROLLUP", "ROUTINE", "ROW", "ROWS", "SAVEPOINT", "SCHEMA", "SCOPE", "SCROLL", "SEARCH", "SECOND", "SECTION", "SELECT", "SENSITIVE", "SESSION", "SESSION_USER", "SET", "SETS", "SIGNAL", "SIMILAR", "SIZE", "SMALLINT", "SOME", "SPACE", "SPECIFIC", "SPECIFICTYPE", "SQL", "SQLCODE", "SQLERROR", "SQLEXCEPTION", "SQLSTATE", "SQLWARNING", "START", "STATE", "STATIC", "SUBMULTISET", "SUBSTRING", "SUM", "SYMMETRIC", "SYSTEM", "SYSTEM_USER", "TABLE", "TABLESAMPLE", "TEMPORARY", "THEN", "TIME", "TIMESTAMP", "TIMEZONE_HOUR", "TIMEZONE_MINUTE", "TO", "TRAILING", "TRANSACTION", "TRANSLATE", "TRANSLATION", "TREAT", "TRIGGER", "TRIM", "TRUE", "UNDER", "UNDO", "UNION", "UNIQUE", "UNKNOWN", "UNNEST", "UNTIL", "UPDATE", "UPPER", "USAGE", "USER", "USING", "VALUE", "VALUES", "VARCHAR", "VARYING", "VIEW", "WHEN", "WHENEVER", "WHERE", "WHILE", "WINDOW", "WITH", "WITHIN", "WITHOUT", "WORK", "WRITE", "YEAR", "ZONE"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ public String getDateLiteral(String isoDate) {
val.append(normalLiteral);
val.append(", 'HH24:MI:SS')");
return val.toString();
} else if (isTimestamp(isoDate)) {
StringBuffer val = new StringBuffer(26);
val.append("to_timestamp(");
val.append(normalLiteral);
val.append(", 'YYYY-MM-DD HH24:MI:SS.FF')");
return val.toString();
} else if (isDateTime(isoDate)) {
normalLiteral = normalLiteral.substring(0, normalLiteral.lastIndexOf('.')) + "'";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,13 @@ public String escapeObjectName(String objectName, Class<? extends DatabaseObject
}
return this.quotingStartCharacter+objectName+this.quotingEndCharacter;
}

@Override
public String escapeObjectName(String catalogName, String schemaName, String objectName, Class<? extends DatabaseObject> objectType) {
String name = super.escapeObjectName(catalogName, schemaName, objectName, objectType);
if (name != null) {
name = name.replaceFirst("\\.", ".."); //use .. between schemaName and object name
}
return name;
}
}
Loading

0 comments on commit c777ea1

Please sign in to comment.