postgresql/contrib/pg_upgrade
Tom Lane d3b0a23a20 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 Update .gitignore for pg_upgrade 2014-12-17 11:59:29 +01:00
check.c pg_upgrade: start/stop new server after pg_resetwal 2017-06-20 13:20:02 -04:00
controldata.c Fix spelling mistake. 2016-01-14 23:16:11 -05: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 Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04: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 Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
IMPLEMENTATION Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
info.c pg_dump, pg_upgrade: allow postgres/template1 tablespace moves 2015-09-11 15:51:10 -04:00
Makefile Fix pg_dump to handle inherited NOT VALID check constraints correctly. 2015-10-01 16:19:49 -04:00
option.c Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
page.c Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
parallel.c pg_upgrade: clarify C comment about Windows thread struct pointers 2013-07-30 09:23:31 -04: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 Fix new warnings from GCC 7 2017-05-15 13:31:38 -04:00
server.c Obstruct shell, SQL, and conninfo injection via database and role names. 2016-08-08 10:07:52 -04:00
tablespace.c pg_upgrade: throw an error for non-existent tablespace directories 2014-04-17 11:42:21 -04:00
test.sh Obstruct shell, SQL, and conninfo injection via database and role names. 2016-08-08 10:07:52 -04:00
TESTING Remove whitespace from end of lines 2012-05-15 22:19:41 +03:00
util.c Obstruct shell, SQL, and conninfo injection via database and role names. 2016-08-08 10:07:52 -04:00
version.c Obstruct shell, SQL, and conninfo injection via database and role names. 2016-08-08 10:07:52 -04:00
version_old_8_3.c Obstruct shell, SQL, and conninfo injection via database and role names. 2016-08-08 10:07:52 -04:00