Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c64ddd

Browse files
committed
Fix Parallel Append crash.
Reported by Tom Lane and the buildfarm. Amul Sul and Amit Khandekar Discussion: http://postgr.es/m/[email protected] Discussion: http://postgr.es/m/CAJ3gD9cJQ4d-XhmZ6BqM9rMM2KDBfpkdgOAb4+psz56uBuMQ_A@mail.gmail.com
1 parent 979a36c commit 9c64ddd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/backend/executor/nodeAppend.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,16 @@ choose_next_subplan_for_worker(AppendState *node)
506506
node->as_whichplan = pstate->pa_next_plan++;
507507
if (pstate->pa_next_plan >= node->as_nplans)
508508
{
509-
Assert(append->first_partial_plan < node->as_nplans);
510-
pstate->pa_next_plan = append->first_partial_plan;
509+
if (append->first_partial_plan < node->as_nplans)
510+
pstate->pa_next_plan = append->first_partial_plan;
511+
else
512+
{
513+
/*
514+
* We have only non-partial plans, and we already chose the last
515+
* one; so arrange for the other workers to immediately bail out.
516+
*/
517+
pstate->pa_next_plan = INVALID_SUBPLAN_INDEX;
518+
}
511519
}
512520

513521
/* If non-partial, immediately mark as finished. */

0 commit comments

Comments
 (0)