Remove bogus code to apply PathTargets to partial paths.
authorRobert Haas <rhaas@postgresql.org>
Fri, 3 Jun 2016 18:27:33 +0000 (14:27 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 3 Jun 2016 18:27:33 +0000 (14:27 -0400)
The partial paths that get modified may already have been used as
part of a GatherPath which appears in the path list, so modifying
them is not a good idea at this stage - especially because this
code has no check that the PathTarget is in fact parallel-safe.

When partial aggregation is being performed, this is actually
harmless because we'll end up replacing the pathtargets here with
the correct ones within create_grouping_paths().  But if we've got
a query tree containing only scan/join operations then this can
result in incorrectly pushing down parallel-restricted target
list entries.  If those are, for example, references to subqueries,
that can crash the server; but it's wrong in any event.

Amit Kapila

src/backend/optimizer/plan/planner.c

index 75d93c08db2f8b77a42b77094570b0dad066ef38..b1554cb8390373a64c4c57b25a1cecc9201fb51d 100644 (file)
@@ -1758,19 +1758,6 @@ grouping_planner(PlannerInfo *root, bool inheritance_update,
            }
        }
 
-       /*
-        * Likewise for any partial paths, although this case is simpler, since
-        * we don't track the cheapest path.
-        */
-       foreach(lc, current_rel->partial_pathlist)
-       {
-           Path       *subpath = (Path *) lfirst(lc);
-
-           Assert(subpath->param_info == NULL);
-           lfirst(lc) = apply_projection_to_path(root, current_rel,
-                                           subpath, scanjoin_target);
-       }
-
        /*
         * Save the various upper-rel PathTargets we just computed into
         * root->upper_targets[].  The core code doesn't use this, but it