There is a redundant check in check_outerjoin_delay() in version 15.14 and below - Mailing list pgsql-hackers

From iosif
Subject There is a redundant check in check_outerjoin_delay() in version 15.14 and below
Date
Msg-id tencent_9A93E919E4393ACD23299A4A6851192E3708@qq.com
Whole thread Raw
Responses Re: There is a redundant check in check_outerjoin_delay() in version 15.14 and below
List pgsql-hackers
Hi:
The following snippet is cited from version 15.14, function check_outerjoin_delay()

2055:                        /* yes; have we included all its rels in relids? */
2056:                        if (!bms_is_subset(sjinfo->min_lefthand, relids) ||
2057:                              !bms_is_subset(sjinfo->min_righthand, relids))
2058:                        {
2059:                              /* no, so add them in */
2060:                              relids = bms_add_members(relids, sjinfo->min_lefthand);
2061:                              relids = bms_add_members(relids, sjinfo->min_righthand);
2062:                              outerjoin_delayed = true;
2063:                              /* we'll need another iteration */
2064:                              found_some = true;
2065:                        }
2066:                        /* track all the nullable rels of relevant OJs */
2067:                        nullable_relids = bms_add_members(nullable_relids,
2068:                                                                          sjinfo->min_righthand);
2069:                        if (sjinfo->jointype == JOIN_FULL)
2070:                              nullable_relids = bms_add_members(nullable_relids,
2071:                                                                                sjinfo->min_lefthand);
2072:                        /* set delay_upper_joins if needed */
2073:                        if (is_pushed_down && sjinfo->jointype != JOIN_FULL &&
2074:                              bms_overlap(relids, sjinfo->min_lefthand))
2075:                              sjinfo->delay_upper_joins = true;

The check at line 2074 is redundant and can be safely removed. If relids doesn't initially include sjinfo->min_lefthand, then the condition at line 2056 will be met, and relids will be augmented to include the whole sjinfo->min_lefthand at line 2060, making it overlap with sjinfo->min_lefthand; If relids does initially include sjinfo->min_lefthand,then it also overlap with sjinfo->min_lefthand. The condition at 2074 is gratified anyway, so this check is removale

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Invalid primary_slot_name triggers warnings in all processes on reload
Next
From: Pavel Stehule
Date:
Subject: Re: Add \pset options for boolean value display