| 1707 | // |
| 1708 | |
| 1709 | static void cmp_plan(const gpre_nod* plan_expression, gpre_req* request) |
| 1710 | { |
| 1711 | // stuff the join type |
| 1712 | |
| 1713 | const gpre_nod* list = plan_expression->nod_arg[1]; |
| 1714 | if (list->nod_count > 1) |
| 1715 | { |
| 1716 | const gpre_nod* node = plan_expression->nod_arg[0]; |
| 1717 | if (node) |
| 1718 | request->add_byte(blr_merge); |
| 1719 | else |
| 1720 | request->add_byte(blr_join); |
| 1721 | request->add_byte(list->nod_count); |
| 1722 | } |
| 1723 | |
| 1724 | // stuff one or more plan items |
| 1725 | |
| 1726 | gpre_nod* const* ptr = list->nod_arg; |
| 1727 | for (gpre_nod* const* const end = ptr + list->nod_count; ptr < end; ptr++) |
| 1728 | { |
| 1729 | gpre_nod* node = *ptr; |
| 1730 | if (node->nod_type == nod_plan_expr) |
| 1731 | { |
| 1732 | cmp_plan(node, request); |
| 1733 | continue; |
| 1734 | } |
| 1735 | |
| 1736 | // if we're here, it must be a nod_plan_item |
| 1737 | |
| 1738 | request->add_byte(blr_retrieve); |
| 1739 | |
| 1740 | // stuff the relation--the relation id itself is redundant except |
| 1741 | // when there is a need to differentiate the base tables of views |
| 1742 | |
| 1743 | CME_relation((gpre_ctx*) node->nod_arg[2], request); |
| 1744 | |
| 1745 | // now stuff the access method for this stream |
| 1746 | |
| 1747 | const gpre_nod* arg = node->nod_arg[1]; |
| 1748 | switch (arg->nod_type) |
| 1749 | { |
| 1750 | case nod_natural: |
| 1751 | request->add_byte(blr_sequential); |
| 1752 | break; |
| 1753 | |
| 1754 | case nod_index_order: |
| 1755 | request->add_byte(blr_navigational); |
| 1756 | request->add_cstring((TEXT*) arg->nod_arg[0]); |
| 1757 | break; |
| 1758 | |
| 1759 | case nod_index: |
| 1760 | { |
| 1761 | request->add_byte(blr_indices); |
| 1762 | arg = arg->nod_arg[0]; |
| 1763 | request->add_byte(arg->nod_count); |
| 1764 | const gpre_nod* const* ptr2 = arg->nod_arg; |
| 1765 | for (const gpre_nod* const* const end2 = ptr2 + arg->nod_count; ptr2 < end2; ptr2++) |
| 1766 | { |
no test coverage detected