public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Richard Guo <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Cc: Robins Tharakan <[email protected]>
Subject: Re: Inconsistent nullingrels due to oversight in deconstruct_distribute_oj_quals
Date: Fri, 10 Feb 2023 13:40:30 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAMbWs4_roJajn1TvC=M9ZCgG65S-h=pqofVa4VTuZh+Q+7K0LA@mail.gmail.com>
References: <CAMbWs497CmBruMx1SOjepWEz+T5NWa4scqbdE9v7ZzSXqH_gQw@mail.gmail.com>
	<[email protected]>
	<CAMbWs485DSqPD9fZLEPZDmRiFy5tH5NLYsvA_OtRM453s5uqEw@mail.gmail.com>
	<CAMbWs4_roJajn1TvC=M9ZCgG65S-h=pqofVa4VTuZh+Q+7K0LA@mail.gmail.com>

Richard Guo <[email protected]> writes:
> However, for 'above_sjinfo' case, we should not use
> othersj->syn_righthand,  because othersj->syn_righthand contains relids
> in sjinfo's righthand which should not be nulled by othersj after the
> commutation.  It seems what we should use here is sjinfo->syn_lefthand.

I had a hard time wrapping my brain around that to start with, but
now I think you're right.  othersj is syntactically above the current
join, so its syn_righthand will cover all of the current join, but
we only want to add nulling bits to Vars of the current join's LHS.
(That is, we need to transform Pbc to Pb*c, not Pb*c*.)

I also realized that there was a fairly critical nearby bug:
make_outerjoininfo was failing to check whether the upper join's qual
is actually of the form "Pbc", without any references to the lower join's
LHS.  So that led us to setting commute bits in some cases where we
shouldn't, further confusing deconstruct_distribute_oj_quals.  (I think
this snuck in because its other code path doesn't need to make such a
check, it being syntactically impossible to have such a reference if
we start from the other form of the identity.)

Fix pushed.  This seems to take care of Robins' latest example in
the bug #17781 thread [1], too.

			regards, tom lane

[1] https://postgr.es/m/CAEP4nAx9C5gXNBfEA0JBfz7B+5f1Bawt-RWQWyhev-wdps8BZA@mail.gmail.com






view thread (3+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Inconsistent nullingrels due to oversight in deconstruct_distribute_oj_quals
  In-Reply-To: <[email protected]>

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

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