]> granicus.if.org Git - postgresql/commitdiff
Don't crash when pg_xlog is empty and pg_basebackup -x is used
authorMagnus Hagander <magnus@hagander.net>
Sat, 24 Aug 2013 15:11:31 +0000 (17:11 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sat, 24 Aug 2013 15:14:09 +0000 (17:14 +0200)
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

index b4ed64f24baab3856b126a96d097b3b58822754d..2fa1fc03bfca50303f6723f367159982876cb2c4 100644 (file)
@@ -297,6 +297,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.