| Line | Hits | Source | Commit |
| 2556 |
- |
perform_pullup_replace_vars(PlannerInfo *root, |
- |
| 2557 |
- |
pullup_replace_vars_context *rvcontext, |
- |
| 2558 |
- |
AppendRelInfo *containing_appendrel) |
- |
| 2559 |
- |
{ |
- |
| 2560 |
- |
Query *parse = root->parse; |
- |
| 2561 |
- |
ListCell *lc; |
- |
| 2562 |
- |
|
- |
| 2563 |
- |
/* |
- |
| 2564 |
- |
* If we are considering an appendrel child subquery (that is, a UNION ALL |
- |
| 2565 |
- |
* member query that we're pulling up), then the only part of the upper |
- |
| 2566 |
- |
* query that could reference the child yet is the translated_vars list of |
- |
| 2567 |
- |
* the associated AppendRelInfo. Furthermore, we do not want to force use |
- |
| 2568 |
- |
* of PHVs in the AppendRelInfo --- there isn't any outer join between. |
- |
| 2569 |
- |
*/ |
- |
| 2570 |
- |
if (containing_appendrel) |
- |
| 2571 |
- |
{ |
- |
| 2572 |
- |
ReplaceWrapOption save_wrap_option = rvcontext->wrap_option; |
- |
| 2573 |
- |
|
- |
| 2574 |
- |
rvcontext->wrap_option = REPLACE_WRAP_NONE; |
- |
| 2575 |
- |
containing_appendrel->translated_vars = (List *) |
- |
| 2576 |
- |
pullup_replace_vars((Node *) containing_appendrel->translated_vars, |
- |
| 2577 |
- |
rvcontext); |
- |
| 2578 |
- |
rvcontext->wrap_option = save_wrap_option; |
- |
| 2579 |
- |
return; |
- |
| 2580 |
- |
} |
- |
| 2581 |
- |
|
- |
| 2582 |
- |
/* |
- |
| 2583 |
- |
* Replace all of the top query's references to the subquery's outputs |
- |
| 2584 |
- |
* with copies of the adjusted subtlist items, being careful not to |
- |
| 2585 |
- |
* replace any of the jointree structure. (This'd be a lot cleaner if we |
- |
| 2586 |
- |
* could use query_tree_mutator.) We have to use PHVs in the targetList, |
- |
| 2587 |
- |
* returningList, and havingQual, since those are certainly above any |
- |
| 2588 |
- |
* outer join. replace_vars_in_jointree tracks its location in the |
- |
| 2589 |
- |
* jointree and uses PHVs or not appropriately. |
- |
| 2590 |
- |
*/ |
- |
| 2591 |
- |
parse->targetList = (List *) |
- |
| 2592 |
- |
pullup_replace_vars((Node *) parse->targetList, rvcontext); |
- |
| 2593 |
- |
parse->returningList = (List *) |
- |
| 2594 |
- |
pullup_replace_vars((Node *) parse->returningList, rvcontext); |
- |
| 2595 |
- |
|
- |
| 2596 |
30482 |
foreach_node(WindowClause, wc, parse->windowClause) |
7521a30Row pattern recognition patch (planner). |
| 2597 |
- |
{ |
7521a30Row pattern recognition patch (planner). |
| 2598 |
1223 |
if (wc->defineClause != NIL) |
7521a30Row pattern recognition patch (planner). |
| 2599 |
795 |
wc->defineClause = (List *) |
7521a30Row pattern recognition patch (planner). |
| 2600 |
795 |
pullup_replace_vars((Node *) wc->defineClause, rvcontext); |
7521a30Row pattern recognition patch (planner). |
| 2601 |
- |
} |
7521a30Row pattern recognition patch (planner). |
| 2602 |
- |
|
7521a30Row pattern recognition patch (planner). |
| 2603 |
- |
if (parse->onConflict) |
- |
| 2604 |
- |
{ |
- |
| 2605 |
- |
parse->onConflict->onConflictSet = (List *) |
- |
| 2606 |
- |
pullup_replace_vars((Node *) parse->onConflict->onConflictSet, |
- |
| 2607 |
- |
rvcontext); |
- |
| 2608 |
- |
parse->onConflict->onConflictWhere = |
- |
| 2609 |
- |
pullup_replace_vars(parse->onConflict->onConflictWhere, |
- |
| 2610 |
- |
rvcontext); |
- |
| 2611 |
- |
|
- |
| 2612 |
- |
/* |
- |
| 2613 |
- |
* We assume ON CONFLICT's arbiterElems, arbiterWhere, exclRelTlist |
- |
| 2614 |
- |
* can't contain any references to a subquery. |
- |
| 2615 |
- |
*/ |
- |
| 2616 |
- |
} |
- |
| 2617 |
- |
if (parse->mergeActionList) |
- |
| 2618 |
- |
{ |
- |
| 2619 |
- |
foreach(lc, parse->mergeActionList) |
- |
| 2620 |
- |
{ |
- |
| 2621 |
- |
MergeAction *action = lfirst(lc); |
- |
| 2622 |
- |
|
- |
| 2623 |
- |
action->qual = pullup_replace_vars(action->qual, rvcontext); |
- |
| 2624 |
- |
action->targetList = (List *) |
- |
| 2625 |
- |
pullup_replace_vars((Node *) action->targetList, rvcontext); |
- |
| 2626 |
- |
} |
- |
| 2627 |
- |
} |
- |
| 2628 |
- |
parse->mergeJoinCondition = pullup_replace_vars(parse->mergeJoinCondition, |
- |
| 2629 |
- |
rvcontext); |
- |
| 2630 |
- |
replace_vars_in_jointree((Node *) parse->jointree, rvcontext); |
- |
| 2631 |
- |
Assert(parse->setOperations == NULL); |
- |
| 2632 |
- |
parse->havingQual = pullup_replace_vars(parse->havingQual, rvcontext); |
- |
| 2633 |
- |
|
- |
| 2634 |
- |
/* |
- |
| 2635 |
- |
* Replace references in the translated_vars lists of appendrels. |
- |
| 2636 |
- |
*/ |
- |
| 2637 |
- |
foreach(lc, root->append_rel_list) |
- |
| 2638 |
- |
{ |
- |
| 2639 |
- |
AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(lc); |
- |
| 2640 |
- |
|
- |
| 2641 |
- |
appinfo->translated_vars = (List *) |
- |
| 2642 |
- |
pullup_replace_vars((Node *) appinfo->translated_vars, rvcontext); |
- |
| 2643 |
- |
} |
- |
| 2644 |
- |
|
- |
| 2645 |
- |
/* |
- |
| 2646 |
- |
* Replace references in the joinaliasvars lists of join RTEs and the |
- |
| 2647 |
- |
* groupexprs list of group RTE. |
- |
| 2648 |
- |
*/ |
- |
| 2649 |
- |
foreach(lc, parse->rtable) |
- |
| 2650 |
- |
{ |
- |
| 2651 |
- |
RangeTblEntry *otherrte = (RangeTblEntry *) lfirst(lc); |
- |
| 2652 |
- |
|
- |
| 2653 |
- |
if (otherrte->rtekind == RTE_JOIN) |
- |
| 2654 |
- |
otherrte->joinaliasvars = (List *) |
- |
| 2655 |
- |
pullup_replace_vars((Node *) otherrte->joinaliasvars, |
- |
| 2656 |
- |
rvcontext); |
- |
| 2657 |
- |
else if (otherrte->rtekind == RTE_GROUP) |
- |
| 2658 |
- |
otherrte->groupexprs = (List *) |
- |
| 2659 |
- |
pullup_replace_vars((Node *) otherrte->groupexprs, |
- |
| 2660 |
- |
rvcontext); |
- |
| 2661 |
- |
} |
- |
| 2662 |
- |
} |
- |