postgresql/src/backend
Tom Lane 5c27bce7f3 Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.
ExecReScanHashJoin will destroy the join's hash table if it expects
that the inner relation will produce different rows on rescan.
Up to now it's not bothered to clear the additional pointer to that
hash table that exists in the child HashState node.  However, it's
possible for the query to terminate without building a fresh hash
table (this happens if the outer relation is found to be empty
during the final rescan).  So we can end with a dangling pointer
to a deleted hash table.  That was harmless originally, but since
9.0 EXPLAIN ANALYZE has used that pointer to print hash table
statistics.  In debug builds this reproducibly results in garbage
statistics.  In non-debug builds there's frequently no ill effects,
but in principle one could get wrong EXPLAIN ANALYZE output, or
perhaps even a crash if free() has released the hashtable memory
back to the OS.

To fix, just make sure we clear the additional pointer when destroying
the hash table.  In problematic cases, EXPLAIN ANALYZE will then print
no hashtable statistics (reverting to its pre-9.0 behavior).  This isn't
ideal, but since the problem manifests only in unusual corner cases,
it's hard to justify taking any risks to do better in the back
branches.  A follow-on patch will improve matters in HEAD.

Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munro
of a trouble report from Alvaro Herrera.

Discussion: https://postgr.es/m/20200323165059.GA24950@alvherre.pgsql
2020-04-11 12:29:06 -04:00
..
access Allow parallel create index to accumulate buffer usage stats. 2020-04-09 09:49:30 +05:30
bootstrap Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
catalog Fix relcache reference leak 2020-04-11 09:44:14 +02:00
commands Fix collection of typos and grammar mistakes in the tree 2020-04-10 11:18:39 +09:00
executor Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case. 2020-04-11 12:29:06 -04:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit Extend ExecBuildAggTrans() to support a NULL pointer check. 2020-03-04 17:29:18 -08:00
lib Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
libpq Provide a TLS init hook 2020-03-25 17:13:17 -04:00
main Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nodes Revert 0f5ca02f53 2020-04-08 11:37:27 +03:00
optimizer Allow partitionwise join to handle nested FULL JOIN USING cases. 2020-04-07 22:12:14 -04:00
parser Fix CREATE TABLE LIKE INCLUDING GENERATED column order issue 2020-04-09 16:36:45 +02:00
partitioning Suppress unused-variable warning. 2020-04-10 12:00:28 -04:00
po Translation updates 2019-06-17 15:30:20 +02:00
port Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postmaster Fix collection of typos and grammar mistakes in the tree 2020-04-10 11:18:39 +09:00
regex Update copyrights for 2020 2020-01-01 12:21:45 -05:00
replication Fix RELCACHE_FORCE_RELEASE issue 2020-04-11 15:07:25 +02:00
rewrite Fix INSERT OVERRIDING USER VALUE behavior 2020-03-31 08:50:39 +02:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Modify additional power 2 calculations to use new helper functions 2020-04-08 18:29:51 +12:00
storage Revert 0f5ca02f53 2020-04-08 11:37:27 +03:00
tcop Revert 0f5ca02f53 2020-04-08 11:37:27 +03:00
tsearch Further cleanup of ts_headline code. 2020-04-09 15:38:43 -04:00
utils Allow publishing partition changes via ancestors 2020-04-08 11:19:23 +02:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2019-05-20 16:00:53 +02:00