postgresql/src
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
..
backend Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case. 2020-04-11 12:29:06 -04:00
bin Exclude backup_manifest file that existed in database, from BASE_BACKUP. 2020-04-09 22:37:11 +09:00
common Add checksum helper functions. 2020-04-03 11:52:43 -04:00
fe_utils Add SQL type xid8 to expose FullTransactionId to users. 2020-04-07 12:03:59 +12:00
include Fix collection of typos and grammar mistakes in the tree 2020-04-10 11:18:39 +09:00
interfaces Allow ecpg to be built stand-alone, allow parallel libpq make 2020-03-31 14:17:32 -04:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Improve user control over truncation of logged bind-parameter values. 2020-04-02 15:04:51 -04:00
port Be more careful about extracting encoding from locale strings on Windows. 2020-03-30 11:14:58 -04:00
template Fix compiler warning for ppoll() on Cygwin 2019-12-22 23:20:00 +01:00
test Further stabilize results of 019_replslot_limit.pl. 2020-04-09 17:28:58 -04:00
timezone Require stdint.h 2020-02-21 09:20:32 +01:00
tools Revert 0f5ca02f53 2020-04-08 11:37:27 +03:00
tutorial Update copyrights for 2020 2020-01-01 12:21:45 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00