Re: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN

Поиск
Список
Период
Сортировка
От Andrei Lepikhov
Тема Re: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN
Дата
Msg-id ac1454ad-dc4d-467c-9a5a-11709ba33195@postgrespro.ru
обсуждение исходный текст
Ответ на Re: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN  (Richard Guo <guofenglinux@gmail.com>)
Ответы Re: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN  (Richard Guo <guofenglinux@gmail.com>)
Список pgsql-bugs
On 28/12/2023 10:03, Richard Guo wrote:
> During that time, join removal was only performed for left joins, so it
> was not possible for 'ojrelid' to be negative.  However, with the
> introduction of the SJE feature, inner joins can also be removed, and
> 'ojrelid' is set to -1 in the inner join case.  That's how we see this
> error.
Agreed, I have come to the same conclusion.

>          if (bms_is_subset(phinfo->ph_needed, joinrelids) &&
>              bms_is_member(relid, phinfo->ph_eval_at) &&
> -           !bms_is_member(ojrelid, phinfo->ph_eval_at))
> +           (sjinfo == NULL || !bms_is_member(ojrelid, phinfo->ph_eval_at)))
It would be better to check "ojrelid >= 0" as a sign. But why do you 
think SJE could need to delete PlaceHolderVar at all?
> 
> Alternatively, we can modify bms_is_member() to return false for
> negative numbers instead of emitting an error, as suggested by the
> comment there.
> -   /* XXX better to just return false for x<0 ? */
> +   /* negative number cannot be a member of the bitmapset */
>      if (x < 0)
> -       elog(ERROR, "negative bitmapset member not allowed");
> +       return false;
> 
> I prefer the second option, but I'm open to other thoughts.
I don't like this option. It could mask some blunders somewhere like a 
current one.

> FWIW, here is a simplified repro for this error.
> 
> create table t (a int primary key, b int);
> 
> explain (verbose, costs off)
> select 1 from t t1 left join
>      (lateral (select 1 as x, * from t t2) s1 inner join
>          (select * from t t3) s2 on s1.a = s2.a)
>      on true
> where s1.x = 1;
> ERROR:  negative bitmapset member not allowed
It can be simplified even more (without LATERAL):
explain (verbose, costs off)
select 1 from t t1 left join
      (select 1 as x, * from t t2) s1 inner join
         (select * from t t3) using (a)
     on true
where s1.x = 1;

-- 
regards,
Andrei Lepikhov
Postgres Professional




В списке pgsql-bugs по дате отправления:

Предыдущее
От: tender wang
Дата:
Сообщение: Re: BUG #18259: Assertion in ExtendBufferedRelLocal() fails after no-space-left condition
Следующее
От: Richard Guo
Дата:
Сообщение: Re: BUG #18259: Assertion in ExtendBufferedRelLocal() fails after no-space-left condition