AbstractPlanNode subSelectRoot = subAssembler.nextPlan();
if (subSelectRoot == null)
return null;
UpdatePlanNode updateNode = new UpdatePlanNode(m_context, getNextPlanNodeId());
updateNode.setTargetTableName(targetTable.getTypeName());
// set this to false until proven otherwise
updateNode.setUpdateIndexes(false);
ProjectionPlanNode projectionNode = new ProjectionPlanNode(m_context, getNextPlanNodeId());
TupleAddressExpression tae = new TupleAddressExpression();
PlanColumn colInfo = m_context.getPlanColumn(tae, "tuple_address");
projectionNode.appendOutputColumn(colInfo);
// get the set of columns affected by indexes
Set<String> affectedColumns = getIndexedColumnSetForTable(targetTable);
// add the output columns we need
for (Entry<Column, AbstractExpression> col : m_parsedUpdate.columns.entrySet()) {
colInfo = m_context.getPlanColumn(col.getValue(), col.getKey().getTypeName());
projectionNode.appendOutputColumn(colInfo);
// check if this column is an indexed column
if (affectedColumns.contains(colInfo.getDisplayName()))
updateNode.setUpdateIndexes(true);
}
if (m_singlePartition == true) {
// add the projection inline (TODO: this will break if more than one
// layer is below this)
assert(subSelectRoot instanceof AbstractScanPlanNode);
subSelectRoot.addInlinePlanNode(projectionNode);
// connect the nodes to build the graph
updateNode.addAndLinkChild(subSelectRoot);
// XXX: PAVLO
if (INCLUDE_SEND_FOR_ALL) {
SendPlanNode sendNode = new SendPlanNode(m_context, getNextPlanNodeId());
sendNode.setFake(true);
sendNode.addAndLinkChild(updateNode);
sendNode.setOutputColumns(updateNode.getOutputColumnGUIDs());
return sendNode;
} else {
return updateNode;
}
} else {
// make sure the thing we have is a receive node which
// indicates it's a multi-site plan
assert (subSelectRoot instanceof ReceivePlanNode);
//
// put the update node in the right place
//
// get the recv node
ReceivePlanNode recvNode = (ReceivePlanNode) subSelectRoot;
// get the send node
assert (recvNode.getChildPlanNodeCount() == 1);
AbstractPlanNode sendNode = recvNode.getChild(0);
// get the scan node and unlink
assert (sendNode.getChildPlanNodeCount() == 1);
AbstractPlanNode scanNode = sendNode.getChild(0);
sendNode.unlinkChild(scanNode);
// link in the update node
assert (scanNode instanceof AbstractScanPlanNode);
scanNode.addInlinePlanNode(projectionNode);
updateNode.addAndLinkChild(scanNode);
AbstractPlanNode countNode = insertCountInDMLPlan(updateNode);
sendNode.addAndLinkChild(countNode);
// fix the receive node's output columns