From: Euler Taveira <euler@eulerto.com>
To: webbohan@qq.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19073: there are meaningless code in _SPI_execute_plan() when canSetTag is true
Date: Sun, 05 Oct 2025 11:47:59 -0300
Message-ID: <5b04da16-c2de-464b-8677-9e4991b28e55@app.fastmail.com> (raw)
In-Reply-To: <19073-93772b97a2f1ecf3@postgresql.org>
References: <19073-93772b97a2f1ecf3@postgresql.org>
On Sat, Oct 4, 2025, at 11:29 PM, PG Bug reporting form wrote:
> In function _SPI_execute_plan(), `my_tuptable` is local variable and
> initialized as NULL.
> If plan is canSetTag subqueries, `SPI_freetuptable(my_tuptable)` is
> meaningless, because `my_tuptable` is NULL.
> We'd better remove this code.
>
There could be multiple statements. The first case will call SPI_freetuptable()
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 before
reusing it. That's exactly what the comment says.
/*
* The last canSetTag query sets the status values returned to the
* caller. Be careful to free any tuptables not returned, to
* avoid intra-transaction memory leak.
*/
if (canSetTag)
{
my_processed = _SPI_current->processed;
SPI_freetuptable(my_tuptable);
my_tuptable = _SPI_current->tuptable;
my_res = res;
}
--
Euler Taveira
EDB https://www.enterprisedb.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: euler@eulerto.com, 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>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox