diff options
author | Magnus Hagander | 2013-08-24 15:11:31 +0000 |
---|---|---|
committer | Magnus Hagander | 2013-08-24 15:14:09 +0000 |
commit | 3979ff1fc6e9dd7847ff9bb24beb4d03ebe02cef (patch) | |
tree | 1b1d357c436fbb770477ca28730bec7cfe97c559 | |
parent | bd5ab4b28745605493ab7061724ba0375ee9593a (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.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index b4ed64f24ba..2fa1fc03bfc 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -298,6 +298,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. */ |