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 1wcJhw-003Fxd-2r for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Jun 2026 09:15:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wcJhv-0002Ss-2Z for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Jun 2026 09:15:43 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wcJhv-0002Sk-1T for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 09:15:43 +0000 Received: from mail-dy1-x1333.google.com ([2607:f8b0:4864:20::1333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wcJht-000000025Xy-1bJY for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 09:15:43 +0000 Received: by mail-dy1-x1333.google.com with SMTP id 5a478bee46e88-30c6c8d7503so1319967eec.0 for ; Wed, 24 Jun 2026 02:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782292539; cv=none; d=google.com; s=arc-20240605; b=RK5/JSz+tKJmIVThZhzL5QfOFa2XJv1x7tctPWppo+ldbOzGGb2x9K1muFet5zXAwl ubApr/6cbtn3BfxQjIz6GaOcno84O9fQH9xJ+jadfKWM3svC2nAvAR42ik1McswmLER0 mqF2vkxNclDpjM7ZZN9o16/TNjoDLWLkj3GOgwBSC8cL8LRsRK0vEQR10jiF5oPUk2Al eURVyKbu0KEwY4i83WtlJmIG/kplBox9WREEpIc/IzLJpPycWDTFAOyRUXyns74+PHEC dqcEEMsOx1dTw6heAq6DotZq3DeLJ+t5QWtKs1rjOfCOb3dLmLXhgxH9x1UAZ/RAx9A0 SKDw== 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=ntBcKJbPdr2BcshaOGmqAHXQMpCNp8GJ4XamSV4zy7Y=; fh=E/wPBX26X0iHszYkM1aKx0VysQErMRZFVVE09A0/obU=; b=Oo7q5x70P5MvbuTL2nwcOsEOyGqSoJ4QuwYaFHkfaKj2NJIp/lPovmjvQMKRs1Kczs zFEhugvx6obLpvXY+WUlIV+No4/FW51Izc0339cmaFSKL+xyHLsb4pF6DO337S1sL55t IZ2PVkjN20IJMOb30L3Eh/t13ah5JxSJL1kjDyy2GraspktVkl37QUI9CsTypfO/e4AC emU0tBgfTmnYsXVm9ftdBqaZQFOE28mZes/hoi3J/QH0OOJEnCVA3nyZTXexx1U10OFx slywgfdh1GCETEmYfYOVz1PtYqNTg3dcdQdut52+2cb7AvJg/iCkX0XFZ/Pn4xuagntH L5eQ==; 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=1782292539; x=1782897339; 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=ntBcKJbPdr2BcshaOGmqAHXQMpCNp8GJ4XamSV4zy7Y=; b=pysKwjijuG1Q5IRuqLJ/ddti4S/N9eme8aKWw9t3Gn25dH4F96DcwDmOxcumFM2DvT YgY1yiSPg4Gl1pAytmMczcdI6/QN26id45zieabEcfw8r+kDH2hyXEvDiwFOuoUJt2qT Z9X+9FF4KD2Tv9+RBJWNyj/Tw0WI2bjuRf0SVk4TdsZkM1HyyuNZRKtLN19p/WzHOUPJ 6bb+lujDyUxwgApxDEBMVbjr9rebNXOEBbnyWUGpboAMp1z1blNWwJGxal6kX59a+4MU pzGg7940QL4NezQa/qokU24/lVzuSdjtqEi5sQQb0mV5iOHFL3f4bXOdUEJEHpceQDO/ G3vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782292539; x=1782897339; 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=ntBcKJbPdr2BcshaOGmqAHXQMpCNp8GJ4XamSV4zy7Y=; b=nEwurOjROkno6ywMyznO6JfGJytFJKY3Bc0kGk6qO+LPj4z7VG0OmZojHVrrZVwskX 7tkoFIjEEeoVs4eQJDaC8raogWKV2zyaUJRUNJHMkFjmi2xH1wDst0SYVkYYPN7vjcu1 j6EtVOpNf+S/nOGriFVGs6PxScqo9rzinzoDFKTslaS33JhMLtVhfHfvD2FI/1KdjJXN Kv4sggefHwlVH+Rm678VaWgj7tF/JNLgcE99q1snUCGcjbRjiHwJ8bJ+53f4KyZfFNux 4f98YEZZxqK+N5cv6LNTW+KbyEv57+jzMiCs8sDZjRMhGdiAi5hik/7qMuWRDKyxUpP6 DW5g== X-Forwarded-Encrypted: i=1; AHgh+Rog4p9u2uKtlpMCxM2FWN1D0CzJ8CybjAkTCrQ4n9t8ir4UdWyrMXbOIXXtKF1dy21/gjCcssnGfI/e@lists.postgresql.org X-Gm-Message-State: AOJu0YwDI0OERiYHpGlcug6vWfNqKNXjrAiDcL6I1weeSOEb2h908LCr +SY4PkQv0iYXENfjrSVa6bIVRTlbM3P9jveiNIS9CXHtDNQAxh++plRK0joKkhwUPH+uuQ0XZIl 40y4gCfsSG5J+o5+Sc2GMZvqHCnw2NbQ= X-Gm-Gg: AfdE7cn2TR43If3D96o8r3+L45EZoSHSHljtgYWDV6ZvLqMTBQp45UspKnrGPh14ztL S38W/9KC8UXku3awJ1JE79QMMtcXPYXffGn1O9HYLNxAy3cOk3M76DU+4PNoBMb5F9CxXCofRqW 4DUBxBEetmuU+6a7deSNuXqlkTZNGi+O+ICIa9FNVfgHgvR0+bET9FkzE4SX4+hjLrhn0OSqdik 49anMnobgGFA8OkVz1Gt6TkarbduJN7HmX5veZbe5lc15PFf8xHCndpeo5+fjYx861MOZofh735 8Jt9wv04e7AU6KFlXZnk5LDprgoSdByML2THiO/CwTanZmxNiUkXaj/LbIeFV0ypHKVN6MqzDCJ Ukla2V91oI2ifNxtfuMvL304pCqYx+Q== X-Received: by 2002:a05:7300:2d15:b0:30c:52c5:6e52 with SMTP id 5a478bee46e88-30c6930b55fmr2916598eec.22.1782292538706; Wed, 24 Jun 2026 02:15:38 -0700 (PDT) MIME-Version: 1.0 References: <19484-a3cb82c8cde3c8fa@postgresql.org> In-Reply-To: From: Etsuro Fujita Date: Wed, 24 Jun 2026 18:15:25 +0900 X-Gm-Features: AVVi8CdO2-KOnsHjSstnIbAFJA_7J3-HgU1cBFQUND15-karPvo5dNm2XWymW34 Message-ID: Subject: Re: BUG #19484: Segmentation fault triggered by FDW To: Amit Langote Cc: Richard Guo , 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 Wed, Jun 24, 2026 at 1:25=E2=80=AFPM Amit Langote wrote: > On Wed, Jun 24, 2026 at 11:23=E2=80=AFAM Richard Guo wrote: > > On Wed, Jun 24, 2026 at 10:43=E2=80=AFAM Amit Langote wrote: > > > If we=E2=80=99d rather avoid it, I have a no-field alternative for RE= L_18: show_modifytable_info() is the only reader of the re-indexed list, an= d it can recompute the mapping from node->resultRelations and node->fdwPriv= Lists, 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->resultRelatio= ns. + * Initial pruning may have dropped earlier relations, so the k= ept + * 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) =3D=3D (int) rti) + { + fdw_private =3D (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