Re: Unclear code - please elaborate - Mailing list pgsql-hackers

From Junwang Zhao
Subject Re: Unclear code - please elaborate
Date
Msg-id CAEG8a3L_4WJk7bHy7Lzy540Biqp=HZry1ghmgMVymOFkJrP2Dw@mail.gmail.com
Whole thread Raw
In response to Unclear code - please elaborate  (Dmitry Nikitin <pgsql-hackers@dima.nikitin.name>)
List pgsql-hackers
On Sat, Nov 30, 2024 at 4:15 PM Dmitry Nikitin
<pgsql-hackers@dima.nikitin.name> wrote:
>
> Hello ,
>
>
https://github.com/postgres/postgres/blob/5d39becf8ba0080c98fee4b63575552f6800b012/src/backend/optimizer/prep/prepjointree.c#L3856
> bms_next_member() is allowed to return the zero as a valid value. Subsequent rt_fetch() offsets that
> zero to -1 which leads to the assertion down the code. Nothing wrong here? Either zero is simply not
> possible after that bms_next_member() because of some factors behind the code?
>

rtindex 0 is not used, see the logic of setup_simple_rel_arrays and the comments
of PlannerInfo.simple_rel_array.

/*
* simple_rel_array holds pointers to "base rels" and "other rels" (see
* comments for RelOptInfo for more info). It is indexed by rangetable
* index (so entry 0 is always wasted). Entries can be NULL when an RTE
* does not correspond to a base relation, such as a join RTE or an
* unreferenced view RTE; or if the RelOptInfo hasn't been made yet.
*/

>
> --
> Best regards,
>  Dmitry                          mailto:pgsql-hackers@dima.nikitin.name
>
>
>


--
Regards
Junwang Zhao



pgsql-hackers by date:

Previous
From: Kirill Gavrilov
Date:
Subject: Re: Truncate logs by max_log_size
Next
From: Bernd Helmle
Date:
Subject: Re: [PATCH] Add sortsupport for range types and btree_gist