Commit 227d57f3 authored by Robert Haas's avatar Robert Haas

Don't dump core when destroying an unused ParallelContext.

If a transaction or subtransaction creates a ParallelContext but ends
without calling InitializeParallelDSM, the previous code would
seg fault.  Fix that.
parent 7d8db3e8
......@@ -513,6 +513,8 @@ DestroyParallelContext(ParallelContext *pcxt)
dlist_delete(&pcxt->node);
/* Kill each worker in turn, and forget their error queues. */
if (pcxt->worker != NULL)
{
for (i = 0; i < pcxt->nworkers; ++i)
{
if (pcxt->worker[i].bgwhandle != NULL)
......@@ -523,6 +525,7 @@ DestroyParallelContext(ParallelContext *pcxt)
pcxt->worker[i].error_mqh = NULL;
}
}
}
/*
* If we have allocated a shared memory segment, detach it. This will
......@@ -550,7 +553,7 @@ DestroyParallelContext(ParallelContext *pcxt)
{
BgwHandleStatus status;
if (pcxt->worker[i].bgwhandle == NULL)
if (pcxt->worker == NULL || pcxt->worker[i].bgwhandle == NULL)
continue;
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment