---------------------------------------------------------------- * InitPlan * * Initializes the query plan: open files, allocate storage * and start up the rule manager * ---------------------------------------------------------------- */
| 1751 | * ---------------------------------------------------------------- |
| 1752 | */ |
| 1753 | static void |
| 1754 | InitPlan(QueryDesc *queryDesc, int eflags) |
| 1755 | { |
| 1756 | CmdType operation = queryDesc->operation; |
| 1757 | PlannedStmt *plannedstmt = queryDesc->plannedstmt; |
| 1758 | Plan *plan = plannedstmt->planTree; |
| 1759 | List *rangeTable = plannedstmt->rtable; |
| 1760 | EState *estate = queryDesc->estate; |
| 1761 | PlanState *planstate; |
| 1762 | TupleDesc tupType; |
| 1763 | ListCell *l; |
| 1764 | |
| 1765 | Assert(plannedstmt->intoPolicy == NULL || |
| 1766 | GpPolicyIsPartitioned(plannedstmt->intoPolicy) || |
| 1767 | GpPolicyIsReplicated(plannedstmt->intoPolicy)); |
| 1768 | |
| 1769 | if (DEBUG1 >= log_min_messages) |
| 1770 | { |
| 1771 | char msec_str[32]; |
| 1772 | switch (check_log_duration(msec_str, false)) |
| 1773 | { |
| 1774 | case 1: |
| 1775 | case 2: |
| 1776 | ereport(LOG, (errmsg("duration to InitPlan start: %s ms", msec_str))); |
| 1777 | break; |
| 1778 | default: |
| 1779 | /* do nothing */ |
| 1780 | break; |
| 1781 | } |
| 1782 | } |
| 1783 | |
| 1784 | /* |
| 1785 | * Do permissions checks |
| 1786 | */ |
| 1787 | if (operation != CMD_SELECT || Gp_role != GP_ROLE_EXECUTE) |
| 1788 | { |
| 1789 | ExecCheckRTPerms(rangeTable, true); |
| 1790 | } |
| 1791 | |
| 1792 | /* |
| 1793 | * initialize the node's execution state |
| 1794 | */ |
| 1795 | ExecInitRangeTable(estate, rangeTable); |
| 1796 | |
| 1797 | estate->es_plannedstmt = plannedstmt; |
| 1798 | |
| 1799 | /* |
| 1800 | * Next, build the ExecRowMark array from the PlanRowMark(s), if any. |
| 1801 | */ |
| 1802 | if (plannedstmt->rowMarks) |
| 1803 | { |
| 1804 | estate->es_rowmarks = (ExecRowMark **) |
| 1805 | palloc0(estate->es_range_table_size * sizeof(ExecRowMark *)); |
| 1806 | foreach(l, plannedstmt->rowMarks) |
| 1807 | { |
| 1808 | PlanRowMark *rc = (PlanRowMark *) lfirst(l); |
| 1809 | Oid relid; |
| 1810 | Relation relation; |
no test coverage detected