On Wed, Aug 9, 2023 at 8:57 AM Amit Langote <[email protected]> wrote: > I checked enough to be sure that IsParallelWorker() is reliable at the > time of ExecutorStart() / ExecInitNode() in ParallelQueryMain() in a > worker. However, ParallelWorkerContext is not available at that > point. Here's the relevant part of ParallelQueryMain(): > > /* Start up the executor */ > queryDesc->plannedstmt->jitFlags = fpes->jit_flags; > ExecutorStart(queryDesc, fpes->eflags); > > /* Special executor initialization steps for parallel workers */ > queryDesc->planstate->state->es_query_dsa = area; > if (DsaPointerIsValid(fpes->param_exec)) > { > char *paramexec_space; > > paramexec_space = dsa_get_address(area, fpes->param_exec); > RestoreParamExecParams(paramexec_space, queryDesc->estate); > } > pwcxt.toc = toc; > pwcxt.seg = seg; > ExecParallelInitializeWorker(queryDesc->planstate, &pwcxt); > > BTW, we do also use IsParallelWorker() in ExecGetRangeTableRelation() > which also probably only runs during ExecInitNode(), same as > ExecInitPartitionPruning() that this patch adds it to.
I don't know if that's a great idea, but I guess if we're already doing it, it doesn't hurt to expand the use a little bit. -- Robert Haas EDB: http://www.enterprisedb.com
