diff options
author | Magnus Hagander <magnus@hagander.net> | 2013-08-24 17:11:31 +0200 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2013-08-24 17:13:49 +0200 |
commit | db4ef737606e340479d68f63f33bc7d21f937ca7 (patch) | |
tree | b545e133b1731f2ae3d3136f3f54720ed2f88fc8 /src/backend/replication/basebackup.c | |
parent | fcf9ecad575302fe3b9fe7cd269c9c153817b16c (diff) | |
download | postgresql-db4ef737606e340479d68f63f33bc7d21f937ca7.tar.gz postgresql-db4ef737606e340479d68f63f33bc7d21f937ca7.zip |
Don't crash when pg_xlog is empty and pg_basebackup -x is used
The backup will not work (without a logarchive, and that's the whole
point of -x) in this case, this patch just changes it to throw an
error instead of crashing when this happens.
Noticed and diagnosed by TAKATSUKA Haruka
Diffstat (limited to 'src/backend/replication/basebackup.c')
-rw-r--r-- | src/backend/replication/basebackup.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index 12b5e24cac5..ba8d173357e 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -304,6 +304,14 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir) qsort(walFiles, nWalFiles, sizeof(char *), compareWalFileNames); /* + * There must be at least one xlog file in the pg_xlog directory, + * since we are doing backup-including-xlog. + */ + if (nWalFiles < 1) + ereport(ERROR, + (errmsg("could not find any WAL files"))); + + /* * Sanity check: the first and last segment should cover startptr and * endptr, with no gaps in between. */ |