Skip to content

Commit

Permalink
Make liquibase.snapshot.ResultSetCache an extensible class. (#2087)
Browse files Browse the repository at this point in the history
This is useful in case an extension has to override
liquibase.snapshot.jvm.UniqueConstraintSnapshotGenerator#listConstraints.

Co-authored-by: Nathan Voxland <nathan@voxland.net>
  • Loading branch information
breglerj and nvoxland committed Aug 31, 2022
1 parent 89fef59 commit 90f84a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public List<CachedRow> bulkFetch() throws SQLException, DatabaseException {
}

@Override
boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
if (database instanceof OracleDatabase || database instanceof MSSQLDatabase) {
return JdbcDatabaseSnapshot.this.getAllCatalogsStringScratchData() != null || (tableName == null && indexName == null) || super.shouldBulkSelect(schemaKey, resultSetCache);
}
Expand Down Expand Up @@ -374,7 +374,7 @@ public String getSchemaKey(CachedRow row) {
}

@Override
boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
return !(tableName.equalsIgnoreCase(database.getDatabaseChangeLogTableName()) || tableName.equalsIgnoreCase(database.getDatabaseChangeLogLockTableName()));
}

Expand Down Expand Up @@ -934,7 +934,7 @@ protected String getDB2ZOSSql(String jdbcSchemaName, String tableName) {
}

@Override
boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
if (database instanceof AbstractDb2Database || database instanceof MSSQLDatabase) {
return super.shouldBulkSelect(schemaKey, resultSetCache); //can bulk and fast fetch
} else {
Expand Down Expand Up @@ -977,7 +977,7 @@ public String getSchemaKey(CachedRow row) {
}

@Override
boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
if (tableName.equalsIgnoreCase(database.getDatabaseChangeLogTableName()) ||
tableName.equalsIgnoreCase(database.getDatabaseChangeLogLockTableName())) {
return false;
Expand Down Expand Up @@ -1061,7 +1061,7 @@ public List<CachedRow> getTables(final String catalogName, final String schemaNa
return getResultSetCache("getTables").get(new ResultSetCache.SingleResultSetExtractor(database) {

@Override
boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
return table == null || getAllCatalogsStringScratchData() != null || super.shouldBulkSelect(schemaKey, resultSetCache);
}

Expand Down Expand Up @@ -1222,7 +1222,7 @@ public List<CachedRow> getViews(final String catalogName, final String schemaNam
return getResultSetCache("getViews").get(new ResultSetCache.SingleResultSetExtractor(database) {

@Override
boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
return view == null || getAllCatalogsStringScratchData() != null || super.shouldBulkSelect(schemaKey, resultSetCache);
}

Expand Down Expand Up @@ -1532,7 +1532,7 @@ public List<CachedRow> bulkFetchQuery() throws SQLException {
}

@Override
boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
if ((database instanceof OracleDatabase) || (database instanceof MSSQLDatabase)) {
return table == null || getAllCatalogsStringScratchData() != null || super.shouldBulkSelect(schemaKey, resultSetCache);
} else {
Expand All @@ -1546,7 +1546,7 @@ public List<CachedRow> getUniqueConstraints(final String catalogName, final Stri
return getResultSetCache("getUniqueConstraints").get(new ResultSetCache.SingleResultSetExtractor(database) {

@Override
boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
return tableName == null || getAllCatalogsStringScratchData() != null || super.shouldBulkSelect(schemaKey, resultSetCache);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.sql.Statement;
import java.util.*;

class ResultSetCache {
public class ResultSetCache {
private Map<String, Integer> timesSingleQueried = new HashMap<>();
private Map<String, Boolean> didBulkQuery = new HashMap<>();
private boolean bulkTracking = true;
Expand Down Expand Up @@ -254,15 +254,15 @@ public String getSchemaKey(CachedRow row) {
throw new UnexpectedLiquibaseException("Not Implemented");
}

boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
protected boolean shouldBulkSelect(String schemaKey, ResultSetCache resultSetCache) {
return resultSetCache.getTimesSingleQueried(schemaKey) >= 3;
}

List<CachedRow> executeAndExtract(String sql, Database database) throws DatabaseException, SQLException {
protected List<CachedRow> executeAndExtract(String sql, Database database) throws DatabaseException, SQLException {
return executeAndExtract(sql, database, false);
}

List<CachedRow> executeAndExtract(String sql, Database database, boolean informixTrimHint)
protected List<CachedRow> executeAndExtract(String sql, Database database, boolean informixTrimHint)
throws DatabaseException, SQLException {
if (sql == null) {
return new ArrayList<>();
Expand Down

0 comments on commit 90f84a2

Please sign in to comment.