| Line | Hits | Source | Commit |
| 2473 |
- |
perform_pullup_replace_vars(PlannerInfo *root, |
- |
| 2474 |
- |
pullup_replace_vars_context *rvcontext, |
- |
| 2475 |
- |
AppendRelInfo *containing_appendrel) |
- |
| 2476 |
- |
{ |
- |
| 2477 |
- |
Query *parse = root->parse; |
- |
| 2478 |
- |
ListCell *lc; |
- |
| 2479 |
- |
|
- |
| 2480 |
- |
/* |
- |
| 2481 |
- |
* If we are considering an appendrel child subquery (that is, a UNION ALL |
- |
| 2482 |
- |
* member query that we're pulling up), then the only part of the upper |
- |
| 2483 |
- |
* query that could reference the child yet is the translated_vars list of |
- |
| 2484 |
- |
* the associated AppendRelInfo. Furthermore, we do not want to force use |
- |
| 2485 |
- |
* of PHVs in the AppendRelInfo --- there isn't any outer join between. |
- |
| 2486 |
- |
*/ |
- |
| 2487 |
- |
if (containing_appendrel) |
- |
| 2488 |
- |
{ |
- |
| 2489 |
- |
ReplaceWrapOption save_wrap_option = rvcontext->wrap_option; |
- |
| 2490 |
- |
|
- |
| 2491 |
- |
rvcontext->wrap_option = REPLACE_WRAP_NONE; |
- |
| 2492 |
- |
containing_appendrel->translated_vars = (List *) |
- |
| 2493 |
- |
pullup_replace_vars((Node *) containing_appendrel->translated_vars, |
- |
| 2494 |
- |
rvcontext); |
- |
| 2495 |
- |
rvcontext->wrap_option = save_wrap_option; |
- |
| 2496 |
- |
return; |
- |
| 2497 |
- |
} |
- |
| 2498 |
- |
|
- |
| 2499 |
- |
/* |
- |
| 2500 |
- |
* Replace all of the top query's references to the subquery's outputs |
- |
| 2501 |
- |
* with copies of the adjusted subtlist items, being careful not to |
- |
| 2502 |
- |
* replace any of the jointree structure. (This'd be a lot cleaner if we |
- |
| 2503 |
- |
* could use query_tree_mutator.) We have to use PHVs in the targetList, |
- |
| 2504 |
- |
* returningList, and havingQual, since those are certainly above any |
- |
| 2505 |
- |
* outer join. replace_vars_in_jointree tracks its location in the |
- |
| 2506 |
- |
* jointree and uses PHVs or not appropriately. |
- |
| 2507 |
- |
*/ |
- |
| 2508 |
- |
parse->targetList = (List *) |
- |
| 2509 |
- |
pullup_replace_vars((Node *) parse->targetList, rvcontext); |
- |
| 2510 |
- |
parse->returningList = (List *) |
- |
| 2511 |
- |
pullup_replace_vars((Node *) parse->returningList, rvcontext); |
- |
| 2512 |
- |
|
- |
| 2513 |
18134 |
foreach(lc, parse->windowClause) |
e33632aRow pattern recognition patch (planner). |
| 2514 |
- |
{ |
e33632aRow pattern recognition patch (planner). |
| 2515 |
226 |
WindowClause *wc = lfirst_node(WindowClause, lc); |
e33632aRow pattern recognition patch (planner). |
| 2516 |
- |
|
e33632aRow pattern recognition patch (planner). |
| 2517 |
226 |
if (wc->defineClause != NIL) |
e33632aRow pattern recognition patch (planner). |
| 2518 |
3 |
wc->defineClause = (List *) |
e33632aRow pattern recognition patch (planner). |
| 2519 |
3 |
pullup_replace_vars((Node *) wc->defineClause, rvcontext); |
e33632aRow pattern recognition patch (planner). |
| 2520 |
- |
} |
e33632aRow pattern recognition patch (planner). |
| 2521 |
- |
|
e33632aRow pattern recognition patch (planner). |
| 2522 |
- |
if (parse->onConflict) |
- |
| 2523 |
- |
{ |
- |
| 2524 |
- |
parse->onConflict->onConflictSet = (List *) |
- |
| 2525 |
- |
pullup_replace_vars((Node *) parse->onConflict->onConflictSet, |
- |
| 2526 |
- |
rvcontext); |
- |
| 2527 |
- |
parse->onConflict->onConflictWhere = |
- |
| 2528 |
- |
pullup_replace_vars(parse->onConflict->onConflictWhere, |
- |
| 2529 |
- |
rvcontext); |
- |
| 2530 |
- |
|
- |
| 2531 |
- |
/* |
- |
| 2532 |
- |
* We assume ON CONFLICT's arbiterElems, arbiterWhere, exclRelTlist |
- |
| 2533 |
- |
* can't contain any references to a subquery. |
- |
| 2534 |
- |
*/ |
- |
| 2535 |
- |
} |
- |
| 2536 |
- |
if (parse->mergeActionList) |
- |
| 2537 |
- |
{ |
- |
| 2538 |
- |
foreach(lc, parse->mergeActionList) |
- |
| 2539 |
- |
{ |
- |
| 2540 |
- |
MergeAction *action = lfirst(lc); |
- |
| 2541 |
- |
|
- |
| 2542 |
- |
action->qual = pullup_replace_vars(action->qual, rvcontext); |
- |
| 2543 |
- |
action->targetList = (List *) |
- |
| 2544 |
- |
pullup_replace_vars((Node *) action->targetList, rvcontext); |
- |
| 2545 |
- |
} |
- |
| 2546 |
- |
} |
- |
| 2547 |
- |
parse->mergeJoinCondition = pullup_replace_vars(parse->mergeJoinCondition, |
- |
| 2548 |
- |
rvcontext); |
- |
| 2549 |
- |
replace_vars_in_jointree((Node *) parse->jointree, rvcontext); |
- |
| 2550 |
- |
Assert(parse->setOperations == NULL); |
- |
| 2551 |
- |
parse->havingQual = pullup_replace_vars(parse->havingQual, rvcontext); |
- |
| 2552 |
- |
|
- |
| 2553 |
- |
/* |
- |
| 2554 |
- |
* Replace references in the translated_vars lists of appendrels. |
- |
| 2555 |
- |
*/ |
- |
| 2556 |
- |
foreach(lc, root->append_rel_list) |
- |
| 2557 |
- |
{ |
- |
| 2558 |
- |
AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(lc); |
- |
| 2559 |
- |
|
- |
| 2560 |
- |
appinfo->translated_vars = (List *) |
- |
| 2561 |
- |
pullup_replace_vars((Node *) appinfo->translated_vars, rvcontext); |
- |
| 2562 |
- |
} |
- |
| 2563 |
- |
|
- |
| 2564 |
- |
/* |
- |
| 2565 |
- |
* Replace references in the joinaliasvars lists of join RTEs and the |
- |
| 2566 |
- |
* groupexprs list of group RTE. |
- |
| 2567 |
- |
*/ |
- |
| 2568 |
- |
foreach(lc, parse->rtable) |
- |
| 2569 |
- |
{ |
- |
| 2570 |
- |
RangeTblEntry *otherrte = (RangeTblEntry *) lfirst(lc); |
- |
| 2571 |
- |
|
- |
| 2572 |
- |
if (otherrte->rtekind == RTE_JOIN) |
- |
| 2573 |
- |
otherrte->joinaliasvars = (List *) |
- |
| 2574 |
- |
pullup_replace_vars((Node *) otherrte->joinaliasvars, |
- |
| 2575 |
- |
rvcontext); |
- |
| 2576 |
- |
else if (otherrte->rtekind == RTE_GROUP) |
- |
| 2577 |
- |
otherrte->groupexprs = (List *) |
- |
| 2578 |
- |
pullup_replace_vars((Node *) otherrte->groupexprs, |
- |
| 2579 |
- |
rvcontext); |
- |
| 2580 |
- |
} |
- |
| 2581 |
- |
} |
- |