* Initialize or reset an EvalPlanQual state tree */
| 3882 | * Initialize or reset an EvalPlanQual state tree |
| 3883 | */ |
| 3884 | void |
| 3885 | EvalPlanQualBegin(EPQState *epqstate) |
| 3886 | { |
| 3887 | EState *parentestate = epqstate->parentestate; |
| 3888 | EState *recheckestate = epqstate->recheckestate; |
| 3889 | |
| 3890 | if (recheckestate == NULL) |
| 3891 | { |
| 3892 | /* First time through, so create a child EState */ |
| 3893 | EvalPlanQualStart(epqstate, epqstate->plan); |
| 3894 | } |
| 3895 | else |
| 3896 | { |
| 3897 | /* |
| 3898 | * We already have a suitable child EPQ tree, so just reset it. |
| 3899 | */ |
| 3900 | Index rtsize = parentestate->es_range_table_size; |
| 3901 | PlanState *rcplanstate = epqstate->recheckplanstate; |
| 3902 | |
| 3903 | MemSet(epqstate->relsubs_done, 0, rtsize * sizeof(bool)); |
| 3904 | |
| 3905 | /* Recopy current values of parent parameters */ |
| 3906 | if (parentestate->es_plannedstmt->paramExecTypes != NIL) |
| 3907 | { |
| 3908 | int i; |
| 3909 | |
| 3910 | /* |
| 3911 | * Force evaluation of any InitPlan outputs that could be needed |
| 3912 | * by the subplan, just in case they got reset since |
| 3913 | * EvalPlanQualStart (see comments therein). |
| 3914 | */ |
| 3915 | ExecSetParamPlanMulti(rcplanstate->plan->extParam, |
| 3916 | GetPerTupleExprContext(parentestate), NULL); |
| 3917 | |
| 3918 | i = list_length(parentestate->es_plannedstmt->paramExecTypes); |
| 3919 | |
| 3920 | while (--i >= 0) |
| 3921 | { |
| 3922 | /* copy value if any, but not execPlan link */ |
| 3923 | recheckestate->es_param_exec_vals[i].value = |
| 3924 | parentestate->es_param_exec_vals[i].value; |
| 3925 | recheckestate->es_param_exec_vals[i].isnull = |
| 3926 | parentestate->es_param_exec_vals[i].isnull; |
| 3927 | } |
| 3928 | } |
| 3929 | |
| 3930 | /* |
| 3931 | * Mark child plan tree as needing rescan at all scan nodes. The |
| 3932 | * first ExecProcNode will take care of actually doing the rescan. |
| 3933 | */ |
| 3934 | rcplanstate->chgParam = bms_add_member(rcplanstate->chgParam, |
| 3935 | epqstate->epqParam); |
| 3936 | } |
| 3937 | } |
| 3938 | |
| 3939 | /* |
| 3940 | * Start execution of an EvalPlanQual plan tree. |
no test coverage detected