Re: BUG #19484: Segmentation fault triggered by FDW
Etsuro Fujita <etsuro.fujita@gmail.com>
From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>,
Matheus Alcantara <matheusssilv97@gmail.com>, Ayush Tiwari <ayushtiwari.slg01@gmail.com>,
Rafia Sabih <rafia.pghackers@gmail.com>, 798604270@qq.com, pgsql-bugs@lists.postgresql.org, Amit Langote <amitlan@postgresql.org>
Date: 2026-06-24T09:15:25Z
Lists: pgsql-bugs
Amit-san,
On Wed, Jun 24, 2026 at 1:25 PM Amit Langote <amitlangote09@gmail.com> wrote:
> On Wed, Jun 24, 2026 at 11:23 AM Richard Guo <guofenglinux@gmail.com> wrote:
> > On Wed, Jun 24, 2026 at 10:43 AM Amit Langote <amitlangote09@gmail.com> wrote:
> > > If we’d rather avoid it, I have a no-field alternative for REL_18: show_modifytable_info() is the only reader of the re-indexed list, and it can recompute the mapping from node->resultRelations and node->fdwPrivLists, both plan-ordered and untouched by pruning.
> >
> > This sounds like a nice solution. Since show_modifytable_info() is
> > only used for EXPLAIN, I guess the recompute overhead on the
> > re-indexed list should be fine.
>
> Thanks for chiming in, here is the patch to do so.
Thanks for the patch!
+ /*
+ * node->fdwPrivLists is indexed by the original, pre-pruning
+ * result relation order and is parallel to node->resultRelations.
+ * Initial pruning may have dropped earlier relations, so the kept
+ * index j need not match the original position; find this
+ * relation's entry by its range table index instead.
+ */
+ forboth(lc1, node->resultRelations, lc2, node->fdwPrivLists)
+ {
+ if (lfirst_int(lc1) == (int) rti)
+ {
+ fdw_private = (List *) lfirst(lc2);
+ break;
+ }
+ }
I think it's good to skip this for efficiency, when there are no
pruned result relations.
Other than that the patch looks good to me.
I didn't know pg_rewrite's use of ModifyTableState, which was
different than I expected. Sorry for that.
Best regards,
Etsuro Fujita
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Avoid ABI break in ModifyTableState from the FDW pruning fix
- bba4e095d250 18 (unreleased) landed
-
Re-index ModifyTable FDW arrays when pruning result relations
- b43f8aa4cb30 19 (unreleased) landed
- 1ef917e3a61a 18 (unreleased) landed
-
Fix universal builds on MacOS
- 901ed9b352b4 19 (unreleased) cited
-
Track unpruned relids to avoid processing pruned relations
- cbc127917e04 18.0 cited