Re: BUG #18830: ExecInitMerge Segfault on MERGE

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: BUG #18830: ExecInitMerge Segfault on MERGE
Дата
Msg-id CAEZATCX8WxPtpaFRfi7JpjPso+xfHaqZfVw-7oHxMg7i54t+4w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #18830: ExecInitMerge Segfault on MERGE  (Tender Wang <tndrwang@gmail.com>)
Ответы Re: BUG #18830: ExecInitMerge Segfault on MERGE
Re: BUG #18830: ExecInitMerge Segfault on MERGE
Список pgsql-bugs
On Wed, 12 Mar 2025 at 16:11, Tender Wang <tndrwang@gmail.com> wrote:
>
>  I can find another same error in the below query:
>
> with t as (update part_abc set c = true  where a = stable_one() +2  returning a) insert into foo select a from t;
>

Interesting example. That passes in HEAD, but fails with the v1 patch
because it is attempting to open a pruned result relation when it
doesn't need to.

Attached is a rough patch that attempts to solve these issues locally
in ExecInitModifyTable(), by not allowing all result relations to be
pruned for that node. That makes it easy to handle cases with multiple
ModifyTable nodes.

This also has the advantage that all these relations can continue to
be pruned from the subplans of the ModifyTable nodes, making those
scans more efficient, and it only keeps a pruned result relation if
all other result relations have been pruned.

It does mean that ExecGetRangeTableRelation() needs to allow pruned
relations to be opened, if called from ExecInitResultRelation(). I
think that's OK because the check for opening pruned relations still
applies to scan relations.

I also adjusted explain.c slightly, to avoid the dummy pruned result
relation that we might now keep from appearing in the EXPLAIN output
as a target relation. Allowing it to be shown looked a bit odd,
because it's not really the target relation in any real sense.

I also noticed a few Asserts in ExecInitModifyTable() that didn't
appear to be doing what they were originally intended to do.

Regards,
Dean

Вложения

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