diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-11-28 11:39:16 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-11-28 11:49:01 -0500 |
commit | ec7629dfb98a34cf4e459cf6b27febfd33ae9ad5 (patch) | |
tree | c4625574e9f91d6987d5e86b91ece925c33c4dc4 | |
parent | 7015bb38949a44849b7a2e6c139700d20d82858b (diff) | |
download | postgresql-ec7629dfb98a34cf4e459cf6b27febfd33ae9ad5.tar.gz postgresql-ec7629dfb98a34cf4e459cf6b27febfd33ae9ad5.zip |
Teach bitmap heap scan to cope with absence of a DSA.
If we have a plan that uses parallelism but are unable to execute it
using parallelism, for example due to a lack of available DSM
segments, then the EState's es_query_dsa will be NULL. Parallel
bitmap heap scan needs to fall back to a non-parallel scan in such
cases.
Patch by me, reviewed by Dilip Kumar
Discussion: http://postgr.es/m/CAEepm=0kADK5inNf_KuemjX=HQ=PuTP0DykM--fO5jS5ePVFEA@mail.gmail.com
-rw-r--r-- | src/backend/executor/nodeBitmapHeapscan.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index f7e55e0b45b..b7be62e92d6 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -963,6 +963,11 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node, { ParallelBitmapHeapState *pstate; EState *estate = node->ss.ps.state; + dsa_area *dsa = node->ss.ps.state->es_query_dsa; + + /* If there's no DSA, there are no workers; initialize nothing. */ + if (dsa == NULL) + return; pstate = shm_toc_allocate(pcxt->toc, node->pscan_len); @@ -995,6 +1000,10 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node, ParallelBitmapHeapState *pstate = node->pstate; dsa_area *dsa = node->ss.ps.state->es_query_dsa; + /* If there's no DSA, there are no workers; do nothing. */ + if (dsa == NULL) + return; + pstate->state = BM_INITIAL; if (DsaPointerIsValid(pstate->tbmiterator)) @@ -1019,6 +1028,8 @@ ExecBitmapHeapInitializeWorker(BitmapHeapScanState *node, shm_toc *toc) ParallelBitmapHeapState *pstate; Snapshot snapshot; + Assert(node->ss.ps.state->es_query_dsa != NULL); + pstate = shm_toc_lookup(toc, node->ss.ps.plan->plan_node_id, false); node->pstate = pstate; |