Re: Remove no-op PlaceHolderVars

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Remove no-op PlaceHolderVars
Date: 2026-01-16 06:21:06
Message-ID: CAMbWs49B8KrvYvRQfhkFvBb_rRyBHv61S29sYO7W+gP3Cve3eQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 16, 2026 at 12:37 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> My immediate reaction is "how sure are you that they're no-ops"?
> I recall that there are places where we intentionally insert PHVs
> to preserve the separate identity of the contained expression
> (so that, for example, it can be matched to a subquery output
> later).

The new phpreserved flag is used for that purpose, as explained in the
commit message and the code comments.

> Do we generate a PHV at all in that case? Seems like we could
> deal with that by adding to the Var's varnullingrels instead of
> making a wrapper node.

The Var can be a reference to something outside the subquery being
pulled up. If it is a reference to the non-nullable side, we'll have
to wrap it in a PHV to ensure that it is forced to null when the outer
join should do so.

- Richard

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2026-01-16 06:32:06 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Alexander Lakhin 2026-01-16 06:00:00 Re: Bug in amcheck?