Re: Avoid use scoped block variable

Tomas Vondra <tomas@vondra.me>

From: Tomas Vondra <tomas@vondra.me>
To: Ranier Vilela <ranier.vf@gmail.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2025-12-09T16:20:48Z
Lists: pgsql-hackers
On 12/9/25 17:06, Ranier Vilela wrote:
> Hi.
> 
> I noticed a possible violation of C rules.
> Some functions rely on local block variables, 
> but this are a mistake.
> Once that block exits, the memory of the variable is released.
> 
> Fix by moving the declaration variables.
> 

When you say "possible violation", did you check the issue is real?

All these places call CStringGetTextDatum, which calls cstring_to_text,
which allocates a new varlena copy of the string. So why is this an
issue, exactly?


regards

-- 
Tomas Vondra