pgsql: Silence leakage complaint about postgres_fdw's InitPgFdwOptions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Silence leakage complaint about postgres_fdw's InitPgFdwOptions.
Date: 2025-07-25 20:42:52
Message-ID: E1ufPFk-000j9L-0O@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Silence leakage complaint about postgres_fdw's InitPgFdwOptions.

Valgrind complains that the PQconninfoOption array returned by libpq
is leaked. We apparently believed that we could suppress that warning
by storing that array's address in a static variable. However, modern
C compilers are bright enough to optimize the static variable away.

We could escalate that arms race by making the variable global.
But on the whole it seems better to revise the code so that it
can free libpq's result properly. The only thing that costs
us is copying the parameter-name keywords; which seems like a
pretty negligible cost in a function that runs at most once per
process.

Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Discussion: https://postgr.es/m/2976982.1748049023@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0f9d4d7c12dcebe951061763ca23ee3b6477e7ca

Modified Files
--------------
contrib/postgres_fdw/option.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-07-25 20:46:12 pgsql: Add commit 73873805f to .git-blame-ignore-revs.
Previous Message Tom Lane 2025-07-25 14:57:04 pgsql: Fix dynahash's HASH_FIXED_SIZE ("isfixed") option.