@Override public LocalResult query(int limit, ResultTarget target) { // union doesn't always know the parameter list of the left and right // queries return queryWithoutCache(limit, target); }
while (true) { if (readIf("UNION")) { SelectUnion union = new SelectUnion(session, command); if (readIf("ALL")) { union.setUnionType(SelectUnion.UNION_ALL); } else { readIf("DISTINCT"); union.setUnionType(SelectUnion.UNION); union.setRight(parseSelectSub()); command = union; } else if (readIf("MINUS") || readIf("EXCEPT")) { SelectUnion union = new SelectUnion(session, command); union.setUnionType(SelectUnion.EXCEPT); union.setRight(parseSelectSub()); command = union; } else if (readIf("INTERSECT")) { SelectUnion union = new SelectUnion(session, command); union.setUnionType(SelectUnion.INTERSECT); union.setRight(parseSelectSub()); command = union; } else {
initOrder(session, expressions, null, orderList, getColumnCount(), true, null); sort = prepareOrder(orderList, expressions.size()); orderList = null;
@Override public void addGlobalCondition(Parameter param, int columnId, int comparisonType) { addParameter(param); switch (unionType) { case UNION_ALL: case UNION: case INTERSECT: { left.addGlobalCondition(param, columnId, comparisonType); right.addGlobalCondition(param, columnId, comparisonType); break; } case EXCEPT: { left.addGlobalCondition(param, columnId, comparisonType); break; } default: DbException.throwInternalError("type=" + unionType); } }
case UNION: { while (l.next()) { result.addRow(convert(l.currentRow(), columnCount)); result.addRow(convert(r.currentRow(), columnCount)); result.addRow(convert(l.currentRow(), columnCount)); result.removeDistinct(convert(r.currentRow(), columnCount)); temp.setRandomAccess(); while (l.next()) { temp.addRow(convert(l.currentRow(), columnCount)); Value[] values = convert(r.currentRow(), columnCount); if (temp.containsDistinct(values)) { result.addRow(values);