protected void addJoinNode(JoinNode joinNode) throws StandardException {
FromTable fromLeft = (FromTable)joinNode.getLeftResultSet();
FromTable fromRight = (FromTable)joinNode.getRightResultSet();
if (joinNode.getNodeType() == NodeTypes.FULL_OUTER_JOIN_NODE)
{
throw new UnsupportedFullOuterJoinException();
}
addFromTable(fromLeft);
addFromTable(fromRight);
if ((joinNode.getUsingClause() != null) || joinNode.isNaturalJoin()) {
// Replace USING clause with equivalent equality predicates, all bound up.
NodeFactory nodeFactory = joinNode.getNodeFactory();
SQLParserContext parserContext = joinNode.getParserContext();
ValueNode conditions = null;
if (joinNode.getUsingClause() != null) {
for (ResultColumn rc : joinNode.getUsingClause()) {
String columnName = rc.getName();
ColumnBinding leftBinding = getColumnBinding(fromLeft, columnName);
if (leftBinding == null)
throw new NoSuchColumnException(columnName, rc);
ColumnBinding rightBinding = getColumnBinding(fromRight, columnName);
if (rightBinding == null)
throw new NoSuchColumnException(columnName, rc);
conditions = addJoinEquality(conditions,
columnName, leftBinding, rightBinding,
nodeFactory, parserContext);
BindingContext bindingContext = getBindingContext();
// USING is tricky case, since join columns do not repeat in expansion.
// (see 7.5 of sql1992 spec)
if (joinNode.getNodeType() == NodeTypes.FULL_OUTER_JOIN_NODE)
{
throw new UnsupportedFullOuterJoinException();
} else if (joinNode.getNodeType() == NodeTypes.HALF_OUTER_JOIN_NODE &&
((HalfOuterJoinNode)joinNode).isRightOuterJoin())
{
// We use the value from the right table on a RIGHT OUTER JOIN
// so ignore the column in the left table