Re: Avoid use scoped block variable

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid use scoped block variable
Date: 2025-12-09 16:20:48
Message-ID: b5f92b03-70d6-4958-b9b0-111fab0f2ab6@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-12-09 16:20:57 Mark function arguments of type "T *" as "const T *" where possible
Previous Message Andres Freund 2025-12-09 16:19:06 Re: Avoid use scoped block variable