* Decorate the Paths of 'rel' with Motions to bring the relation's * result to OuterQuery locus. The final plan will look something like * this: * * Result (with quals from 'outer_quals') * \ * \_Material * \ * \_Broadcast (or Gather) * \ * \_SeqScan (with quals from 'baserest
| 512 | * \_SeqScan (with quals from 'baserestrictinfo') |
| 513 | */ |
| 514 | static void |
| 515 | bring_to_outer_query(PlannerInfo *root, RelOptInfo *rel, List *outer_quals) |
| 516 | { |
| 517 | List *origpathlist; |
| 518 | ListCell *lc; |
| 519 | |
| 520 | origpathlist = rel->pathlist; |
| 521 | rel->cheapest_startup_path = NULL; |
| 522 | rel->cheapest_total_path = NULL; |
| 523 | rel->cheapest_unique_path = NULL; |
| 524 | rel->cheapest_parameterized_paths = NIL; |
| 525 | rel->pathlist = NIL; |
| 526 | /* CBDB_PARALLEL_FIXME: Need to clear partial_pathlist before we enable OuterQuery locus in paralle mode */ |
| 527 | rel->partial_pathlist = NIL; |
| 528 | |
| 529 | foreach(lc, origpathlist) |
| 530 | { |
| 531 | Path *origpath = (Path *) lfirst(lc); |
| 532 | Path *path; |
| 533 | CdbPathLocus outerquery_locus; |
| 534 | |
| 535 | if (CdbPathLocus_IsGeneral(origpath->locus) || |
| 536 | CdbPathLocus_IsOuterQuery(origpath->locus)) |
| 537 | path = origpath; |
| 538 | else |
| 539 | { |
| 540 | /* |
| 541 | * Cannot pass a param through motion, so if this is a parameterized |
| 542 | * path, we can't use it. |
| 543 | */ |
| 544 | if (origpath->param_info) |
| 545 | continue; |
| 546 | |
| 547 | /* |
| 548 | * param_info cannot cover the case that an index path's orderbyclauses |
| 549 | * See github issue: https://github.com/greenplum-db/gpdb/issues/9733 |
| 550 | */ |
| 551 | if (IsA(origpath, IndexPath)) |
| 552 | { |
| 553 | IndexPath *ipath = (IndexPath *) origpath; |
| 554 | if (contains_outer_params((Node *) ipath->indexorderbys, |
| 555 | (void *) root)) |
| 556 | continue; |
| 557 | } |
| 558 | |
| 559 | CdbPathLocus_MakeOuterQuery(&outerquery_locus); |
| 560 | |
| 561 | path = cdbpath_create_motion_path(root, |
| 562 | origpath, |
| 563 | NIL, // DESTROY pathkeys |
| 564 | false, |
| 565 | outerquery_locus); |
| 566 | } |
| 567 | |
| 568 | if (outer_quals) |
| 569 | path = (Path *) create_projection_path_with_quals(root, |
| 570 | rel, |
| 571 | path, |
no test coverage detected