postgres.git / summary / log / commit / refs

commit    db4ef737606e340479d68f63f33bc7d21f937ca7
Author:   Magnus Hagander <magnus@hagander.net>
Date:     Sat Aug 24 15:11:31 2013 +0000
First released in: 9.4.0, 9.2.5, 9.3.0

    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


src/backend/replication/basebackup.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 @@ -303,6 +303,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. [parent: fcf9ecad5753]