Skip to content

Commit

Permalink
Merge branch '3.1.x'
Browse files Browse the repository at this point in the history
Conflicts:
	liquibase-cdi/pom.xml
	liquibase-core/pom.xml
	liquibase-debian/pom.xml
	liquibase-integration-tests/pom.xml
	liquibase-maven-plugin/pom.xml
	liquibase-osgi/pom.xml
	pom.xml
  • Loading branch information
nvoxland committed Jan 16, 2014
2 parents 39c3ff2 + 4b20c12 commit a047a77
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 22 deletions.
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Liquibase Core Changelog
===========================================

Changes in version 3.1.1 (2014.01.16)
Bug Fix release. Most critical bug is CORE-1704

- [CORE-1704] - Checksum errors for changeSets with createProcedure in 3.1.0 vs 3.0.x
- [CORE-1707] - TableRowCountGenerator shouldn't pass tableName as catalogName
- [CORE-1710] - Oracle: NUMBER data type size specification is deployed with a precision specifier even though precision isn't specified in the change log
- [CORE-1711] - rowCount doesn't work if only the tableName is given
- [CORE-1713] - liquibase.precondition.core.ForeignKeyExistsPrecondition exception
- [CORE-1715] - Errors if there are single quotes in comments
- [CORE-1709] - generateChangeLog returns tables created by Materialized Views as standard tables

Changes in version 3.1.0 (2014.01.09)
- Major Changes:
Offline Datatabase Support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ public void setRelativeToChangelogFile(Boolean relativeToChangelogFile) {
" BEGIN\n" +
" DBMS_OUTPUT.PUT_LINE('Hello From The Database!');\n" +
" END;")
/**
* @deprecated Use getProcedureText() instead
*/
public String getProcedureBody() {
return procedureText;
}

/**
* @deprecated Use setProcedureText() instead
*/
public void setProcedureBody(String procedureText) {
this.procedureText = procedureText;
}

@DatabaseChangeProperty(isChangeProperty = false)
public String getProcedureText() {
return procedureText;
}
Expand All @@ -96,7 +111,7 @@ public void setProcedureText(String procedureText) {
this.procedureText = procedureText;
}

@DatabaseChangeProperty(since = "3.1", exampleValue = "h2, oracle")
@DatabaseChangeProperty(since = "3.1", exampleValue = "h2, oracle")
public String getDbms() {
return dbms;
}
Expand Down Expand Up @@ -146,6 +161,10 @@ public InputStream openSqlStream() throws IOException {
*/
@Override
public CheckSum generateCheckSum() {
if (this.path == null) {
return super.generateCheckSum();
}

InputStream stream = null;
try {
stream = openSqlStream();
Expand Down Expand Up @@ -183,7 +202,11 @@ public SqlStatement[] generateStatements(Database database) {
procedureText = StringUtils.trimToNull(getProcedureText());
} else {
try {
procedureText = StreamUtil.getStreamContents(openSqlStream(), encoding);
InputStream stream = openSqlStream();
if (stream == null) {
throw new IOException("File does not exist: "+path);
}
procedureText = StreamUtil.getStreamContents(stream, encoding);
} catch (IOException e) {
throw new UnexpectedLiquibaseException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void check(Database database, DatabaseChangeLog changeLog, ChangeSet chan
TableRowCountStatement statement = new TableRowCountStatement(catalogName, schemaName, tableName);

int result = ExecutorService.getInstance().getExecutor(database).queryForInt(statement);
if (result == expectedRows) {
if (result != expectedRows) {
throw new PreconditionFailedException(getFailureMessage(result), changeLog, this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import liquibase.database.core.*;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.logging.LogFactory;
import liquibase.structure.DatabaseObject;
import liquibase.structure.core.*;
Expand Down Expand Up @@ -273,21 +274,58 @@ public ResultSetCache.RowData wantedKeyParameters() {


@Override
public List<CachedRow> fastFetchQuery() throws SQLException {
public List<CachedRow> fastFetchQuery() throws SQLException, DatabaseException {
CatalogAndSchema catalogAndSchema = database.correctSchema(new CatalogAndSchema(catalogName, schemaName));

if (database instanceof OracleDatabase) {
return queryOracle(catalogAndSchema, null);
}

String catalog = ((AbstractJdbcDatabase) database).getJdbcCatalogName(catalogAndSchema);
String schema = ((AbstractJdbcDatabase) database).getJdbcSchemaName(catalogAndSchema);
return extract(databaseMetaData.getTables(catalog, schema, database.correctObjectName(table, Table.class), types));
}


@Override
public List<CachedRow> bulkFetchQuery() throws SQLException {
public List<CachedRow> bulkFetchQuery() throws SQLException, DatabaseException {
CatalogAndSchema catalogAndSchema = database.correctSchema(new CatalogAndSchema(catalogName, schemaName));

if (database instanceof OracleDatabase) {
return queryOracle(catalogAndSchema, null);
}

return extract(databaseMetaData.getTables(((AbstractJdbcDatabase) database).getJdbcCatalogName(catalogAndSchema), ((AbstractJdbcDatabase) database).getJdbcSchemaName(catalogAndSchema), null, types));
}

private List<CachedRow> queryOracle(CatalogAndSchema catalogAndSchema, String tableName) throws DatabaseException, SQLException {
List<CachedRow> results = new ArrayList<CachedRow>();
for (String type : types) {
String allTable;
String nameColumn;
if (type.equalsIgnoreCase("table")) {
allTable = "ALL_TABLES";
nameColumn = "TABLE_NAME";
} else if (type.equalsIgnoreCase("view")) {
allTable = "ALL_VIEWS";
nameColumn = "VIEW_NAME";
} else {
throw new UnexpectedLiquibaseException("Unknown table type: "+type);
}

String ownerName = database.correctObjectName(catalogAndSchema.getCatalogName(), Schema.class);
String sql = "SELECT null as TABLE_CAT, a.OWNER as TABLE_SCHEM, a."+nameColumn+" as TABLE_NAME, 'TABLE' as TABLE_TYPE, c.COMMENTS as REMARKS " +
"from "+allTable+" a " +
"join ALL_TAB_COMMENTS c on a."+nameColumn+"=c.table_name and a.owner=c.owner " +
"WHERE a.OWNER='" + ownerName + "'";
if (tableName != null) {
sql += " AND "+nameColumn+"='" + database.correctObjectName(tableName, Table.class) + "'";
}
sql += " AND a."+nameColumn+" not in (select mv.name from all_registered_mviews mv where mv.owner='"+ownerName+"')";
results.addAll(executeAndExtract(sql, database));
}
return results;
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ protected DataType readDataType(CachedRow columnMetadataResultSet, Column column
type.setColumnSize(38);
}
type.setDecimalDigits(columnMetadataResultSet.getInt("DATA_SCALE"));
if (type.getDecimalDigits() == null) {
type.setDecimalDigits(0);
}
// type.setRadix(10);
} else {
type.setColumnSize(columnMetadataResultSet.getInt("DATA_LENGTH"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Sql[] generateSql(MarkChangeSetRanStatement statement, Database database,
.addColumnValue("ORDEREXECUTED", ChangeLogHistoryServiceFactory.getInstance().getChangeLogService(database).getNextSequenceValue())
.addColumnValue("MD5SUM", changeSet.generateCheckSum().toString())
.addColumnValue("DESCRIPTION", limitSize(changeSet.getDescription()))
.addColumnValue("COMMENTS", limitSize(StringUtils.trimToEmpty(changeSet.getComments())))
.addColumnValue("COMMENTS", limitSize(database.escapeStringForDatabase(StringUtils.trimToEmpty(changeSet.getComments()))))
.addColumnValue("EXECTYPE", statement.getExecType().value)
.addColumnValue("LIQUIBASE", LiquibaseUtil.getBuildVersion().replaceAll("SNAPSHOT", "SNP"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ValidationErrors validate(TableRowCountStatement dropColumnStatement, Dat
}

protected String generateCountSql(TableRowCountStatement statement, Database database) {
return "SELECT COUNT(*) FROM "+database.escapeTableName(statement.getTableName(), statement.getSchemaName(), statement.getTableName());
return "SELECT COUNT(*) FROM "+database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package liquibase.structure.core;

import liquibase.util.StringUtils;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -47,7 +49,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return getName().toUpperCase().hashCode();
return StringUtils.trimToEmpty(getName()).toUpperCase().hashCode();
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions liquibase-core/src/main/java/liquibase/util/StreamUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public static String getStreamContents(InputStream ins, String charsetName)
throws IOException {
UtfBomAwareReader reader;

if (ins == null) {
throw new IOException("No stream to open");
}

if (charsetName == null) {
reader = new UtfBomAwareReader(ins);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: asany
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: db2
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: derby
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: firebird
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: h2
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: hsqldb
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: informix
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: mssql
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: mysql
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: oracle
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: postgresql
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: sqlite
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: sybase
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Database: unsupported
-- Change Parameter: procedureText=CREATE OR REPLACE PROCEDURE testHello
-- Change Parameter: procedureBody=CREATE OR REPLACE PROCEDURE testHello
-- IS
-- BEGIN
-- DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
Expand Down

0 comments on commit a047a77

Please sign in to comment.