pgsql: Fix another ancient memory-leak bug in relcache.c.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix another ancient memory-leak bug in relcache.c.
Date: 2014-08-24 15:56:55
Message-ID: E1XLaA3-0002kn-Hr@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix another ancient memory-leak bug in relcache.c.

CheckConstraintFetch() leaked a cstring in the caller's context for each
CHECK constraint expression it copied into the relcache. Ordinarily that
isn't problematic, but it can be during CLOBBER_CACHE testing because so
many reloads can happen during a single query; so complicate the code
slightly to allow freeing the cstring after use. Per testing on buildfarm
member barnacle.

This is exactly like the leak fixed in AttrDefaultFetch() by commit
078b2ed291c758e7125d72c3a235f128d40a232b. (Yes, this time I did look for
other instances of the same coding pattern :-(.) Like that patch, no
back-patch, since it seems unlikely that there's any problem except under
very artificial test conditions.

BTW, it strikes me that both of these places would require further work
comparable to commit ab8c84db2f7af008151b848cf1d6a4672a39eecd, if we ever
supported defaults or check constraints on system catalogs: they both
assume they are copying into an empty relcache data structure, and that
conceivably wouldn't be the case during recursive reloading of a system
catalog. This does not seem worth worrying about for the moment, since
there is no near-term prospect of supporting any such thing. So I'll
just note the possibility for the archives' sake.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/73eba19aebe0101837668e39267469ca34373552

Modified Files
--------------
src/backend/utils/cache/relcache.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-08-25 16:18:24 pgsql: Don't track DEALLOCATE in pg_stat_statements.
Previous Message Andrew Dunstan 2014-08-23 20:03:28 Re: pgsql: Implement ALTER TABLE .. SET LOGGED / UNLOGGED