OSDN Git Service

Fix a bug of Parallel hint
authorKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Thu, 18 May 2017 01:28:49 +0000 (10:28 +0900)
committerKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Thu, 18 May 2017 09:45:25 +0000 (18:45 +0900)
During manipulation on pathlist of a GatherPath, foreach was mitakenly
used for a loop using list_delete_cell. This leads to a crash with
SEGV.

pg_hint_plan.c

index 477c1f1..04540a5 100644 (file)
@@ -4405,12 +4405,13 @@ pg_hint_plan_set_rel_pathlist(PlannerInfo * root, RelOptInfo *rel,
                /* also remove gather path */
                if (rel->pathlist)
                {
-                       ListCell *cell, *prev = NULL;
+                       ListCell *cell, *prev = NULL, *next;
 
-                       foreach (cell, rel->pathlist)
+                       for (cell = list_head(rel->pathlist) ; cell; cell = next)
                        {
                                Path *path = (Path *) lfirst(cell);
-                               
+
+                               next = lnext(cell);
                                if (IsA(path, GatherPath))
                                        rel->pathlist = list_delete_cell(rel->pathlist,
                                                                                                         cell, prev);