mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-07 13:07:42 +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
46 lines
1.8 KiB
C
46 lines
1.8 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* nodeIndexscan.h
|
|
*
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/executor/nodeIndexscan.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef NODEINDEXSCAN_H
|
|
#define NODEINDEXSCAN_H
|
|
|
|
#include "access/parallel.h"
|
|
#include "nodes/execnodes.h"
|
|
|
|
extern IndexScanState *ExecInitIndexScan(IndexScan *node, EState *estate, int eflags);
|
|
extern void ExecEndIndexScan(IndexScanState *node);
|
|
extern void ExecIndexMarkPos(IndexScanState *node);
|
|
extern void ExecIndexRestrPos(IndexScanState *node);
|
|
extern void ExecReScanIndexScan(IndexScanState *node);
|
|
extern void ExecIndexScanEstimate(IndexScanState *node, ParallelContext *pcxt);
|
|
extern void ExecIndexScanInitializeDSM(IndexScanState *node, ParallelContext *pcxt);
|
|
extern void ExecIndexScanReInitializeDSM(IndexScanState *node, ParallelContext *pcxt);
|
|
extern void ExecIndexScanInitializeWorker(IndexScanState *node, shm_toc *toc);
|
|
|
|
/*
|
|
* These routines are exported to share code with nodeIndexonlyscan.c and
|
|
* nodeBitmapIndexscan.c
|
|
*/
|
|
extern void ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
|
|
List *quals, bool isorderby,
|
|
ScanKey *scanKeys, int *numScanKeys,
|
|
IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys,
|
|
IndexArrayKeyInfo **arrayKeys, int *numArrayKeys);
|
|
extern void ExecIndexEvalRuntimeKeys(ExprContext *econtext,
|
|
IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys);
|
|
extern bool ExecIndexEvalArrayKeys(ExprContext *econtext,
|
|
IndexArrayKeyInfo *arrayKeys, int numArrayKeys);
|
|
extern bool ExecIndexAdvanceArrayKeys(IndexArrayKeyInfo *arrayKeys, int numArrayKeys);
|
|
|
|
#endif /* NODEINDEXSCAN_H */
|