summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2013-08-24 15:11:31 +0000
committerMagnus Hagander2013-08-24 15:14:18 +0000
commit3cf89057b5bced4478a285e0b49e321996b40044 (patch)
treee7060791441855db67a0f1711112e3285972082a
parentc19617d5355e41074623bbb7c3efda532c20f637 (diff)
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
-rw-r--r--src/backend/replication/basebackup.c8
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.
*/