| Line | Hits | Source | Commit |
| 2501 |
- |
set_upper_references(PlannerInfo *root, Plan *plan, int rtoffset) |
- |
| 2502 |
- |
{ |
- |
| 2503 |
- |
Plan *subplan = plan->lefttree; |
- |
| 2504 |
- |
indexed_tlist *subplan_itlist; |
- |
| 2505 |
- |
List *output_targetlist; |
- |
| 2506 |
- |
ListCell *l; |
- |
| 2507 |
- |
|
- |
| 2508 |
- |
subplan_itlist = build_tlist_index(subplan->targetlist); |
- |
| 2509 |
- |
|
- |
| 2510 |
- |
/* |
- |
| 2511 |
- |
* If it's a grouping node with grouping sets, any Vars and PHVs appearing |
- |
| 2512 |
- |
* in the targetlist and quals should have nullingrels that include the |
- |
| 2513 |
- |
* effects of the grouping step, ie they will have nullingrels equal to |
- |
| 2514 |
- |
* the input Vars/PHVs' nullingrels plus the RT index of the grouping |
- |
| 2515 |
- |
* step. In order to perform exact nullingrels matches, we remove the RT |
- |
| 2516 |
- |
* index of the grouping step first. |
- |
| 2517 |
- |
*/ |
- |
| 2518 |
- |
if (IsA(plan, Agg) && |
- |
| 2519 |
- |
root->group_rtindex > 0 && |
- |
| 2520 |
- |
((Agg *) plan)->groupingSets) |
- |
| 2521 |
- |
{ |
- |
| 2522 |
- |
plan->targetlist = (List *) |
- |
| 2523 |
- |
remove_nulling_relids((Node *) plan->targetlist, |
- |
| 2524 |
- |
bms_make_singleton(root->group_rtindex), |
- |
| 2525 |
- |
NULL); |
- |
| 2526 |
- |
plan->qual = (List *) |
- |
| 2527 |
- |
remove_nulling_relids((Node *) plan->qual, |
- |
| 2528 |
- |
bms_make_singleton(root->group_rtindex), |
- |
| 2529 |
- |
NULL); |
- |
| 2530 |
- |
} |
- |
| 2531 |
- |
|
- |
| 2532 |
- |
output_targetlist = NIL; |
- |
| 2533 |
- |
foreach(l, plan->targetlist) |
- |
| 2534 |
- |
{ |
- |
| 2535 |
- |
TargetEntry *tle = (TargetEntry *) lfirst(l); |
- |
| 2536 |
- |
Node *newexpr; |
- |
| 2537 |
- |
|
- |
| 2538 |
- |
/* If it's a sort/group item, first try to match by sortref */ |
- |
| 2539 |
- |
if (tle->ressortgroupref != 0) |
- |
| 2540 |
- |
{ |
- |
| 2541 |
- |
newexpr = (Node *) |
- |
| 2542 |
- |
search_indexed_tlist_for_sortgroupref(tle->expr, |
- |
| 2543 |
- |
tle->ressortgroupref, |
- |
| 2544 |
- |
subplan_itlist, |
- |
| 2545 |
- |
OUTER_VAR); |
- |
| 2546 |
- |
if (!newexpr) |
- |
| 2547 |
- |
newexpr = fix_upper_expr(root, |
- |
| 2548 |
- |
(Node *) tle->expr, |
- |
| 2549 |
- |
subplan_itlist, |
- |
| 2550 |
- |
OUTER_VAR, |
- |
| 2551 |
- |
rtoffset, |
- |
| 2552 |
- |
NRM_EQUAL, |
- |
| 2553 |
- |
NUM_EXEC_TLIST(plan)); |
- |
| 2554 |
- |
} |
- |
| 2555 |
- |
else |
- |
| 2556 |
- |
newexpr = fix_upper_expr(root, |
- |
| 2557 |
- |
(Node *) tle->expr, |
- |
| 2558 |
- |
subplan_itlist, |
- |
| 2559 |
- |
OUTER_VAR, |
- |
| 2560 |
- |
rtoffset, |
- |
| 2561 |
- |
NRM_EQUAL, |
- |
| 2562 |
- |
NUM_EXEC_TLIST(plan)); |
- |
| 2563 |
- |
tle = flatCopyTargetEntry(tle); |
- |
| 2564 |
- |
tle->expr = (Expr *) newexpr; |
- |
| 2565 |
- |
output_targetlist = lappend(output_targetlist, tle); |
- |
| 2566 |
- |
} |
- |
| 2567 |
- |
plan->targetlist = output_targetlist; |
- |
| 2568 |
- |
|
- |
| 2569 |
- |
plan->qual = (List *) |
- |
| 2570 |
- |
fix_upper_expr(root, |
- |
| 2571 |
- |
(Node *) plan->qual, |
- |
| 2572 |
- |
subplan_itlist, |
- |
| 2573 |
- |
OUTER_VAR, |
- |
| 2574 |
- |
rtoffset, |
- |
| 2575 |
- |
NRM_EQUAL, |
- |
| 2576 |
- |
NUM_EXEC_QUAL(plan)); |
- |
| 2577 |
- |
|
- |
| 2578 |
- |
/* |
e33632aRow pattern recognition patch (planner). |
| 2579 |
- |
* Modifies an expression tree in each DEFINE clause so that all Var |
e33632aRow pattern recognition patch (planner). |
| 2580 |
- |
* nodes's varno refers to OUTER_VAR. |
e33632aRow pattern recognition patch (planner). |
| 2581 |
- |
*/ |
e33632aRow pattern recognition patch (planner). |
| 2582 |
37870 |
if (IsA(plan, WindowAgg)) |
e33632aRow pattern recognition patch (planner). |
| 2583 |
- |
{ |
e33632aRow pattern recognition patch (planner). |
| 2584 |
1453 |
WindowAgg *wplan = (WindowAgg *) plan; |
e33632aRow pattern recognition patch (planner). |
| 2585 |
- |
|
e33632aRow pattern recognition patch (planner). |
| 2586 |
1453 |
if (wplan->defineClause != NIL) |
e33632aRow pattern recognition patch (planner). |
| 2587 |
- |
{ |
e33632aRow pattern recognition patch (planner). |
| 2588 |
243 |
foreach(l, wplan->defineClause) |
e33632aRow pattern recognition patch (planner). |
| 2589 |
- |
{ |
e33632aRow pattern recognition patch (planner). |
| 2590 |
171 |
TargetEntry *tle = (TargetEntry *) lfirst(l); |
e33632aRow pattern recognition patch (planner). |
| 2591 |
- |
|
e33632aRow pattern recognition patch (planner). |
| 2592 |
171 |
tle->expr = (Expr *) |
e33632aRow pattern recognition patch (planner). |
| 2593 |
171 |
fix_upper_expr(root, |
e33632aRow pattern recognition patch (planner). |
| 2594 |
171 |
(Node *) tle->expr, |
e33632aRow pattern recognition patch (planner). |
| 2595 |
- |
subplan_itlist, |
e33632aRow pattern recognition patch (planner). |
| 2596 |
- |
OUTER_VAR, |
e33632aRow pattern recognition patch (planner). |
| 2597 |
- |
rtoffset, |
e33632aRow pattern recognition patch (planner). |
| 2598 |
- |
NRM_EQUAL, |
e33632aRow pattern recognition patch (planner). |
| 2599 |
171 |
NUM_EXEC_QUAL(plan)); |
e33632aRow pattern recognition patch (planner). |
| 2600 |
- |
} |
e33632aRow pattern recognition patch (planner). |
| 2601 |
- |
} |
e33632aRow pattern recognition patch (planner). |
| 2602 |
- |
} |
e33632aRow pattern recognition patch (planner). |
| 2603 |
- |
|
e33632aRow pattern recognition patch (planner). |
| 2604 |
- |
pfree(subplan_itlist); |
- |
| 2605 |
- |
} |
- |