postgresql/src
Andres Freund a15ad67089 Fix ALTER TABLE ... SET TABLESPACE for unlogged relations.
Changing the tablespace of an unlogged relation did not WAL log the
creation and content of the init fork. Thus, after a standby is
promoted, unlogged relation cannot be accessed anymore, with errors
like:
ERROR:  58P01: could not open file "pg_tblspc/...": No such file or directory
Additionally the init fork was not synced to disk, independent of the
configured wal_level, a relatively small durability risk.

Investigation of that problem also brought to light that, even for
permanent relations, the creation of !main forks was not WAL logged,
i.e. no XLOG_SMGR_CREATE record were emitted. That mostly turns out not
to be a problem, because these files were created when the actual
relation data is copied; nonexistent files are not treated as an error
condition during replay. But that doesn't work for empty files, and
generally feels a bit haphazard. Luckily, outside init and main forks,
empty forks don't occur often or are not a problem.

Add the required WAL logging and syncing to disk.

Reported-By: Michael Paquier
Author: Michael Paquier and Andres Freund
Discussion: 20151210163230.GA11331@alap3.anarazel.de
Backpatch: 9.1, where unlogged relations were introduced
2015-12-12 14:19:51 +01:00
..
backend Fix ALTER TABLE ... SET TABLESPACE for unlogged relations. 2015-12-12 14:19:51 +01:00
bin Be more paranoid about null return values from libpq status functions. 2015-11-25 17:31:54 -05:00
include Fix bug leading to restoring unlogged relations from empty files. 2015-12-10 16:29:27 +01:00
interfaces Use "g" not "f" format in ecpg's PGTYPESnumeric_from_double(). 2015-12-01 11:42:47 -05:00
makefiles Don't use deprecated dllwrap on Cygwin. 2014-02-01 16:13:46 -05:00
pl PL/Python: Make tests pass with Python 3.5 2015-11-14 13:53:26 -05:00
port Adopt the GNU convention for handling tar-archive members exceeding 8GB. 2015-11-21 20:21:32 -05:00
template AIX: Test the -qlonglong option before use. 2015-07-17 03:02:18 -04:00
test Add an expected-file to match behavior of latest libxml2. 2015-12-11 19:08:40 -05:00
timezone Update time zone data files to tzdata release 2015g. 2015-10-02 19:16:18 -04:00
tools Accept flex > 2.5.x on Windows, too. 2015-12-10 10:19:31 -05:00
tutorial Remove tabs after spaces in C comments 2014-05-06 11:26:27 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix some oversights in distprep and maintainer-clean targets. 2011-03-10 00:04:05 -05:00
Makefile.global.in Make numeric form of PG version number readily available in Makefiles. 2015-07-05 12:01:01 -04:00
Makefile.shlib Unlink static libraries before rebuilding them. 2015-03-01 13:07:00 -05:00
nls-global.mk Lots of doc corrections. 2012-04-23 22:43:09 -04:00
win32.mak Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00