Skip to content

Commit

Permalink
Update for lowercase names
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
  • Loading branch information
prb112 committed Nov 8, 2021
1 parent caf2bc2 commit a2521f2
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,30 @@ private void checkDataInAllPartitionedTenantTables(IDatabaseTranslator translato
*/
private void checkDataTables(IDatabaseTranslator translator, Connection c) {
for (String deprecatedTable : UnusedTableRemovalNeedsV0021Migration.DEPRECATED_TABLES) {
final String table = schemaName + "." + deprecatedTable;
if (adapter.doesTableExist(schemaName, deprecatedTable)) {
String table = schemaName + "." + deprecatedTable;
if (translator.getType() == DbType.POSTGRESQL) {
table = schemaName.toLowerCase() + "." + deprecatedTable;
}

// When checking for data... SYSCAT.TABLES->CARD was considered to be checked.
// However if the db hasn't collected statistics -1 is returned, and unreliable
// Instead we're going to check if it has at least one row...
final String sql = "SELECT * FROM " + table + " " + translator.limit("1");
try (PreparedStatement ps = c.prepareStatement(sql)) {
if (ps.execute()) {
ResultSet rs = ps.getResultSet();
if (rs.next()) {
LOG.warning("Data Table contains data '" + table + "'");
count++;
// When checking for data... SYSCAT.TABLES->CARD was considered to be checked.
// However if the db hasn't collected statistics -1 is returned, and unreliable
// Instead we're going to check if it has at least one row...
final String sql = "SELECT * FROM " + table + " " + translator.limit("1");
try (PreparedStatement ps = c.prepareStatement(sql)) {
if (ps.execute()) {
ResultSet rs = ps.getResultSet();
if (rs.next()) {
LOG.warning("Data Table contains data '" + table + "'");
count++;
}
}
} catch (SQLException x) {
if (!translator.isUndefinedName(x)){
throw translator.translate(x);
} else {
LOG.finest("Table already deleted: " + table);
}
}
} catch (SQLException x) {
if (!translator.isUndefinedName(x)){
throw translator.translate(x);
} else {
LOG.finest("Table already deleted: " + table);
}
}
}
Expand Down

0 comments on commit a2521f2

Please sign in to comment.