Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wcB3S-0039BA-05 for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Jun 2026 00:01:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wcB3Q-00ERnL-2P for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Jun 2026 00:01:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wcB3Q-00ERnD-1V for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 00:01:20 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wcB3O-000000020kJ-1y66 for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 00:01:20 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-84231305a80so391952b3a.0 for ; Tue, 23 Jun 2026 17:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782259276; cv=none; d=google.com; s=arc-20240605; b=emKXVo59QkUB2FGm3gI0GrJgiQTkXs7iCjp2v4dqgtWQfJj5svTZkBnB2M3hkMHykc nytDa8E6NM7/T7R9PYpIE4//SyfC7E6JM9TOhhNWCFC7ivqjxs3Mn/Q5aBarT3YDZ6pM qfr1NbWQsfp3mrlSMHvXkI768rRfG4tgWlxQ7qkZIwxJCoisM2UoUKm95BFa2di3IUhG jXfEoLdmFk8pz0coKREkPti3xag5n5mg5tp7/bm9PrbPsinAl41Avi0kJ0uDfXrAXL6T Hrmcl9rY8qpbWZIlvvbwZGwe/zWHZdMyagmlAacsAvwmm/dgXg7JUnDwWqvFs4sw/9ZR ONJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LqjWxtoGoa4lDbwFMROS2YqMya6Mj8+COjyhxgIHmBI=; fh=B7ZJbsQSTxIVX5UDwpAP5XgPPwuX5ayhwQZq0GFJeRM=; b=dNunTtIeLA+LUL5k5eKjuULu/j+rjUuFrKX9/+uICfoPL8SrrDxh8XRPoQDqxCZCZq hopdOgJ/Vmtn1L69jgSWL41+DPFnD9hxxxttUhc2IPuXg0IctY6m7ua5Sx81xbO77eZx r2lG6UylJSi7NOe5WNcPtQZvMI+UMDE2NbqXFcFnm2KWKrpB1bGIKlSqlMwLjJSLtRs1 /K5F+zf6eMh4LnBQS4pfgnYr6yIzfW0LXfjCZohWk8FQqhZqFjTyF9nUkUhQQqaas2eW eJDN+efv9woOjWQjo/uEk1almkueaWw6CCODwmyjicifA0JW4nrWBhQngWWpk0itw5r2 Swag==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782259276; x=1782864076; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LqjWxtoGoa4lDbwFMROS2YqMya6Mj8+COjyhxgIHmBI=; b=WB3GLeJwNpsvMShJ3DToBnGOMcbkDS/TbMP3XfKXBbzk/V5mgypiHZOv9NA64Cu8gJ a6m93Zbx3+F8YmhGdMC64lK1mufZDJ3FnqwJWX9eWhSA5SANIIdLYFtBFCyw/9O5pb2R ctvjO4fPG8fxX7mFjsD199tvIcW/CYKqj1nPYWzOl7FjrP0Bl9BVC9GQxluoOKkjSGFA mEawMzSZ+WaqhZTofuNWMHMAwQdgNIHCEOelPTnKdy/wfoAWbzdd52alQDWOIvkm/1Vn CwsXdiecW1/43RpHE6XUD+Sy1kehZzuHkwEXP7lkbbNiD3pyXqsWocgFObLKRGMyh1jF kVew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782259276; x=1782864076; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LqjWxtoGoa4lDbwFMROS2YqMya6Mj8+COjyhxgIHmBI=; b=s4Oe9qjxDAOSPyeFIGwoEQ1utW9+eTUhYnZfU/sxkkaJMPvxazKD5IjAXZMCn+eCiT QUjSoBOZdTKjiFs9Z6yG483naFMxUZvxJP0RUvz/O27+JVPu3QSFPBdRuk3cTFhSOnTG vub9m6y+pqzyZaO21cb5NgWNogycbFHGinY/5H+yxNEmxG0XDvCiJU7694vYheXZ+dFK /RqONwpsu/34edGZfvkE+osCXVXaW+mIGlWfztwIkkqN0EJNacUo+ScRyobooFdYzazN 9zDJMxON2GRBF6rczJgcjzgossxBk0S27GJ+hodbln2Z6k10DSgDZfITfaOC+rbN0IH5 c6DA== X-Forwarded-Encrypted: i=1; AFNElJ+N/jvTVD2rfIIq9bJqBehfXvMCizQxcI1wWIpBtp5h7sAS5f+KBltSN05cb3WZmtSUpG7AifYS/rZK@lists.postgresql.org X-Gm-Message-State: AOJu0Yx+Wq7Y6jYaV7QmCAKAqM4zFHK3zeQfA6+tkjOBqRa0yUATThhK Adfom6CeniuXzbaEAMSc6x6HiFzY4OJPxPMB9Hp7qmiLCHxp2aTy+cHtrPlLvuk+EW+bK+Tfogk Y8/l8PyI+HWGrMjx4kDtWe0B2Q6QWQl0= X-Gm-Gg: AfdE7cnk2mo2GLawUslOnmI95B79k3b2uIP2F2LVj1w9kTyqY8r7eqpkcKZM7mUL5Ao 6p1FH9/yEQmWA8ILKwFVElqNuBegzuFBn5RdXgygIBdYtgQUXNkiFPBuTPJONhc0bZERK27a/f/ BSlI3dVDjtf5nmifhQkbNJjbr/ffmfeqWT1HiU9jFrzAKDp6mdd1EdTY9w+Ibu1u0r8O3m2F3rk YrH5PEwoZazp+B0tnl+QQ1Le7E5VBLNC9mBuQ9pw09zKlsc6B7IkIlx7ZNJEqkHJSRYkw8sUXGL P25bGUp5BWLNF8oekgC7zczK/4X8nDeN+xmJjA8VtlIEHw+XHPDa4w== X-Received: by 2002:a05:6a00:a0d:b0:83f:250d:59c with SMTP id d2e1a72fcca58-845a27b23a2mr1782836b3a.39.1782259275492; Tue, 23 Jun 2026 17:01:15 -0700 (PDT) MIME-Version: 1.0 References: <19484-a3cb82c8cde3c8fa@postgresql.org> In-Reply-To: From: Amit Langote Date: Wed, 24 Jun 2026 09:00:59 +0900 X-Gm-Features: AVVi8Ce9oeFQ-CRgw-K_mXxsY7tefndXSFfBRYwPjzyoJ437lmAMtSfW_N8da7k Message-ID: Subject: Re: BUG #19484: Segmentation fault triggered by FDW To: Etsuro Fujita Cc: Matheus Alcantara , Ayush Tiwari , Rafia Sabih , 798604270@qq.com, pgsql-bugs@lists.postgresql.org, Amit Langote Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jun 23, 2026 at 5:27=E2=80=AFPM Etsuro Fujita wrote: > On Mon, Jun 22, 2026 at 5:28=E2=80=AFPM Amit Langote wrote: > > On Fri, Jun 19, 2026 at 8:59=E2=80=AFPM Etsuro Fujita wrote: > > > > +-- Runtime pruning of result relations must keep ModifyTable's per-r= elation > > > +-- FDW arrays (fdwPrivLists, fdwDirectModifyPlans) aligned with the = kept > > > +-- resultRelations. Otherwise BeginForeignModify() reads the wrong > > > +-- fdw_private and segfaults. > > > > > > This comment isn't 100% correct, because this issue happens with > > > DirectModify as well. I think we could expand the comment to mention > > > that as well, but the comment is already too much/detailed IMO; I > > > don't think we add such a comment for a test case, so how about > > > simplifying the comment like this: "Test that direct modify and > > > foreign modify work with runtime pruning of result relations (bug > > > #19484)" > > > > I agree that the details shouldn't leak into test code and have been > > trying to follow that principle. Also, bug numbers shouldn't be > > mentioned because one can always use `git blame` to find them. > > However, since different committers have different styles, I'm fine > > with it; kept in the attached updated patch. > > Thanks! > > > > @@ -1446,6 +1446,12 @@ typedef struct ModifyTableState > > > int mt_nrels; /* number of entries in resultRelInfo= [] */ > > > ResultRelInfo *resultRelInfo; /* info about target relation(s) = */ > > > > > > + /* > > > + * Re-indexed fdw private data lists, aligned with resultRelInfo[= ] after > > > + * pruning > > > + */ > > > + List *mt_fdwPrivLists; > > > > > > For v18, I think we should put this at the end of the ModifyTableStat= e > > > struct, to avoid ABI breakage. > > > > Good point on ABI. Rather than placing it differently per branch, how > > about putting mt_fdwPrivLists at the end of the struct alongside > > mt_updateColnosLists/mt_mergeActionLists/mt_mergeJoinConditions, which > > are the same kind of unpruned-filtered lists? That keeps it ABI-safe > > and lets master and 18 share an identical change. I'd fold it into > > their existing comment too. > > That's a good idea! So +1 > > > Updated patch attached. > > LGTM. Pushed, thanks for checking. -- Thanks, Amit Langote