On Tue, Feb 27, 2024 at 8:53 PM Dean Rasheed <dean.a.rash...@gmail.com> wrote: > > Attached is a very rough patch. It seemed better to build the > projection in the executor rather than the planner, since then the > extra work can be avoided, if EPQ is not invoked. > > It seems to work (it passes the isolation tests, and I couldn't break > it in ad hoc testing), but it definitely needs tidying up, and it's > hard to be sure that it's not overlooking something. >
Hi. minor issues. In nodeAppend.c, nodeMergeAppend.c + if (estate->es_epq_active != NULL) + { + /* + * We are inside an EvalPlanQual recheck. If there is a relevant + * rowmark for the append relation, return the test tuple if one is + * available. + */ + oldcontext = MemoryContextSwitchTo(estate->es_query_cxt); + + node->as_epq_tupdesc = lookup_rowtype_tupdesc_copy(tupType, tupTypmod); + + ExecAssignExprContext(estate, &node->ps); + + node->ps.ps_ProjInfo = + ExecBuildProjectionInfo(castNode(Append, node->ps.plan)->epq_targetlist, + node->ps.ps_ExprContext, + node->ps.ps_ResultTupleSlot, + &node->ps, + NULL); + + MemoryContextSwitchTo(oldcontext); EvalPlanQualStart, EvalPlanQualNext will switch the memory context to es_query_cxt. so the memory context switch here is not necessary? do you think it's sane to change `ExecAssignExprContext(estate, &node->ps);` to ` /* need an expression context to do the projection */ if (node->ps.ps_ExprContext == NULL) ExecAssignExprContext(estate, &node->ps); ` ?