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.94.2) (envelope-from ) id 1v5Qyd-006nAr-2r for pgsql-bugs@arkaria.postgresql.org; Sun, 05 Oct 2025 15:48:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v5Qya-002rxn-Fi for pgsql-bugs@arkaria.postgresql.org; Sun, 05 Oct 2025 15:48:45 +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.94.2) (envelope-from ) id 1v5Qya-002rxf-7O for pgsql-bugs@lists.postgresql.org; Sun, 05 Oct 2025 15:48:45 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v5QyY-000WoF-15 for pgsql-bugs@lists.postgresql.org; Sun, 05 Oct 2025 15:48:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 595FmXeg1680817; Sun, 5 Oct 2025 11:48:33 -0400 From: Tom Lane To: "Euler Taveira" cc: webbohan@qq.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19073: there are meaningless code in _SPI_execute_plan() when canSetTag is true In-reply-to: <5b04da16-c2de-464b-8677-9e4991b28e55@app.fastmail.com> References: <19073-93772b97a2f1ecf3@postgresql.org> <5b04da16-c2de-464b-8677-9e4991b28e55@app.fastmail.com> Comments: In-reply-to "Euler Taveira" message dated "Sun, 05 Oct 2025 11:47:59 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1680815.1759679313.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 05 Oct 2025 11:48:33 -0400 Message-ID: <1680816.1759679313@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Euler Taveira" writes: > On Sat, Oct 4, 2025, at 11:29 PM, PG Bug reporting form wrote: >> If plan is canSetTag subqueries, `SPI_freetuptable(my_tuptable)` is >> meaningless, because `my_tuptable` is NULL. > There could be multiple statements. The first case will call SPI_freetup= table() > and it is a noop. The code path you are referring to is inside a foreach= loop > and a previous statement might set my_tuptable and needs to be freed bef= ore > reusing it. That's exactly what the comment says. Yeah. You'd only reach this case if there were multiple SQL statements in the string given to SPI_execute() or similar, but that's perfectly legal. regards, tom lane