Re: [PATCH v1] fix potential memory leak in untransformRelOptions

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: Junwang Zhao <zhjwpku@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-09-01T12:14:52Z
Lists: pgsql-hackers
> On 1 Sep 2022, at 10:36, Junwang Zhao <zhjwpku@gmail.com> wrote:

> *TextDatumGetCString* calls palloc to alloc memory for the option
> text datum, in some cases the the memory is allocated in
> *TopTransactionContext*, this may cause memory leak for a long
> running backend.

Wouldn't that be a fairly small/contained leak in comparison to memory spent
during a long running transaction?  Do you have any example of transforming
reloptions in a loop into TopTransactionContext where it might add up?

--
Daniel Gustafsson		https://vmware.com/




Commits

  1. Remove useless pstrdups in untransformRelOptions