1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

Revert "Get rid of the "new" and "old" entries in a view's rangetable."

This reverts commit 1b4d280ea1.
It's broken the buildfarm members that run cross-version-upgrade tests,
because they're not prepared to deal with cosmetic differences between
CREATE VIEW commands emitted by older servers and HEAD.  Even if we had
a solution to that, which we don't, it'd take some time to roll it out
to the affected animals.  This improvement isn't valuable enough to
justify addressing that problem on an emergency basis, so revert it
for now.
This commit is contained in:
Tom Lane
2023-01-11 22:56:34 -05:00
parent 5a26c7b310
commit f0e6d6d3c9
34 changed files with 890 additions and 774 deletions

View File

@ -405,15 +405,13 @@ add_rtes_to_flat_rtable(PlannerInfo *root, bool recursing)
*
* At top level, we must add all RTEs so that their indexes in the
* flattened rangetable match up with their original indexes. When
* recursing, we only care about extracting relation RTEs (and subquery
* RTEs that were once relation RTEs).
* recursing, we only care about extracting relation RTEs.
*/
foreach(lc, root->parse->rtable)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
if (!recursing || rte->rtekind == RTE_RELATION ||
(rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid)))
if (!recursing || rte->rtekind == RTE_RELATION)
add_rte_to_flat_rtable(glob, root->parse->rteperminfos, rte);
}
@ -503,9 +501,8 @@ flatten_rtes_walker(Node *node, flatten_rtes_walker_context *cxt)
{
RangeTblEntry *rte = (RangeTblEntry *) node;
/* As above, we need only save relation RTEs and former relations */
if (rte->rtekind == RTE_RELATION ||
(rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid)))
/* As above, we need only save relation RTEs */
if (rte->rtekind == RTE_RELATION)
add_rte_to_flat_rtable(cxt->glob, cxt->query->rteperminfos, rte);
return false;
}
@ -563,8 +560,7 @@ add_rte_to_flat_rtable(PlannerGlobal *glob, List *rteperminfos,
glob->finalrtable = lappend(glob->finalrtable, newrte);
/*
* If it's a plain relation RTE (or a subquery that was once a view
* reference), add the relation OID to relationOids.
* If it's a plain relation RTE, add the table to relationOids.
*
* We do this even though the RTE might be unreferenced in the plan tree;
* this would correspond to cases such as views that were expanded, child
@ -574,8 +570,7 @@ add_rte_to_flat_rtable(PlannerGlobal *glob, List *rteperminfos,
* Note we don't bother to avoid making duplicate list entries. We could,
* but it would probably cost more cycles than it would save.
*/
if (newrte->rtekind == RTE_RELATION ||
(newrte->rtekind == RTE_SUBQUERY && OidIsValid(newrte->relid)))
if (newrte->rtekind == RTE_RELATION)
glob->relationOids = lappend_oid(glob->relationOids, newrte->relid);
/*
@ -3408,11 +3403,14 @@ extract_query_dependencies_walker(Node *node, PlannerInfo *context)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
if (rte->rtekind == RTE_RELATION ||
(rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid)) ||
(rte->rtekind == RTE_NAMEDTUPLESTORE && OidIsValid(rte->relid)))
if (rte->rtekind == RTE_RELATION)
context->glob->relationOids =
lappend_oid(context->glob->relationOids, rte->relid);
else if (rte->rtekind == RTE_NAMEDTUPLESTORE &&
OidIsValid(rte->relid))
context->glob->relationOids =
lappend_oid(context->glob->relationOids,
rte->relid);
}
/* And recurse into the query's subexpressions */