postgresql/src
Tom Lane 5deadfef28 Fix misapplication of pgstat_count_truncate to wrong relation.
The stanza of ExecuteTruncate[Guts] that truncates a target table's toast
relation re-used the loop local variable "rel" to reference the toast rel.
This was safe enough when written, but commit d42358efb added code below
that that supposed "rel" still pointed to the parent table.  Therefore,
the stats counter update was applied to the wrong relcache entry (the
toast rel not the user rel); and if we were unlucky and that relcache
entry had been flushed during reindex_relation, very bad things could
ensue.

(I'm surprised that CLOBBER_CACHE_ALWAYS testing hasn't found this.
I'm even more surprised that the problem wasn't detected during the
development of d42358efb; it must not have been tested in any case
with a toast table, as the incorrect stats counts are very obvious.)

To fix, replace use of "rel" in that code branch with a more local
variable.  Adjust test cases added by d42358efb so that some of them
use tables with toast tables.

Per bug #15540 from Pan Bian.  Back-patch to 9.5 where d42358efb came in.

Discussion: https://postgr.es/m/15540-01078812338195c0@postgresql.org
2018-12-07 12:11:59 -05:00
..
backend Fix misapplication of pgstat_count_truncate to wrong relation. 2018-12-07 12:11:59 -05:00
bin Cleanup minor pg_dump memory leaks 2018-12-06 11:11:21 -05:00
common Improve our response to invalid format strings, and detect more cases. 2018-12-06 15:08:44 -05:00
fe_utils Fix translation of special characters in psql's LaTeX output modes. 2018-11-26 17:32:51 -05:00
include Cleanup comments in xlog compression 2018-12-06 11:05:39 -05:00
interfaces Eliminate parallel-make hazard in ecpg/preproc. 2018-12-01 17:19:51 -05:00
makefiles Add PGXS options to control TAP and isolation tests, take two 2018-12-03 09:27:35 +09:00
pl Fix some errhint and errdetail strings missing a period 2018-12-07 07:47:42 +09:00
port Improve our response to invalid format strings, and detect more cases. 2018-12-06 15:08:44 -05:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Fix misapplication of pgstat_count_truncate to wrong relation. 2018-12-07 12:11:59 -05:00
timezone Sync our copy of the timezone library with IANA release tzcode2018g. 2018-10-31 09:47:53 -04:00
tools Eliminate parallel-make hazard in ecpg/preproc. 2018-12-01 17:19:51 -05:00
tutorial Deduplicate "invalid input syntax" messages for various types. 2018-07-22 14:58:01 -07:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Remove useless symbol from Makefile.global. 2018-11-06 10:57:51 -05:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00