| 604 | ListCell *l; |
| 605 | int count = 0; |
| 606 | foreach_with_count(l, relations, count) |
| 607 | { |
| 608 | char *relation = (char *) lfirst(l); |
| 609 | if (aliases.count(std::string(relation)) > 0) |
| 610 | { |
| 611 | pair->Release(); |
| 612 | // invalid leading hint if alias is specified more than once |
| 613 | return nullptr; |
| 614 | } |
| 615 | aliases.insert(std::string(relation)); |
| 616 | |
| 617 | CWStringConst *alias = GPOS_NEW(mp) CWStringConst(mp, relation); |
| 618 | |
| 619 | if (count == 0) |
| 620 | { |
| 621 | // As we traverse the input list relations, we build up the |
| 622 | // JoinNode pair. The first element is an edge case because there |
| 623 | // is no existing JoinNode pair yet. |
| 624 | pair = GPOS_NEW(mp) CJoinHint::JoinNode(alias); |
| 625 | } |
| 626 | else |
| 627 | { |
| 628 | pair = GPOS_NEW(mp) CJoinHint::JoinNode( |
| 629 | pair, GPOS_NEW(mp) CJoinHint::JoinNode(alias), |
| 630 | /*is_directed*/ false); |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | return pair; |
| 635 | } |