summaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/pg_recvlogical.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-07-12 22:06:27 +0200
committerAndres Freund <andres@anarazel.de>2015-07-12 22:15:20 +0200
commitff27db5dd2fc096d89d3f995d3f650ec6d3bc147 (patch)
tree4e57e6befd68986468c4547a136ef9f6011ba65d /src/bin/pg_basebackup/pg_recvlogical.c
parent0a0fe2ff6ef65e3a1cf4d83d96eab144477a0220 (diff)
Optionally don't error out due to preexisting slots in commandline utilities.
pg_receivexlog and pg_recvlogical error out when --create-slot is specified and a slot with the same name already exists. In some cases, especially with pg_receivexlog, that's rather annoying and requires additional scripting. Backpatch to 9.5 as slot control functions have newly been added to pg_receivexlog, and there doesn't seem much point leaving it in a less useful state. Discussion: 20150619144755.GG29350@alap3.anarazel.de
Diffstat (limited to 'src/bin/pg_basebackup/pg_recvlogical.c')
-rw-r--r--src/bin/pg_basebackup/pg_recvlogical.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c
index 50844e700d9..f189f71eff6 100644
--- a/src/bin/pg_basebackup/pg_recvlogical.c
+++ b/src/bin/pg_basebackup/pg_recvlogical.c
@@ -38,6 +38,7 @@ static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
static int fsync_interval = 10 * 1000; /* 10 sec = default */
static XLogRecPtr startpos = InvalidXLogRecPtr;
static bool do_create_slot = false;
+static bool slot_exists_ok = false;
static bool do_start_slot = false;
static bool do_drop_slot = false;
@@ -75,6 +76,7 @@ usage(void)
printf(_(" -f, --file=FILE receive log into this file, - for stdout\n"));
printf(_(" -F --fsync-interval=SECS\n"
" time between fsyncs to the output file (default: %d)\n"), (fsync_interval / 1000));
+ printf(_(" --if-not-exists do not treat naming conflicts as an error when creating a slot\n"));
printf(_(" -I, --startpos=LSN where in an existing slot should the streaming start\n"));
printf(_(" -n, --no-loop do not loop on connection lost\n"));
printf(_(" -o, --option=NAME[=VALUE]\n"
@@ -633,6 +635,7 @@ main(int argc, char **argv)
{"create-slot", no_argument, NULL, 1},
{"start", no_argument, NULL, 2},
{"drop-slot", no_argument, NULL, 3},
+ {"if-not-exists", no_argument, NULL, 4},
{NULL, 0, NULL, 0}
};
int c;
@@ -764,6 +767,9 @@ main(int argc, char **argv)
case 3:
do_drop_slot = true;
break;
+ case 4:
+ slot_exists_ok = true;
+ break;
default:
@@ -891,8 +897,9 @@ main(int argc, char **argv)
progname, replication_slot);
if (!CreateReplicationSlot(conn, replication_slot, plugin,
- &startpos, false))
+ false, slot_exists_ok))
disconnect_and_exit(1);
+ startpos = InvalidXLogRecPtr;
}
if (!do_start_slot)