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 1wbwU9-002xu2-1u for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Jun 2026 08:27:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbwU8-00AVRY-0z for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Jun 2026 08:27:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wbwU7-00AVRQ-30 for pgsql-bugs@lists.postgresql.org; Tue, 23 Jun 2026 08:27:56 +0000 Received: from mail-dy1-x1335.google.com ([2607:f8b0:4864:20::1335]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wbwU5-00000001iSP-0bN6 for pgsql-bugs@lists.postgresql.org; Tue, 23 Jun 2026 08:27:54 +0000 Received: by mail-dy1-x1335.google.com with SMTP id 5a478bee46e88-30bc806fcf8so6076217eec.1 for ; Tue, 23 Jun 2026 01:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782203272; cv=none; d=google.com; s=arc-20240605; b=NDJcZN8lo3ZbylhwiAt31lRnjBY7GtF2C4afxIoQ+vjoA7Z8UkSZY+NTXor4iwXv65 KXiqXa7cCle0LU+6bvoZyC+nveEdexDoG/R8rwuWj3EKQPBpwKP/LX9WoM0r0wS/mci7 AeabfmPzIuV2RKx3DeNreW4Ij2zqE8vXqEtH+luVy6sCTp9nuY7pJpB7E2taU0n+IFgh aJUV2nVQvST1EqF7qlS5A9XDHNSJtYvd3jwi1twW1PZ1Sz8meGZq9AsbnVnidC38m5px WE7rKt2GbQPrOsZ4RidEp9wuEyiVg9wTiVodmobgN+YNyVk1SQRD2MszGE5jZCqeW+aL tQ5A== 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=vpAstcG4PM175YitBPXXyo6zFrn77URgCaNw9IF+j38=; fh=aRMqc7qzPUXssrbkJ5FyU0sWAqAoyNoSvmhii4y/5v4=; b=L4Zs6+PSmMuIMCHtwK4zMEgBtOzDptbbw6mFK3eFKT5Yb/Pa9whwflB6HBeoegcabt rUx80VIFy555RM8X5GSjoaMB1sgRFa2kN4sTUPBPwj6pimN1BzwU0QVN6tOAoxeLGNQN KH5nz/WFFef+4MjHIl/KlAuwx91NnTS3y9uZfzYGhUghR0yLakaVxMX+SF1arY/dQ0WI CcO/muan8MHjTewcjNudrlK7bSafcJo0FjAE6PI4uDc7T36WXfBxgRuhon+OTrqhB6nx cK7cgyaALb+l8Djfb18nxEZtwD5fxn6oVKKBlIKnpvwof6hSeMRS5ijLUlUqYbCyqlW6 +ITw==; 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=1782203272; x=1782808072; 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=vpAstcG4PM175YitBPXXyo6zFrn77URgCaNw9IF+j38=; b=T0IRxNIHJaBEoXldM4IiYyvWJ7av6ehPMVPy9oEcxtjJFokvDyeK3vl+SB7CWfDVPT vMGID8cMdB38zRfgWJr1tCXDNeSQtZbjAV/LDeoI4iSfQd+QQdV4lvtpe36jIRLkg1Xo j/iti5IFZEK7RCvLyVe3I5qhI/rN2gfeTjNdgctVWyw8tEXA6caT/NO3UEVSPvW6OJqx LjdWCWKmtp50Sgag4MjtspqxpiakYqDCdYBIBr1LSDZtMx+Q9jO8wiHJPtlHG45tyNOJ eWN7TCBtLTwX5eh/w767PAEi6hx1d4j8xD+xsjes1mQj4WgtLPZb26jghyW5z7Y15lPv ZagQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782203272; x=1782808072; 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=vpAstcG4PM175YitBPXXyo6zFrn77URgCaNw9IF+j38=; b=TglKxNWzlZy72pZS+cALQp6hzkNmIcw5KpBK1zxPzfA43w28LCvFIgzSqFYM8AHbFK HkqAakSQOprXs67Xty+GuukaIN+5FYrUlQcthpuULMNAwCj+lR+OHDIc52uzVivxAvF8 99sCJgYephMwuyJPKPBFZw0YZg5Vk3l7oGLX1SpQvyEBQWqqh2aT0XpJoPZokKm32Hoe q2n8ZDxypiHuUprvJXbduOWEq/M/daYpQz+hF0buvy8sUpc8VuqdEw5M2kqkwVfm3veT Dv11d7tIS4rf28Xs9RTMYhmcuLB6EXQYqjKa8miozQ1+uIGSNiPxXy6UOOo/USa228R9 P+ww== X-Forwarded-Encrypted: i=1; AHgh+RpqXBkPbMbb6dpMvRKgNEvpkHQIKL9EuHAMUx8HeZkc5QgUabPjyTHIUrBWmOAbE4+BCPkbovLiMh6t@lists.postgresql.org X-Gm-Message-State: AOJu0Yy1prJ9tel0p1JRjxVIUcgmRNrtvP19al7l6ZVtiI54t/qZ7I9s tvn14HEFhA2wWPUuzR2/qp7/Gt+/quaQKbuweI3GCuS5x8hsAE66x4st3p8iM1Sc51PkYi/vojd w8Rnaw/ZlcGfvTf0r1JiSQrqxQMKm/f4= X-Gm-Gg: AfdE7cmjzFVV3RdlS89ma3jG5rWYpz05bkjlPfbQK/ydgOFtYKBDSkAF3yI3UceVco/ G0o/qJo7kahuusiaLZMdXUjHQEfhMKKLNUo5XjmTmgovWqfFCa1ft/AYTmoJEFKMkEDNlBtxr9+ z5l/z1OqXdDwRI0qcLWDjkjZwSd/1R7IFZAmKCcZamErexdUuIh3n7vgcfe4dya2biDDIGp8Smf oESdXEgQIfP1maCbxaYBrIypvMCOpod7ycvcoIApepuWMgVrQSzrm3I48TaQbeyX8gjBiM95MH3 IhG8YSx8xRh3q1qTf/PF7Cff/wFOEpQLKskc+ETNEoK/BAZBxFTTlZyBCR/2vcu0ZtIMuOr4fcO gnb2TOPXFX00KIX510kA0C/XNBuJXNQ== X-Received: by 2002:a05:7301:22af:b0:304:bce8:fa30 with SMTP id 5a478bee46e88-30c58a44beamr1550556eec.5.1782203271789; Tue, 23 Jun 2026 01:27:51 -0700 (PDT) MIME-Version: 1.0 References: <19484-a3cb82c8cde3c8fa@postgresql.org> In-Reply-To: From: Etsuro Fujita Date: Tue, 23 Jun 2026 17:27:39 +0900 X-Gm-Features: AVVi8Cdq51ednIteteuE8GBHQRikaCDHeVLi7Ptd2TiYv-y2KO4lT7rBvsJPZVo Message-ID: Subject: Re: BUG #19484: Segmentation fault triggered by FDW To: Amit Langote 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 Amit-san, 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-rel= ation > > +-- FDW arrays (fdwPrivLists, fdwDirectModifyPlans) aligned with the ke= pt > > +-- 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 ModifyTableState > > 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. Best regards, Etsuro Fujita