* The following function "steals" ideas and most of the code from the * function bring_to_outer_query. * * Decorate the Paths of 'rel' with Motions to bring the relation's * result to SingleQE locus. The final plan will look something like * this: * * Result (with quals from 'outer_quals') * \ * \_Material * \ * \_ Gather *
| 594 | * \_SeqScan (with quals from 'baserestrictinfo') |
| 595 | */ |
| 596 | static void |
| 597 | bring_to_singleQE(PlannerInfo *root, RelOptInfo *rel) |
| 598 | { |
| 599 | List *origpathlist; |
| 600 | ListCell *lc; |
| 601 | |
| 602 | origpathlist = rel->pathlist; |
| 603 | rel->cheapest_startup_path = NULL; |
| 604 | rel->cheapest_total_path = NULL; |
| 605 | rel->cheapest_unique_path = NULL; |
| 606 | rel->cheapest_parameterized_paths = NIL; |
| 607 | rel->pathlist = NIL; |
| 608 | |
| 609 | foreach(lc, origpathlist) |
| 610 | { |
| 611 | Path *origpath = (Path *) lfirst(lc); |
| 612 | Path *path; |
| 613 | CdbPathLocus target_locus; |
| 614 | |
| 615 | if (CdbPathLocus_IsGeneral(origpath->locus) || |
| 616 | CdbPathLocus_IsEntry(origpath->locus) || |
| 617 | CdbPathLocus_IsSingleQE(origpath->locus) || |
| 618 | CdbPathLocus_IsOuterQuery(origpath->locus)) |
| 619 | path = origpath; |
| 620 | else |
| 621 | { |
| 622 | /* |
| 623 | * Cannot pass a param through motion, so if this is a parameterized |
| 624 | * path, we can't use it. |
| 625 | */ |
| 626 | if (origpath->param_info) |
| 627 | continue; |
| 628 | |
| 629 | /* |
| 630 | * param_info cannot cover the case that an index path's orderbyclauses |
| 631 | * See github issue: https://github.com/greenplum-db/gpdb/issues/9733 |
| 632 | */ |
| 633 | if (IsA(origpath, IndexPath)) |
| 634 | { |
| 635 | IndexPath *ipath = (IndexPath *) origpath; |
| 636 | if (contains_outer_params((Node *) ipath->indexorderbys, |
| 637 | (void *) root)) |
| 638 | continue; |
| 639 | } |
| 640 | |
| 641 | CdbPathLocus_MakeSingleQE(&target_locus, |
| 642 | origpath->locus.numsegments); |
| 643 | |
| 644 | path = cdbpath_create_motion_path(root, |
| 645 | origpath, |
| 646 | NIL, // DESTROY pathkeys |
| 647 | false, |
| 648 | target_locus); |
| 649 | |
| 650 | path = (Path *) create_material_path(rel, path); |
| 651 | } |
| 652 | |
| 653 | add_path(rel, path, root); |
no test coverage detected