Skip to content

Commit

Permalink
'usePreparedStatement' default to 'true' in 'LoadDataChange' and chan…
Browse files Browse the repository at this point in the history
…ged its weight in later decision

(cherry picked from commit a382e56)
  • Loading branch information
Jose D. Hernandez Moreno authored and molivasdat committed Feb 24, 2021
1 parent 440c4c9 commit 6e29566
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ public SqlStatement[] generateStatements(Database database) {
);
}

boolean needsPreparedStatement = false;
if (usePreparedStatements != null && usePreparedStatements) {
needsPreparedStatement = true;
boolean needsPreparedStatement = true;
if (usePreparedStatements != null && !usePreparedStatements) {
needsPreparedStatement = false;
}

List<LoadDataColumnConfig> columnsFromCsv = new ArrayList<>();
Expand Down Expand Up @@ -475,12 +475,13 @@ public SqlStatement[] generateStatements(Database database) {
}
// end of: iterate through all the columns of a CSV line

// Try to use prepared statements if any of the two following conditions apply:
// 1. There is no other option than using a prepared statement (e.g. in cases of LOBs)
// Try to use prepared statements if any of the following conditions apply:
// 1. There is no other option than using a prepared statement (e.g. in cases of LOBs) regardless
// of whether the 'usePreparedStatement' is set to false
// 2. The database supports batched statements (for improved performance) AND we are not in an
// "SQL" mode (i.e. we generate an SQL file instead of actually modifying the database).
if
((needsPreparedStatement || (databaseSupportsBatchUpdates && ! isLoggingExecutor(database))) &&
((needsPreparedStatement && (databaseSupportsBatchUpdates && ! isLoggingExecutor(database))) &&
hasPreparedStatementsImplemented()) {
anyPreparedStatements = true;
ExecutablePreparedStatementBase stmt =
Expand Down

0 comments on commit 6e29566

Please sign in to comment.