OSDN Git Service

Don't set_plain_rel_pathlist for other than RTE_RELATION.
authorKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Mon, 13 Feb 2017 08:01:49 +0000 (17:01 +0900)
committerKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Tue, 21 Feb 2017 00:11:44 +0000 (09:11 +0900)
pg_hint_plan_set_rel_pathlist can call set_plain_rel_pathlist for
relations other than RTE_RELATION and this results in a crash.

pg_hint_plan.c

index 5d4bd18..41baf67 100644 (file)
@@ -4348,8 +4348,9 @@ pg_hint_plan_set_rel_pathlist(PlannerInfo * root, RelOptInfo *rel,
        if (!setup_hint_enforcement(root, rel))
        {
                /*
-                * No enforcement requested, but we might have to generate gather
-                * path on this relation
+                * No enforcement requested, but we might have to generate gather path
+                * on this relation. We could regenerate gather for relations not
+                * getting enforcement or even relations other than ordinary ones.
                 */
 
                /* If no need of a gather path, just return */
@@ -4373,6 +4374,10 @@ pg_hint_plan_set_rel_pathlist(PlannerInfo * root, RelOptInfo *rel,
                return;
        }
 
+       /* Don't touch other than ordinary relation hereafter */
+       if (rte->rtekind != RTE_RELATION)
+               return;
+
        /* Here, we regenerate paths with the current hint restriction */
 
        /* Remove prviously generated paths */