Re: Revert: Remove useless self-joins *and* -DREALLOCATE_BITMAPSETS make server crash, regress test fail.

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Re: Revert: Remove useless self-joins *and* -DREALLOCATE_BITMAPSETS make server crash, regress test fail.
Дата
Msg-id CAMbWs4_52sDfSey01dJzLZOp+_P2hWWg7C_7r1wrg+Dc9SyAsA@mail.gmail.com
обсуждение исходный текст
Ответ на Revert: Remove useless self-joins *and* -DREALLOCATE_BITMAPSETS make server crash, regress test fail.  (jian he <jian.universality@gmail.com>)
Ответы Re: Revert: Remove useless self-joins *and* -DREALLOCATE_BITMAPSETS make server crash, regress test fail.  (David Rowley <dgrowleyml@gmail.com>)
Re: Revert: Remove useless self-joins *and* -DREALLOCATE_BITMAPSETS make server crash, regress test fail.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers

On Tue, May 7, 2024 at 11:35 AM jian he <jian.universality@gmail.com> wrote:
hi,

SELECT table_name, column_name, is_updatable
  FROM information_schema.columns
 WHERE table_name LIKE E'r_\\_view%'
 ORDER BY table_name, ordinal_position;

at d1d286d83c0eed695910cb20d970ea9bea2e5001,
this query in src/test/regress/sql/updatable_views.sql
makes regress tests fail. maybe other query also,
but this is the first one that invokes the server crash.

Thank you for the report.  I looked at this a little bit and I think
here is what happened.  In deconstruct_distribute_oj_quals we call
distribute_quals_to_rels using the uncopied sjinfo->syn_lefthand as
outerjoin_nonnullable, which eventually becomes rinfo->outer_relids.
Later on, when we remove useless left joins, we modify
sjinfo->syn_lefthand using bms_del_member and recycle
sjinfo->syn_lefthand.  And that causes the rinfo->outer_relids becomes
invalid, and finally triggers this issue in join_clause_is_movable_to.

Maybe we want to bms_copy sjinfo->syn_lefthand first before using it as
nonnullable_rels.

--- a/src/backend/optimizer/plan/initsplan.c
+++ b/src/backend/optimizer/plan/initsplan.c
@@ -1888,7 +1888,7 @@ deconstruct_distribute_oj_quals(PlannerInfo *root,
    qualscope = bms_union(sjinfo->syn_lefthand, sjinfo->syn_righthand);
    qualscope = bms_add_member(qualscope, sjinfo->ojrelid);
    ojscope = bms_union(sjinfo->min_lefthand, sjinfo->min_righthand);
-   nonnullable_rels = sjinfo->syn_lefthand;
+   nonnullable_rels = bms_copy(sjinfo->syn_lefthand);

I will take a closer look in the afternoon.

Thanks
Richard

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

Предыдущее
От: "Jingxian Li"
Дата:
Сообщение: Re: [PATCH] Fix bug when calling strncmp in check_authmethod_valid
Следующее
От: David Rowley
Дата:
Сообщение: Re: Revert: Remove useless self-joins *and* -DREALLOCATE_BITMAPSETS make server crash, regress test fail.