Re: BUG #18830: ExecInitMerge Segfault on MERGE

amit <amitlangote09@gmail.com>

From: Amit Langote <amitlangote09@gmail.com>
To: Tender Wang <tndrwang@gmail.com>
Cc: tharakan@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2025-03-04T11:51:25Z
Lists: pgsql-bugs
On Mon, Mar 3, 2025 at 9:16 PM Tender Wang <tndrwang@gmail.com> wrote:
> nrels = list_length(resultRelations);
> ...
> mtstate->resultRelInfo = (ResultRelInfo *)
>               palloc(nrels * sizeof(ResultRelInfo));
>
> The memory of mtstate->resultRelInfo point to is undefined. When we access its memory in ExecInitMerge(),

This needs to be fixed saparately.

> relationDesc = RelationGetDescr(resultRelInfo->ri_RelationDesc);
>
> crash happened.

Do you have a case where this access to undefined
ModifyTableState.resultRelInfo occurs? I would have thought that it
should not happen.

-- 
Thanks, Amit Langote



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Ensure first ModifyTable rel initialized if all are pruned

  2. Don't lock partitions pruned by initial pruning

  3. Fix an oversight in cbc127917 to handle MERGE correctly

  4. Remove some unnecessary fields from Plan trees.