mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-07 16:47:37 +08:00
Previously, the parallel executor logic did reinitialization of shared state within the ExecReScan code for parallel-aware scan nodes. This is problematic, because it means that the ExecReScan call has to occur synchronously (ie, during the parent Gather node's ReScan call). That is swimming very much against the tide so far as the ExecReScan machinery is concerned; the fact that it works at all today depends on a lot of fragile assumptions, such as that no plan node between Gather and a parallel-aware scan node is parameterized. Another objection is that because ExecReScan might be called in workers as well as the leader, hacky extra tests are needed in some places to prevent unwanted shared-state resets. Hence, let's separate this code into two functions, a ReInitializeDSM call and the ReScan call proper. ReInitializeDSM is called only in the leader and is guaranteed to run before we start new workers. ReScan is returned to its traditional function of resetting only local state, which means that ExecReScan's usual habits of delaying or eliminating child rescan calls are safe again. As with the preceding commit 7df2c1f8d, it doesn't seem to be necessary to make these changes in 9.6, which is a good thing because the FDW and CustomScan APIs are impacted. Discussion: https://postgr.es/m/CAA4eK1JkByysFJNh9M349u_nNjqETuEnY_y1VUc_kJiU0bxtaQ@mail.gmail.com
44 lines
1.3 KiB
C
44 lines
1.3 KiB
C
/* ------------------------------------------------------------------------
|
|
*
|
|
* nodeCustom.h
|
|
*
|
|
* prototypes for CustomScan nodes
|
|
*
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* ------------------------------------------------------------------------
|
|
*/
|
|
#ifndef NODECUSTOM_H
|
|
#define NODECUSTOM_H
|
|
|
|
#include "access/parallel.h"
|
|
#include "nodes/execnodes.h"
|
|
#include "nodes/extensible.h"
|
|
|
|
/*
|
|
* General executor code
|
|
*/
|
|
extern CustomScanState *ExecInitCustomScan(CustomScan *custom_scan,
|
|
EState *estate, int eflags);
|
|
extern void ExecEndCustomScan(CustomScanState *node);
|
|
|
|
extern void ExecReScanCustomScan(CustomScanState *node);
|
|
extern void ExecCustomMarkPos(CustomScanState *node);
|
|
extern void ExecCustomRestrPos(CustomScanState *node);
|
|
|
|
/*
|
|
* Parallel execution support
|
|
*/
|
|
extern void ExecCustomScanEstimate(CustomScanState *node,
|
|
ParallelContext *pcxt);
|
|
extern void ExecCustomScanInitializeDSM(CustomScanState *node,
|
|
ParallelContext *pcxt);
|
|
extern void ExecCustomScanReInitializeDSM(CustomScanState *node,
|
|
ParallelContext *pcxt);
|
|
extern void ExecCustomScanInitializeWorker(CustomScanState *node,
|
|
shm_toc *toc);
|
|
extern void ExecShutdownCustomScan(CustomScanState *node);
|
|
|
|
#endif /* NODECUSTOM_H */
|