Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28a7e31

Browse files
committed
Preserve RangeTblEntry.relid when expanding a view RTE.
When the rewriter converts an RTE_RELATION RTE for a view intoan RTE_SUBQUERY RTE containing the view's defining query, leavethe relid field alone instead of zeroing it. This allows theplanner to tell that the subquery came from a view rather thanhaving been written in-line, which is needed to support anupcoming planner bug fix. We cannot change the behavior of theoutfuncs/readfuncs code in released branches, so the relid fieldwill not survive in plans passed to parallel workers; thereforethis info should not be relied on in the executor.This back-patches a portion of the data structure definitionalchanges made in v16 and up by commit47bb9db. It's beingcommitted separately for visibility in the commit log, butwith luck it will not actually matter to anyone. While it'snot inconceivable that this change will break code expectingrelid to be zero in a subquery RTE, we can hope that such codehas already been adjusted to cope with v16 and up.Reported-by: Duncan Sands <duncan.sands@deepbluecap.com>Diagnosed-by: Tender Wang <tndrwang@gmail.com>Author: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>Discussion:https://postgr.es/m/3518c50a-ab18-482f-b916-a37263622501@deepbluecap.comBackpatch-through: 13-15
1 parentf5b4a0b commit28a7e31

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,8 +1825,12 @@ ApplyRetrieveRule(Query *parsetree,
18251825
rte->rtekind=RTE_SUBQUERY;
18261826
rte->subquery=rule_action;
18271827
rte->security_barrier=RelationIsSecurityView(relation);
1828-
/* Clear fields that should not be set in a subquery RTE */
1829-
rte->relid=InvalidOid;
1828+
1829+
/*
1830+
* Clear fields that should not be set in a subquery RTE. However, we
1831+
* retain the relid to support correct operation of makeWholeRowVar during
1832+
* planning.
1833+
*/
18301834
rte->relkind=0;
18311835
rte->rellockmode=0;
18321836
rte->tablesample=NULL;

‎src/include/nodes/parsenodes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,12 @@ typedef struct RangeTblEntry
982982
/*
983983
* Fields valid for a plain relation RTE (else zero):
984984
*
985+
* As a special case, relid can also be set in RTE_SUBQUERY RTEs. This
986+
* happens when an RTE_RELATION RTE for a view is transformed to an
987+
* RTE_SUBQUERY during rewriting. We keep the relid because it is useful
988+
* during planning, cf makeWholeRowVar. (It cannot be relied on during
989+
* execution, because it will not propagate to parallel workers.)
990+
*
985991
* As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
986992
* that the tuple format of the tuplestore is the same as the referenced
987993
* relation. This allows plans referencing AFTER trigger transition

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp