public inbox for [email protected]  
help / color / mirror / Atom feed
pgsql: Preserve RangeTblEntry.relid when expanding a view RTE.
3+ messages / 1 participants
[nested] [flat]

* pgsql: Preserve RangeTblEntry.relid when expanding a view RTE.
@ 2025-03-12 15:48 Tom Lane <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2025-03-12 15:48 UTC (permalink / raw)
  To: [email protected]

Preserve RangeTblEntry.relid when expanding a view RTE.

When the rewriter converts an RTE_RELATION RTE for a view into
an RTE_SUBQUERY RTE containing the view's defining query, leave
the relid field alone instead of zeroing it.  This allows the
planner to tell that the subquery came from a view rather than
having been written in-line, which is needed to support an
upcoming planner bug fix.  We cannot change the behavior of the
outfuncs/readfuncs code in released branches, so the relid field
will not survive in plans passed to parallel workers; therefore
this info should not be relied on in the executor.

This back-patches a portion of the data structure definitional
changes made in v16 and up by commit 47bb9db75.  It's being
committed separately for visibility in the commit log, but
with luck it will not actually matter to anyone.  While it's
not inconceivable that this change will break code expecting
relid to be zero in a subquery RTE, we can hope that such code
has already been adjusted to cope with v16 and up.

Reported-by: Duncan Sands <[email protected]>
Diagnosed-by: Tender Wang <[email protected]>
Author: Tom Lane <[email protected]>
Reviewed-by: Dean Rasheed <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13-15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/317aba70ef83464c0e592be733e38e4b8897c0b5

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 8 ++++++--
src/include/nodes/parsenodes.h       | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Preserve RangeTblEntry.relid when expanding a view RTE.
@ 2025-03-12 15:48 Tom Lane <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2025-03-12 15:48 UTC (permalink / raw)
  To: [email protected]

Preserve RangeTblEntry.relid when expanding a view RTE.

When the rewriter converts an RTE_RELATION RTE for a view into
an RTE_SUBQUERY RTE containing the view's defining query, leave
the relid field alone instead of zeroing it.  This allows the
planner to tell that the subquery came from a view rather than
having been written in-line, which is needed to support an
upcoming planner bug fix.  We cannot change the behavior of the
outfuncs/readfuncs code in released branches, so the relid field
will not survive in plans passed to parallel workers; therefore
this info should not be relied on in the executor.

This back-patches a portion of the data structure definitional
changes made in v16 and up by commit 47bb9db75.  It's being
committed separately for visibility in the commit log, but
with luck it will not actually matter to anyone.  While it's
not inconceivable that this change will break code expecting
relid to be zero in a subquery RTE, we can hope that such code
has already been adjusted to cope with v16 and up.

Reported-by: Duncan Sands <[email protected]>
Diagnosed-by: Tender Wang <[email protected]>
Author: Tom Lane <[email protected]>
Reviewed-by: Dean Rasheed <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13-15

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/584f17a9063ee63aa472705bfac1bed95e3e2194

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 8 ++++++--
src/include/nodes/parsenodes.h       | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Preserve RangeTblEntry.relid when expanding a view RTE.
@ 2025-03-12 15:48 Tom Lane <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2025-03-12 15:48 UTC (permalink / raw)
  To: [email protected]

Preserve RangeTblEntry.relid when expanding a view RTE.

When the rewriter converts an RTE_RELATION RTE for a view into
an RTE_SUBQUERY RTE containing the view's defining query, leave
the relid field alone instead of zeroing it.  This allows the
planner to tell that the subquery came from a view rather than
having been written in-line, which is needed to support an
upcoming planner bug fix.  We cannot change the behavior of the
outfuncs/readfuncs code in released branches, so the relid field
will not survive in plans passed to parallel workers; therefore
this info should not be relied on in the executor.

This back-patches a portion of the data structure definitional
changes made in v16 and up by commit 47bb9db75.  It's being
committed separately for visibility in the commit log, but
with luck it will not actually matter to anyone.  While it's
not inconceivable that this change will break code expecting
relid to be zero in a subquery RTE, we can hope that such code
has already been adjusted to cope with v16 and up.

Reported-by: Duncan Sands <[email protected]>
Diagnosed-by: Tender Wang <[email protected]>
Author: Tom Lane <[email protected]>
Reviewed-by: Dean Rasheed <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13-15

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/28a7e31d0cec07fdcea5f800cc29ed7b1ec04cfd

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 8 ++++++--
src/include/nodes/parsenodes.h       | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-03-12 15:48 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-12 15:48 pgsql: Preserve RangeTblEntry.relid when expanding a view RTE. Tom Lane <[email protected]>
2025-03-12 15:48 pgsql: Preserve RangeTblEntry.relid when expanding a view RTE. Tom Lane <[email protected]>
2025-03-12 15:48 pgsql: Preserve RangeTblEntry.relid when expanding a view RTE. Tom Lane <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox