Re: Wrong results with initplans moved by setrefs.c

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Wrong results with initplans moved by setrefs.c
Date: 2026-11-09 06:30:03
Message-ID: CAMbWs48G5D5oeZGfuxmqDoXa7NVWpKXYJqDOoOiDivE5tQ+BcQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 9, 2026 at 2:11 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> Looking at finalize_plan(), I'd say that's correct. But shouldn't it
> be bms_add_member() rather than bms_union()?

Thanks for looking! I assume you mean bms_add_members(). Agreed.
finalize_plan() allocates a fresh extParam and allParam for each plan
node, and nothing else keeps a pointer to them, so we can safely
modify the child's sets in place, and there's no point in allocating
new ones.

Attached is a patch for this fix.

(Since v14 will reach EOL before this can be pushed, maybe
back-patching to v15 is enough.)

- Richard

Attachment Content-Type Size
v1-0001-Fix-stale-initplans-after-removing-a-plan-level-i.patch application/octet-stream 4.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Henson Choi 2026-11-09 06:30:08 Re: Row pattern recognition
Previous Message Henson Choi 2026-11-09 06:29:45 Re: Row pattern recognition