public inbox for [email protected]  
help / color / mirror / Atom feed
From: g l <[email protected]>
To: [email protected] <[email protected]>
Subject: are the 2 if-statements in  join_is_legal() removable?
Date: Sat, 10 May 2025 02:14:28 +0000
Message-ID: <SY6P282MB3797B4D591EE5A3953F40C9EDA95A@SY6P282MB3797.AUSP282.PROD.OUTLOOK.COM> (raw)

Hi:
In join_is_legal(), there are 2 decision-making statements based on match_sjinfo. I    wonder wether their conditions can ever test possitive.

            /*
             * If one input contains min_lefthand and the other contains
             * min_righthand, then we can perform the SJ at this join.
             *
             * Reject if we get matches to more than one SJ; that implies we're
             * considering something that's not really valid.
             */
            if (bms_is_subset(sjinfo->min_lefthand, rel1->relids) &&
                  bms_is_subset(sjinfo->min_righthand, rel2->relids))
            {
                  if (match_sjinfo)
                        return false;     /* invalid join path */
                  match_sjinfo = sjinfo;
                  reversed = false;
            }
            else if (bms_is_subset(sjinfo->min_lefthand, rel2->relids) &&
                         bms_is_subset(sjinfo->min_righthand, rel1->relids))
            {
                  if (match_sjinfo)
                        return false;     /* invalid join path */
                  match_sjinfo = sjinfo;
                  reversed = true;
            }
There is no query in regression test suite that can render the 2 decision-makings based on match_sjinfo true, nor can i figure out one. Can these conditions ever be true? If they can be true, what queries can make them true? On the contrary,if the conditions can never be true, then the 2 "if (match_sjinfo) return false" statements can be safely removed.
Any feedback is welcome.

--
Best Regards
Geng





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]
  Subject: Re: are the 2 if-statements in  join_is_legal() removable?
  In-Reply-To: <SY6P282MB3797B4D591EE5A3953F40C9EDA95A@SY6P282MB3797.AUSP282.PROD.OUTLOOK.COM>

* 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