postgresql/src
Tom Lane aedd3d4dbd 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:12:00 -05:00
..
backend Fix misapplication of pgstat_count_truncate to wrong relation. 2018-12-07 12:12:00 -05:00
bin Fix various checksum check problems for pg_verify_checksums and base backups 2018-11-30 10:34:56 +09: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 PANIC on fsync() failure. 2018-11-19 13:37:59 +13:00
interfaces Second try at fixing numeric data passed through an ECPG SQLDA. 2018-11-14 11:27:30 -05:00
makefiles Refactor installation of extension headers. 2018-09-07 14:30:15 +01:00
pl Fix error-cleanup mistakes in exec_stmt_call(). 2018-11-09 22:04:14 -05:00
port Stamp 11.1. 2018-11-05 16:43:09 -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:12:00 -05:00
timezone Sync our copy of the timezone library with IANA release tzcode2018g. 2018-10-31 09:48:04 -04:00
tools Add valgrind suppressions for wcsrtombs optimizations 2018-11-18 00:08:19 +01:00
tutorial Update copyright for 2018 2018-01-02 23:30:12 -05: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 Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04: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