@@ -2368,9 +2368,9 @@ create_projection_path(PlannerInfo *root,
2368
2368
* knows that the given path isn't referenced elsewhere and so can be modified
2369
2369
* in-place.
2370
2370
*
2371
- * If the input path is a GatherPath, we try to push the new target down to
2372
- * its input as well; this is a yet more invasive modification of the input
2373
- * path, which create_projection_path() can't do.
2371
+ * If the input path is a GatherPath or GatherMergePath , we try to push the
2372
+ * new target down to its input as well; this is a yet more invasive
2373
+ * modification of the input path, which create_projection_path() can't do.
2374
2374
*
2375
2375
* Note that we mustn't change the source path's parent link; so when it is
2376
2376
* add_path'd to "rel" things will be a bit inconsistent. So far that has
@@ -2407,31 +2407,44 @@ apply_projection_to_path(PlannerInfo *root,
2407
2407
(target -> cost .per_tuple - oldcost .per_tuple ) * path -> rows ;
2408
2408
2409
2409
/*
2410
- * If the path happens to be a Gather path, we'd like to arrange for the
2411
- * subpath to return the required target list so that workers can help
2412
- * project. But if there is something that is not parallel-safe in the
2413
- * target expressions, then we can't.
2410
+ * If the path happens to be a Gather or GatherMerge path, we'd like to
2411
+ * arrange for the subpath to return the required target list so that
2412
+ * workers can help project. But if there is something that is not
2413
+ * parallel-safe in the target expressions, then we can't.
2414
2414
*/
2415
- if (IsA (path , GatherPath ) &&
2415
+ if (( IsA (path , GatherPath ) || IsA ( path , GatherMergePath ) ) &&
2416
2416
is_parallel_safe (root , (Node * ) target -> exprs ))
2417
2417
{
2418
- GatherPath * gpath = (GatherPath * ) path ;
2419
-
2420
2418
/*
2421
2419
* We always use create_projection_path here, even if the subpath is
2422
2420
* projection-capable, so as to avoid modifying the subpath in place.
2423
2421
* It seems unlikely at present that there could be any other
2424
2422
* references to the subpath, but better safe than sorry.
2425
2423
*
2426
- * Note that we don't change the GatherPath 's cost estimates; it might
2424
+ * Note that we don't change the parallel path 's cost estimates; it might
2427
2425
* be appropriate to do so, to reflect the fact that the bulk of the
2428
2426
* target evaluation will happen in workers.
2429
2427
*/
2430
- gpath -> subpath = (Path * )
2431
- create_projection_path (root ,
2432
- gpath -> subpath -> parent ,
2433
- gpath -> subpath ,
2434
- target );
2428
+ if (IsA (path , GatherPath ))
2429
+ {
2430
+ GatherPath * gpath = (GatherPath * ) path ;
2431
+
2432
+ gpath -> subpath = (Path * )
2433
+ create_projection_path (root ,
2434
+ gpath -> subpath -> parent ,
2435
+ gpath -> subpath ,
2436
+ target );
2437
+ }
2438
+ else
2439
+ {
2440
+ GatherMergePath * gmpath = (GatherMergePath * ) path ;
2441
+
2442
+ gmpath -> subpath = (Path * )
2443
+ create_projection_path (root ,
2444
+ gmpath -> subpath -> parent ,
2445
+ gmpath -> subpath ,
2446
+ target );
2447
+ }
2435
2448
}
2436
2449
else if (path -> parallel_safe &&
2437
2450
!is_parallel_safe (root , (Node * ) target -> exprs ))
0 commit comments