Source:
private boolean handleOnDuplicate(DbException de, Value[] currentRow) { if (de.getErrorCode() != ErrorCode.DUPLICATE_KEY_1) { throw de; } if (duplicateKeyAssignmentMap == null || duplicateKeyAssignmentMap.isEmpty()) { if (ignore) { return false; } throw de; } ArrayList<String> variableNames = new ArrayList<>( duplicateKeyAssignmentMap.size()); Expression[] row = (currentRow == null) ? valuesExpressionList.get((int) getCurrentRowNumber() - 1) : new Expression[columns.length]; for (int i = 0; i < columns.length; i++) { StringBuilder builder = table.getSQL(new StringBuilder()).append('.'); String key = columns[i].getSQL(builder).toString(); variableNames.add(key); Value value; if (currentRow != null) { value = currentRow[i]; row[i] = ValueExpression.get(value); } else { value = row[i].getValue(session); } session.setVariable(key, value); } StatementBuilder buff = new StatementBuilder("UPDATE "); table.getSQL(buff.builder()).append(" SET "); for (Column column : duplicateKeyAssignmentMap.keySet()) { buff.appendExceptFirst(", "); Expression ex = duplicateKeyAssignmentMap.get(column); column.getSQL(buff.builder()).append('='); ex.getSQL(buff.builder()); } buff.append(" WHERE "); Index foundIndex = (Index) de.getSource(); if (foundIndex == null) { throw DbException.getUnsupportedException( "Unable to apply ON DUPLICATE KEY UPDATE, no index found!"); } prepareUpdateCondition(foundIndex, row).getSQL(buff.builder()); String sql = buff.toString(); Update command = (Update) session.prepare(sql); command.setUpdateToCurrentValuesReturnsZero(true); for (Parameter param : command.getParameters()) { Parameter insertParam = parameters.get(param.getIndex()); param.setValue(insertParam.getValue(session)); } boolean result = command.update() > 0; for (String variableName : variableNames) { session.setVariable(variableName, ValueNull.INSTANCE); } return result; }

Target:
private boolean handleOnDuplicate(DbException de, Value[] currentRow) { if (de.getErrorCode() != ErrorCode.DUPLICATE_KEY_1) { throw de; } if (duplicateKeyAssignmentMap == null || duplicateKeyAssignmentMap.isEmpty()) { if (ignore) { return false; } throw de; } ArrayList<String> variableNames = new ArrayList<>( duplicateKeyAssignmentMap.size()); Expression[] row = (currentRow == null) ? valuesExpressionList.get((int) getCurrentRowNumber() - 1) : new Expression[columns.length]; for (int i = 0; i < columns.length; i++) { StringBuilder builder = table.getSQL(new StringBuilder()).append('.'); String key = columns[i].getSQL(builder).toString(); variableNames.add(key); Value value; if (currentRow != null) { value = currentRow[i]; row[i] = ValueExpression.get(value); } else { value = row[i].getValue(session); } session.setVariable(key, value); } StringBuilder builder = new StringBuilder("UPDATE "); table.getSQL(builder).append(" SET "); boolean f = false; for (Column column : duplicateKeyAssignmentMap.keySet()) { if (f) { builder.append(", "); } f = true; Expression ex = duplicateKeyAssignmentMap.get(column); column.getSQL(builder).append('='); ex.getSQL(builder); } builder.append(" WHERE "); Index foundIndex = (Index) de.getSource(); if (foundIndex == null) { throw DbException.getUnsupportedException( "Unable to apply ON DUPLICATE KEY UPDATE, no index found!"); } prepareUpdateCondition(foundIndex, row).getSQL(builder); String sql = builder.toString(); Update command = (Update) session.prepare(sql); command.setUpdateToCurrentValuesReturnsZero(true); for (Parameter param : command.getParameters()) { Parameter insertParam = parameters.get(param.getIndex()); param.setValue(insertParam.getValue(session)); } boolean result = command.update() > 0; for (String variableName : variableNames) { session.setVariable(variableName, ValueNull.INSTANCE); } return result; }