postgresql/src/bin/pg_upgrade
Tom Lane 66e203c851 Repair pg_upgrade's failure to preserve relfrozenxid for matviews.
This oversight led to data corruption in matviews, manifesting as
"could not access status of transaction" before our most recent releases,
and "found xmin from before relfrozenxid" errors since then.

The proximate cause of the problem seems to have been confusion between
the task of preserving dropped-column status and the task of preserving
frozenxid status.  Those are required for distinct sets of relkinds,
and the reasoning was entirely undocumented in the source code.  In hopes
of forestalling future errors of the same kind, try to improve the
commentary in this area.

In passing, also improve the remarkably unhelpful comments around
pg_upgrade's set_frozenxids().  That's not actually buggy AFAICS,
but good luck figuring out what it does from the old comments.

Per report from Claudio Freire.  It appears that bug #14852 from Alexey
Ermakov is an earlier report of the same issue, and there may be other
cases that we failed to identify at the time.

Patch by me based on analysis by Andres Freund.  The bug dates back
to the introduction of matviews, so back-patch to all supported branches.

Discussion: https://postgr.es/m/CAGTBQpbrY9CdRGGhyBZ9yqY4jWaGC85rUF4X+R7d-aim=mBNsw@mail.gmail.com
Discussion: https://postgr.es/m/20171013115320.28049.86457@wrigleys.postgresql.org
2018-02-21 18:40:24 -05:00
..
.gitignore Move pg_upgrade from contrib/ to src/bin/ 2015-04-14 19:26:38 -04:00
check.c pg_upgrade: start/stop new server after pg_resetwal 2017-06-20 13:20:02 -04:00
controldata.c Improve error reporting in pg_upgrade's file copying/linking/rewriting. 2016-09-30 20:40:27 -04:00
dump.c Ensure that all temp files made during pg_upgrade are non-world-readable. 2018-02-05 10:58:27 -05:00
exec.c pg_upgrade: simplify code layout in a few places 2018-01-05 14:11:15 -05:00
file.c Ensure that all temp files made during pg_upgrade are non-world-readable. 2018-02-05 10:58:27 -05:00
function.c Enforce a specific order for probing library loadability in pg_upgrade. 2016-10-03 10:07:39 -04:00
IMPLEMENTATION Move pg_upgrade from contrib/ to src/bin/ 2015-04-14 19:26:38 -04:00
info.c Improve pg_upgrade's report about failure to match up old and new tables. 2016-05-06 14:45:01 -04:00
Makefile Fix broken link-command-line ordering for libpgfeutils. 2017-07-14 12:26:53 -04:00
option.c Improve error reporting in pg_upgrade's file copying/linking/rewriting. 2016-09-30 20:40:27 -04:00
parallel.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
pg_upgrade.c Repair pg_upgrade's failure to preserve relfrozenxid for matviews. 2018-02-21 18:40:24 -05:00
pg_upgrade.h Ensure that all temp files made during pg_upgrade are non-world-readable. 2018-02-05 10:58:27 -05:00
relfilenode.c Improve error reporting in pg_upgrade's file copying/linking/rewriting. 2016-09-30 20:40:27 -04:00
server.c pg_upgrade: Fix for changed pg_ctl default stop mode 2017-01-13 16:19:48 -05:00
tablespace.c Improve error reporting in pg_upgrade's file copying/linking/rewriting. 2016-09-30 20:40:27 -04:00
test.sh Obstruct shell, SQL, and conninfo injection via database and role names. 2016-08-08 10:07:46 -04:00
TESTING Move pg_upgrade from contrib/ to src/bin/ 2015-04-14 19:26:38 -04:00
util.c pg_rewing pg_upgrade: Fix translation markers 2016-11-07 09:53:55 -05:00
version.c Improve error reporting in pg_upgrade's file copying/linking/rewriting. 2016-09-30 20:40:27 -04:00