postgresql/contrib
Tom Lane a3bed62d44 Fix low-probability leaks of PGresult objects in the backend.
We had three occurrences of essentially the same coding pattern
wherein we tried to retrieve a query result from a libpq connection
without blocking.  In the case where PQconsumeInput failed (typically
indicating a lost connection), all three loops simply gave up and
returned, forgetting to clear any previously-collected PGresult
object.  Since those are malloc'd not palloc'd, the oversight results
in a process-lifespan memory leak.

One instance, in libpqwalreceiver, is of little significance because
the walreceiver process would just quit anyway if its connection fails.
But we might as well fix it.

The other two instances, in postgres_fdw, are somewhat more worrisome
because at least in principle the scenario could be repeated, allowing
the amount of memory leaked to build up to something worth worrying
about.  Moreover, in these cases the loops contain CHECK_FOR_INTERRUPTS
calls, as well as other calls that could potentially elog(ERROR),
providing another way to exit without having cleared the PGresult.
Here we need to add PG_TRY logic similar to what exists in quite a
few other places in postgres_fdw.

Coverity noted the libpqwalreceiver bug; I found the other two cases
by checking all calls of PQconsumeInput.

Back-patch to all supported versions as appropriate (9.2 lacks
postgres_fdw, so this is really quite unexciting for that branch).

Discussion: https://postgr.es/m/22620.1497486981@sss.pgh.pa.us
2017-06-15 15:03:52 -04:00
..
adminpack Use wrappers of PG_DETOAST_DATUM_PACKED() more. 2017-03-12 19:35:34 -04:00
amcheck amcheck: Harden tests against concurrent autovacuums. 2017-03-14 13:07:38 -07:00
auth_delay Consistently declare timestamp variables as TimestampTz. 2017-02-23 15:57:08 -05:00
auto_explain Allow for parallel execution whenever ExecutorRun() is done only once. 2017-03-23 13:14:36 -04:00
bloom Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
btree_gin Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
btree_gist Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
chkpass
citext Optimize joins when the inner relation can be proven unique. 2017-04-07 22:20:13 -04:00
cube Fix typos in comments. 2017-02-06 11:33:58 +02:00
dblink Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
dict_int
dict_xsyn
earthdistance Remove support for version-0 calling conventions. 2017-03-30 06:25:46 -07:00
file_fdw Reset API of clause_selectivity() 2017-04-06 19:10:51 -04:00
fuzzystrmatch Use wrappers of PG_DETOAST_DATUM_PACKED() more. 2017-03-12 19:35:34 -04:00
hstore Assume deconstruct_array() outputs are untoasted. 2017-03-12 19:35:31 -04:00
hstore_plperl psql: Use more consistent capitalization of some output headings 2017-06-13 14:41:14 -04:00
hstore_plpython Drop support for Python 2.3 2017-02-21 09:49:22 -05:00
intagg
intarray Post-PG 10 beta1 pgperltidy run 2017-05-17 19:01:23 -04:00
isn Fix wording in amvalidate error messages 2017-05-30 15:45:42 -04:00
lo Move atooid() definition to a central place 2017-03-01 11:55:28 -05:00
ltree Spelling fixes 2017-03-14 12:58:39 -04:00
ltree_plpython Code review for avoidance of direct cross-module links. 2017-02-02 11:21:16 -05:00
oid2name Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
pageinspect Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
passwordcheck Remove support for password_encryption='off' / 'plain'. 2017-05-08 11:26:07 +03:00
pg_buffercache Default monitoring roles 2017-03-30 14:18:53 -04:00
pg_freespacemap Default monitoring roles 2017-03-30 14:18:53 -04:00
pg_prewarm Use wrappers of PG_DETOAST_DATUM_PACKED() more. 2017-03-12 19:35:34 -04:00
pg_standby Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
pg_stat_statements Improve castNode notation by introducing list-extraction-specific variants. 2017-04-10 13:51:53 -04:00
pg_trgm Further fix pg_trgm's extraction of trigrams from regular expressions. 2017-04-14 14:52:21 -04:00
pg_visibility Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
pgcrypto Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
pgrowlocks Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
pgstattuple Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
postgres_fdw Fix low-probability leaks of PGresult objects in the backend. 2017-06-15 15:03:52 -04:00
seg Move contrib/seg to only use V1 calling conventions. 2017-03-30 06:25:46 -07:00
sepgsql Fix contrib/sepgsql regr tests for tup-routing constraint check change. 2017-06-07 17:54:33 -07:00
spi Spelling fixes in code comments 2017-03-14 12:58:39 -04:00
sslinfo Use wrappers of PG_DETOAST_DATUM_PACKED() more. 2017-03-12 19:35:34 -04:00
start-scripts Fix typos in comments. 2017-02-06 11:33:58 +02:00
tablefunc
tcn
test_decoding Fix race condition leading to hanging logical slot creation. 2017-05-13 14:21:00 -07:00
tsm_system_rows
tsm_system_time
unaccent Use wrappers of PG_DETOAST_DATUM_PACKED() more. 2017-03-12 19:35:34 -04:00
uuid-ossp Use wrappers of PG_DETOAST_DATUM_PACKED() more. 2017-03-12 19:35:34 -04:00
vacuumlo Fix hard-coded relkind constants in assorted other files. 2017-03-09 23:36:52 -05:00
xml2 Use wrappers of PG_DETOAST_DATUM_PACKED() more. 2017-03-12 19:35:34 -04:00
contrib-global.mk
Makefile Add amcheck extension to contrib. 2017-03-09 16:33:02 -08:00
README

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.