From: | Tender Wang <tndrwang(at)gmail(dot)com> |
---|---|
To: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
Cc: | Amit Langote <amitlangote09(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, tharakan(at)gmail(dot)com |
Subject: | Re: BUG #18830: ExecInitMerge Segfault on MERGE |
Date: | 2025-03-13 07:29:35 |
Message-ID: | CAHewXNnRhngjctUBW7-5SF6o8k3SmQ=Z2JDTwdP5SWJ4jJWd6Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> 于2025年3月13日周四 03:23写道:
> On Wed, 12 Mar 2025 at 16:11, Tender Wang <tndrwang(at)gmail(dot)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.
>
I tested and debugged the attached patch. I didn't find any other issue.
A comment in execPartition.h may need to be changed:
* partrel Partitioned table
Relation; obtained by
*
ExecGetRangeTableRelation(estate, rti), where
Because the func interface has changed, the above comments are better to be
changed "ExecGetRangeTableRelation(estate, rti, false)".
--
Thanks,
Tender Wang
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2025-03-13 08:14:11 | Re: BUG #18828: Crash when pg_get_logical_snapshot_meta() passed empty string |
Previous Message | Tom Lane | 2025-03-13 02:21:20 | Re: BUG #18839: ARMv7 builds fail due to missing __crc32cw and similar |