pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org, Richard Guo <guofenglinux@gmail.com>
Subject: Re: BUG #18953: Planner fails to build plan for complex query with LATERAL references
Date: Tue, 24 Jun 2025 10:00:00 +0300
Message-ID: <afb7be67-cc8a-42b9-952a-0bd7e8c9f925@gmail.com> (raw)
In-Reply-To: <3886446.1750703041@sss.pgh.pa.us>
References: <18953-1c9883a9d4afeb30@postgresql.org>
	<CAMbWs49XTfPD9OCw9xWsRtbiNYgQ-Nau_hHy9UbbGP-w2V=ANQ@mail.gmail.com>
	<1268645.1749765012@sss.pgh.pa.us>
	<1499514.1749848324@sss.pgh.pa.us>
	<CAMbWs4_E7wC3LX17jr+RnRunz9ROcwhn0eXt0riJ6FjbxB0g+g@mail.gmail.com>
	<527134.1750087495@sss.pgh.pa.us>
	<CAMbWs4_wYvQWHCwBfSXj9OQ-fWn+xnntR+EVzks2KB0eRWcRpw@mail.gmail.com>
	<835659.1750177751@sss.pgh.pa.us>
	<837b0dce-b2f3-4811-bccf-f42e8985d6e2@gmail.com>
	<3040798.1750617116@sss.pgh.pa.us>
	<3886446.1750703041@sss.pgh.pa.us>

Hello Tom and Richard,

23.06.2025 21:24, Tom Lane wrote:
> Anyway, with one eye on the possibility that we'll need to back-patch
> this in some form, I went for the localized fix of ensuring that
> we use a copy of the PHV that's been through the normal processing.
> I do want to look into restructuring the handling of these PHVs
> to make this less messy, but that's not a job to undertake for v18
> (much less if we have to back-patch).

I've managed to discover one more anomaly introduced by a16ef313f, that is
not fixed by fix-bug-18953-some-more:
CREATE TABLE t(i int PRIMARY KEY);

MERGE INTO t
USING
   (SELECT 1 AS j FROM generate_series(1, 1))
   RIGHT JOIN (SELECT 1) ON true
   LEFT JOIN (SELECT 1 FROM (SELECT 1 FROM generate_series(1, 1))) ON false
ON i = j
WHEN NOT MATCHED THEN INSERT VALUES (1);
ERROR:  XX000: wrong phnullingrels (b) (expected (b 4)) for PlaceHolderVar 1
LOCATION:  search_indexed_tlist_for_phv, setrefs.c:2958

Thank you for spending your time on this!

Best regards,
Alexander

view thread (21+ messages)  latest in thread

Message-ID: <afb7be67-cc8a-42b9-952a-0bd7e8c9f925@gmail.com>
Permalink:  ../afb7be67-cc8a-42b9-952a-0bd7e8c9f925@gmail.com/
Also on:    postgresql.org/message-id/afb7be67-cc8a-42b9-952a-0bd7e8c9f925@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: exclusion@gmail.com, tgl@sss.pgh.pa.us, guofenglinux@gmail.com
  Subject: Re: BUG #18953: Planner fails to build plan for complex query with LATERAL references
  In-Reply-To: <afb7be67-cc8a-42b9-952a-0bd7e8c9f925@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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