提交 cba7f2c8 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Extract row variable

上级 4cd4f38d
...@@ -375,12 +375,13 @@ public class Insert extends Prepared implements ResultTarget { ...@@ -375,12 +375,13 @@ public class Insert extends Prepared implements ResultTarget {
ArrayList<String> variableNames = new ArrayList<>( ArrayList<String> variableNames = new ArrayList<>(
duplicateKeyAssignmentMap.size()); duplicateKeyAssignmentMap.size());
Expression[] row = list.get(getCurrentRowNumber() - 1);
for (int i = 0; i < columns.length; i++) { for (int i = 0; i < columns.length; i++) {
String key = table.getSchema().getName() + "." + String key = table.getSchema().getName() + "." +
table.getName() + "." + columns[i].getName(); table.getName() + "." + columns[i].getName();
variableNames.add(key); variableNames.add(key);
session.setVariable(key, session.setVariable(key,
list.get(getCurrentRowNumber() - 1)[i].getValue(session)); row[i].getValue(session));
} }
StatementBuilder buff = new StatementBuilder("UPDATE "); StatementBuilder buff = new StatementBuilder("UPDATE ");
...@@ -425,6 +426,7 @@ public class Insert extends Prepared implements ResultTarget { ...@@ -425,6 +426,7 @@ public class Insert extends Prepared implements ResultTarget {
indexedColumns = foundIndex.getColumns(); indexedColumns = foundIndex.getColumns();
} }
Expression[] row = list.get(getCurrentRowNumber() - 1);
Expression condition = null; Expression condition = null;
for (Column column : indexedColumns) { for (Column column : indexedColumns) {
ExpressionColumn expr = new ExpressionColumn(session.getDatabase(), ExpressionColumn expr = new ExpressionColumn(session.getDatabase(),
...@@ -433,13 +435,10 @@ public class Insert extends Prepared implements ResultTarget { ...@@ -433,13 +435,10 @@ public class Insert extends Prepared implements ResultTarget {
for (int i = 0; i < columns.length; i++) { for (int i = 0; i < columns.length; i++) {
if (expr.getColumnName().equals(columns[i].getName())) { if (expr.getColumnName().equals(columns[i].getName())) {
if (condition == null) { if (condition == null) {
condition = new Comparison(session, Comparison.EQUAL, condition = new Comparison(session, Comparison.EQUAL, expr, row[i++]);
expr, list.get(getCurrentRowNumber() - 1)[i++]);
} else { } else {
condition = new ConditionAndOr(ConditionAndOr.AND, condition = new ConditionAndOr(ConditionAndOr.AND, condition,
condition, new Comparison(session, Comparison.EQUAL, expr, row[i++]));
new Comparison(session, Comparison.EQUAL, expr,
list.get(getCurrentRowNumber() - 1)[i++]));
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论