Skip to content

Commit

Permalink
0006164: During an upgrade, log DDL before executing it instead of af…
Browse files Browse the repository at this point in the history
…terwards
  • Loading branch information
evan-miller-jumpmind committed Dec 19, 2023
1 parent 177afcd commit 70be27e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Expand Up @@ -21,6 +21,8 @@
package org.jumpmind.db.sql;

public interface ISqlResultsListener {
public void sqlBefore(String sql, int lineNumber);

public void sqlApplied(String sql, int rowsUpdated, int rowsRetrieved, int lineNumber);

public void sqlErrored(String sql, SqlException ex, int lineNumber, boolean dropStatement, boolean sequenceCreate);
Expand Down
Expand Up @@ -29,6 +29,10 @@ public class LogSqlResultsListener implements ISqlResultsListener {
public LogSqlResultsListener() {
}

public void sqlBefore(String sql, int lineNumber) {
log.info("Executing DDL: {}", sql);
}

public void sqlErrored(String sql, SqlException ex, int lineNumber, boolean dropStatement,
boolean sequenceCreate) {
if (dropStatement || sequenceCreate) {
Expand All @@ -39,6 +43,5 @@ public void sqlErrored(String sql, SqlException ex, int lineNumber, boolean drop
}

public void sqlApplied(String sql, int rowsUpdated, int rowsRetrieved, int lineNumber) {
log.info("DDL applied: {}", sql);
}
}
Expand Up @@ -423,6 +423,9 @@ public Integer execute(Connection con) throws SQLException {
.readSqlStatement()) {
if (isNotBlank(statement)) {
try {
if (resultsListener != null) {
resultsListener.sqlBefore(statement, statementCount);
}
long startTime = System.currentTimeMillis();
boolean hasResults = stmt.execute(statement);
long endTime = System.currentTimeMillis();
Expand Down

0 comments on commit 70be27e

Please sign in to comment.