mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Simplify executor's determination of whether to use parallelism.
Our parallel-mode code only works when we are executing a query in full, so ExecutePlan must disable parallel mode when it is asked to do partial execution. The previous logic for this involved passing down a flag (variously named execute_once or run_once) from callers of ExecutorRun or PortalRun. This is overcomplicated, and unsurprisingly some of the callers didn't get it right, since it requires keeping state that not all of them have handy; not to mention that the requirements for it were undocumented. That led to assertion failures in some corner cases. The only state we really need for this is the existing QueryDesc.already_executed flag, so let's just put all the responsibility in ExecutePlan. (It could have been done in ExecutorRun too, leading to a slightly shorter patch -- but if there's ever more than one caller of ExecutePlan, it seems better to have this logic in the subroutine than the callers.) This makes those ExecutorRun/PortalRun parameters unnecessary. In master it seems okay to just remove them, returning the API for those functions to what it was before parallelism. Such an API break is clearly not okay in stable branches, but for them we can just leave the parameters in place after documenting that they do nothing. Per report from Yugo Nagata, who also reviewed and tested this patch. Back-patch to all supported branches. Discussion: https://postgr.es/m/20241206062549.710dc01cf91224809dd6c0e1@sraoss.co.jp
This commit is contained in:
@ -78,8 +78,7 @@ extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook;
|
||||
/* Hook for plugins to get control in ExecutorRun() */
|
||||
typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc,
|
||||
ScanDirection direction,
|
||||
uint64 count,
|
||||
bool execute_once);
|
||||
uint64 count);
|
||||
extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;
|
||||
|
||||
/* Hook for plugins to get control in ExecutorFinish() */
|
||||
@ -200,9 +199,9 @@ ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
|
||||
extern void ExecutorStart(QueryDesc *queryDesc, int eflags);
|
||||
extern void standard_ExecutorStart(QueryDesc *queryDesc, int eflags);
|
||||
extern void ExecutorRun(QueryDesc *queryDesc,
|
||||
ScanDirection direction, uint64 count, bool execute_once);
|
||||
ScanDirection direction, uint64 count);
|
||||
extern void standard_ExecutorRun(QueryDesc *queryDesc,
|
||||
ScanDirection direction, uint64 count, bool execute_once);
|
||||
ScanDirection direction, uint64 count);
|
||||
extern void ExecutorFinish(QueryDesc *queryDesc);
|
||||
extern void standard_ExecutorFinish(QueryDesc *queryDesc);
|
||||
extern void ExecutorEnd(QueryDesc *queryDesc);
|
||||
|
Reference in New Issue
Block a user