Re: Fixing memory leaks in postgres_fdw

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Matheus Alcantara <matheusssilv97@gmail.com>
Cc: Etsuro Fujita <etsuro.fujita@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-05-29T13:17:52Z
Lists: pgsql-hackers
Matheus Alcantara <matheusssilv97@gmail.com> writes:
> The only point is that I've just tried to apply the v5-0001 on top of
> the previous v4-000X patches and is raising an error:
>   git am v5-0001-Avoid-resource-leaks-when-a-dblink-connection-fai.patch
> Applying: Avoid resource leaks when a dblink connection fails.
> error: patch failed: contrib/dblink/dblink.c:105
> error: contrib/dblink/dblink.c: patch does not apply
> Patch failed at 0001 Avoid resource leaks when a dblink connection fails.

Yeah, it's not intended to be done in that order: the v5-0001 patch is
an independent thing.  I anticipate I'll have to rebase the other
patches after I push v5-0001.

Thanks for looking at it!

			regards, tom lane



Commits

  1. Silence leakage complaint about postgres_fdw's InitPgFdwOptions.

  2. Run pgindent on the changes of the previous patch.

  3. Reap the benefits of not having to avoid leaking PGresults.

  4. Create infrastructure to reliably prevent leakage of PGresults.

  5. Fix memory leakage in postgres_fdw's DirectModify code path.

  6. Avoid resource leaks when a dblink connection fails.