| Line | Hits | Source | Commit |
| 2559 |
- |
set_upper_references(PlannerInfo *root, Plan *plan, int rtoffset) |
- |
| 2560 |
- |
{ |
- |
| 2561 |
- |
Plan *subplan = plan->lefttree; |
- |
| 2562 |
- |
indexed_tlist *subplan_itlist; |
- |
| 2563 |
- |
List *output_targetlist; |
- |
| 2564 |
- |
ListCell *l; |
- |
| 2565 |
- |
|
- |
| 2566 |
- |
subplan_itlist = build_tlist_index(subplan->targetlist); |
- |
| 2567 |
- |
|
- |
| 2568 |
- |
/* |
- |
| 2569 |
- |
* If it's a grouping node with grouping sets, any Vars and PHVs appearing |
- |
| 2570 |
- |
* in the targetlist and quals should have nullingrels that include the |
- |
| 2571 |
- |
* effects of the grouping step, ie they will have nullingrels equal to |
- |
| 2572 |
- |
* the input Vars/PHVs' nullingrels plus the RT index of the grouping |
- |
| 2573 |
- |
* step. In order to perform exact nullingrels matches, we remove the RT |
- |
| 2574 |
- |
* index of the grouping step first. |
- |
| 2575 |
- |
*/ |
- |
| 2576 |
- |
if (IsA(plan, Agg) && |
- |
| 2577 |
- |
root->group_rtindex > 0 && |
- |
| 2578 |
- |
((Agg *) plan)->groupingSets) |
- |
| 2579 |
- |
{ |
- |
| 2580 |
- |
plan->targetlist = (List *) |
- |
| 2581 |
- |
remove_nulling_relids((Node *) plan->targetlist, |
- |
| 2582 |
- |
bms_make_singleton(root->group_rtindex), |
- |
| 2583 |
- |
NULL); |
- |
| 2584 |
- |
plan->qual = (List *) |
- |
| 2585 |
- |
remove_nulling_relids((Node *) plan->qual, |
- |
| 2586 |
- |
bms_make_singleton(root->group_rtindex), |
- |
| 2587 |
- |
NULL); |
- |
| 2588 |
- |
} |
- |
| 2589 |
- |
|
- |
| 2590 |
- |
output_targetlist = NIL; |
- |
| 2591 |
- |
foreach(l, plan->targetlist) |
- |
| 2592 |
- |
{ |
- |
| 2593 |
- |
TargetEntry *tle = (TargetEntry *) lfirst(l); |
- |
| 2594 |
- |
Node *newexpr; |
- |
| 2595 |
- |
|
- |
| 2596 |
- |
/* If it's a sort/group item, first try to match by sortref */ |
- |
| 2597 |
- |
if (tle->ressortgroupref != 0) |
- |
| 2598 |
- |
{ |
- |
| 2599 |
- |
newexpr = (Node *) |
- |
| 2600 |
- |
search_indexed_tlist_for_sortgroupref(tle->expr, |
- |
| 2601 |
- |
tle->ressortgroupref, |
- |
| 2602 |
- |
subplan_itlist, |
- |
| 2603 |
- |
OUTER_VAR); |
- |
| 2604 |
- |
if (!newexpr) |
- |
| 2605 |
- |
newexpr = fix_upper_expr(root, |
- |
| 2606 |
- |
(Node *) tle->expr, |
- |
| 2607 |
- |
subplan_itlist, |
- |
| 2608 |
- |
OUTER_VAR, |
- |
| 2609 |
- |
rtoffset, |
- |
| 2610 |
- |
NRM_EQUAL, |
- |
| 2611 |
- |
NUM_EXEC_TLIST(plan)); |
- |
| 2612 |
- |
} |
- |
| 2613 |
- |
else |
- |
| 2614 |
- |
newexpr = fix_upper_expr(root, |
- |
| 2615 |
- |
(Node *) tle->expr, |
- |
| 2616 |
- |
subplan_itlist, |
- |
| 2617 |
- |
OUTER_VAR, |
- |
| 2618 |
- |
rtoffset, |
- |
| 2619 |
- |
NRM_EQUAL, |
- |
| 2620 |
- |
NUM_EXEC_TLIST(plan)); |
- |
| 2621 |
- |
tle = flatCopyTargetEntry(tle); |
- |
| 2622 |
- |
tle->expr = (Expr *) newexpr; |
- |
| 2623 |
- |
output_targetlist = lappend(output_targetlist, tle); |
- |
| 2624 |
- |
} |
- |
| 2625 |
- |
plan->targetlist = output_targetlist; |
- |
| 2626 |
- |
|
- |
| 2627 |
- |
plan->qual = (List *) |
- |
| 2628 |
- |
fix_upper_expr(root, |
- |
| 2629 |
- |
(Node *) plan->qual, |
- |
| 2630 |
- |
subplan_itlist, |
- |
| 2631 |
- |
OUTER_VAR, |
- |
| 2632 |
- |
rtoffset, |
- |
| 2633 |
- |
NRM_EQUAL, |
- |
| 2634 |
- |
NUM_EXEC_QUAL(plan)); |
- |
| 2635 |
- |
|
- |
| 2636 |
- |
/* |
7521a30Row pattern recognition patch (planner). |
| 2637 |
- |
* Replace an expression tree in each DEFINE clause so that all Var |
7521a30Row pattern recognition patch (planner). |
| 2638 |
- |
* nodes's varno refers to OUTER_VAR. |
7521a30Row pattern recognition patch (planner). |
| 2639 |
- |
*/ |
7521a30Row pattern recognition patch (planner). |
| 2640 |
64548 |
if (IsA(plan, WindowAgg)) |
7521a30Row pattern recognition patch (planner). |
| 2641 |
- |
{ |
7521a30Row pattern recognition patch (planner). |
| 2642 |
6182 |
WindowAgg *wplan = (WindowAgg *) plan; |
7521a30Row pattern recognition patch (planner). |
| 2643 |
- |
|
7521a30Row pattern recognition patch (planner). |
| 2644 |
6182 |
if (wplan->defineClause != NIL) |
7521a30Row pattern recognition patch (planner). |
| 2645 |
- |
{ |
7521a30Row pattern recognition patch (planner). |
| 2646 |
12380 |
foreach(l, wplan->defineClause) |
7521a30Row pattern recognition patch (planner). |
| 2647 |
- |
{ |
7521a30Row pattern recognition patch (planner). |
| 2648 |
8655 |
TargetEntry *tle = (TargetEntry *) lfirst(l); |
7521a30Row pattern recognition patch (planner). |
| 2649 |
- |
|
7521a30Row pattern recognition patch (planner). |
| 2650 |
8655 |
tle = flatCopyTargetEntry(tle); |
7521a30Row pattern recognition patch (planner). |
| 2651 |
17310 |
tle->expr = (Expr *) |
7521a30Row pattern recognition patch (planner). |
| 2652 |
8655 |
fix_upper_expr(root, |
7521a30Row pattern recognition patch (planner). |
| 2653 |
8655 |
(Node *) tle->expr, |
7521a30Row pattern recognition patch (planner). |
| 2654 |
- |
subplan_itlist, |
7521a30Row pattern recognition patch (planner). |
| 2655 |
- |
OUTER_VAR, |
7521a30Row pattern recognition patch (planner). |
| 2656 |
- |
rtoffset, |
7521a30Row pattern recognition patch (planner). |
| 2657 |
- |
NRM_EQUAL, |
7521a30Row pattern recognition patch (planner). |
| 2658 |
8655 |
NUM_EXEC_QUAL(plan)); |
7521a30Row pattern recognition patch (planner). |
| 2659 |
8655 |
lfirst(l) = tle; |
7521a30Row pattern recognition patch (planner). |
| 2660 |
- |
} |
7521a30Row pattern recognition patch (planner). |
| 2661 |
- |
} |
7521a30Row pattern recognition patch (planner). |
| 2662 |
- |
} |
7521a30Row pattern recognition patch (planner). |
| 2663 |
- |
|
7521a30Row pattern recognition patch (planner). |
| 2664 |
- |
pfree(subplan_itlist); |
- |
| 2665 |
- |
} |
- |