pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18634: Wrong varnullingrels with merge ... when not matched by source
Date: Fri, 27 Sep 2024 11:43:21 -0400
Message-ID: <491922.1727451801@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEZATCWcks92b7YXukLWN8FOOx_Di7sj4_qao=q==6MT_oAoOA@mail.gmail.com>
References: <18634-db5299c937877f2b@postgresql.org>
	<374420.1727390489@sss.pgh.pa.us>
	<CAMbWs4_GGgGaU=oT0zt0rR0uosdjWVZ0Ts5js5dgM21aQSdM5w@mail.gmail.com>
	<CAEZATCWcks92b7YXukLWN8FOOx_Di7sj4_qao=q==6MT_oAoOA@mail.gmail.com>

Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> On Fri, 27 Sept 2024 at 13:52, Richard Guo <guofenglinux@gmail.com> wrote:
>> I think we can check the jointype of the join between the target and
>> the source relation when adding the vars in mergeJoinCondition.  If it
>> is JOIN_LEFT, we mark the vars that belong to source as nullable by
>> this join.

> Another option is to do it in transform_MERGE_to_join(). That feels
> safer, because the jointree might have been modified by the time we
> reach preprocess_targetlist().

Yeah, I think it's critical that these Vars be already correctly
marked before we engage in all the slicing-and-dicing that
prepjointree et al will do.  As an example, it seems not impossible
for join removal to make wrong decisions if they aren't.

> Something like the attached.

Could use some comments ... but actually, now I'm confused about why
any of this is the right thing at all:

+	 * Similarly, any non-target Vars in the join condition will be added to
+	 * the targetlist by preprocess_targetlist(), and so must be marked as
+	 * nullable by the join, for LEFT and FULL joins.

Why do we need these Vars in the tlist?  If they're for re-evaluating
the join condition, isn't the already-nulled form of them the wrong
thing?

			regards, tom lane





view thread (9+ messages)  latest in thread

Message-ID: <491922.1727451801@sss.pgh.pa.us>
Permalink:  ../491922.1727451801@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/491922.1727451801@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, dean.a.rasheed@gmail.com, guofenglinux@gmail.com, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18634: Wrong varnullingrels with merge ... when not matched by source
  In-Reply-To: <491922.1727451801@sss.pgh.pa.us>

* 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