pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #19073: there are meaningless code in _SPI_execute_plan() when canSetTag is true
3+ messages / 3 participants
[nested] [flat]
* BUG #19073: there are meaningless code in _SPI_execute_plan() when canSetTag is true
@ 2025-10-05 02:29 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: PG Bug reporting form @ 2025-10-05 02:29 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: webbohan@qq.com
The following bug has been logged on the website:
Bug reference: 19073
Logged by: Webbo Han
Email address: webbohan@qq.com
PostgreSQL version: 18.0
Operating system: all
Description:
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #19073: there are meaningless code in _SPI_execute_plan() when canSetTag is true
@ 2025-10-05 14:47 Euler Taveira <euler@eulerto.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: Euler Taveira @ 2025-10-05 14:47 UTC (permalink / raw)
To: webbohan@qq.com; pgsql-bugs@lists.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/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #19073: there are meaningless code in _SPI_execute_plan() when canSetTag is true
@ 2025-10-05 15:48 Tom Lane <tgl@sss.pgh.pa.us>
parent: Euler Taveira <euler@eulerto.com>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2025-10-05 15:48 UTC (permalink / raw)
To: Euler Taveira <euler@eulerto.com>; +Cc: webbohan@qq.com; pgsql-bugs@lists.postgresql.org
"Euler Taveira" <euler@eulerto.com> 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_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.
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2025-10-05 15:48 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-10-05 02:29 BUG #19073: there are meaningless code in _SPI_execute_plan() when canSetTag is true PG Bug reporting form <noreply@postgresql.org>
2025-10-05 14:47 ` Euler Taveira <euler@eulerto.com>
2025-10-05 15:48 ` Tom Lane <tgl@sss.pgh.pa.us>
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