// data generated for non-matching rows
RowSetNavigatorClient newData = new RowSetNavigatorClient(8);
// rowset for update operation
RowSetNavigatorDataChange updateRowSet =
session.sessionContext.getRowSetDataChange();
RangeVariable[] joinRangeIterators = targetRangeVariables;
// populate insert and update lists
RangeIterator[] rangeIterators =
new RangeIterator[joinRangeIterators.length];
for (int i = 0; i < joinRangeIterators.length; i++) {
rangeIterators[i] = joinRangeIterators[i].getIterator(session);
}
for (int currentIndex = 0; currentIndex >= 0; ) {
RangeIterator it = rangeIterators[currentIndex];
boolean beforeFirst = it.isBeforeFirst();
if (it.next()) {
if (currentIndex < joinRangeIterators.length - 1) {
currentIndex++;
continue;
}
} else {
if (currentIndex == 1 && beforeFirst
&& insertExpression != null) {
Object[] data =
getInsertData(session, colTypes,
insertExpression.nodes[0].nodes);
if (data != null) {
newData.add(data);
}
}
it.reset();
currentIndex--;
continue;
}
// row matches!
if (updateExpressions.length != 0) {
Row row = it.getCurrentRow(); // this is always the second iterator
session.sessionData.startRowProcessing();
Object[] data = getUpdatedData(session, targets, baseTable,
updateColumnMap,
updateExpressions, colTypes,
row.getData());
try {
updateRowSet.addRow(session, row, data, colTypes,
updateColumnMap);
} catch (HsqlException e) {
for (int i = 0; i < joinRangeIterators.length; i++) {
rangeIterators[i].reset();
}
throw Error.error(ErrorCode.X_21000);
}
}
}
updateRowSet.endMainDataSet();
for (int i = 0; i < joinRangeIterators.length; i++) {
rangeIterators[i].reset();
}