diff --git a/doc/src/sgml/ref/pg_receivexlog.sgml b/doc/src/sgml/ref/pg_receivexlog.sgml
index a4c9892..451e6d4 100644
--- a/doc/src/sgml/ref/pg_receivexlog.sgml
+++ b/doc/src/sgml/ref/pg_receivexlog.sgml
@@ -93,16 +93,6 @@ PostgreSQL documentation
-
-
-
- Do not not error out when is specified
- and a slot with the specified name already exists.
-
-
-
-
-
@@ -273,7 +263,7 @@ PostgreSQL documentation
Create a new physical replication slot with the name specified in
- , then start to stream WAL.
+ , then exit.
diff --git a/doc/src/sgml/ref/pg_recvlogical.sgml b/doc/src/sgml/ref/pg_recvlogical.sgml
index 4eda9eb..3686acf 100644
--- a/doc/src/sgml/ref/pg_recvlogical.sgml
+++ b/doc/src/sgml/ref/pg_recvlogical.sgml
@@ -44,63 +44,6 @@ PostgreSQL documentation
Options
- At least one of the following options must be specified to select an action:
-
-
-
-
-
-
-
- Create a new logical replication slot with the name specified by
- , using the output plugin specified by
- , for the database specified
- by .
-
-
-
-
-
-
-
-
- Drop the replication slot with the name specified
- by , then exit.
-
-
-
-
-
-
-
-
- Begin streaming changes from the logical replication slot specified
- by , continuing until terminated by a
- signal. If the server side change stream ends with a server shutdown
- or disconnect, retry in a loop unless
- is specified.
-
-
-
- The stream format is determined by the output plugin specified when
- the slot was created.
-
-
-
- The connection must be to the same database used to create the slot.
-
-
-
-
-
-
-
- and can be
- specified together. cannot be combined with
- another action.
-
-
-
The following command-line options control the location and format of the
output and other replication behavior:
@@ -146,30 +89,20 @@ PostgreSQL documentation
- In mode, start replication from the given
- LSN. For details on the effect of this, see the documentation
- in
+ Start replication from the given LSN. For details on the effect of
+ this, see the documentation in
and . Ignored in other modes.
-
-
-
- Do not not error out when is specified
- and a slot with the specified name already exists.
-
-
-
-
-
- When the connection to the server is lost, do not retry in a loop, just exit.
+ When the connection to the server is lost, do not retry in a loop,
+ just exit.
@@ -214,7 +147,7 @@ PostgreSQL documentation
- In mode, use the existing logical replication slot named
+ Use the existing logical replication slot named
slot_name. In
mode, create the slot with this name. In
mode, delete the slot with this name.
@@ -328,6 +261,49 @@ PostgreSQL documentation
+ pg_recvlogical can perform one of the two
+ following actions in order to control logical replication slots:
+
+
+
+
+
+
+ Create a new logical replication slot with the name specified by
+ , using the output plugin specified by
+ , for the database specified
+ by , then exit.
+
+
+
+
+
+
+
+
+ Drop the replication slot with the name specified
+ by , then exit.
+
+
+
+
+
+
+
+ The stream format is determined by the output plugin specified when
+ the slot was created.
+
+
+
+ The connection must be to the same database used to create the slot.
+
+
+
+ and cannot
+ be combined together.
+
+
+
The following additional options are available:
diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c
index 00536bd..0fde0f0 100644
--- a/src/bin/pg_basebackup/pg_receivexlog.c
+++ b/src/bin/pg_basebackup/pg_receivexlog.c
@@ -38,7 +38,6 @@ static int noloop = 0;
static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
static volatile bool time_to_abort = false;
static bool do_create_slot = false;
-static bool slot_exists_ok = false;
static bool do_drop_slot = false;
static bool synchronous = false;
@@ -67,7 +66,6 @@ usage(void)
printf(_(" %s [OPTION]...\n"), progname);
printf(_("\nOptions:\n"));
printf(_(" -D, --directory=DIR receive transaction log files into this directory\n"));
- printf(_(" --if-not-exists do not treat naming conflicts as an error when creating a slot\n"));
printf(_(" -n, --no-loop do not loop on connection lost\n"));
printf(_(" -s, --status-interval=SECS\n"
" time between status packets sent to server (default: %d)\n"), (standby_message_timeout / 1000));
@@ -373,8 +371,7 @@ main(int argc, char **argv)
/* action */
{"create-slot", no_argument, NULL, 1},
{"drop-slot", no_argument, NULL, 2},
- {"if-not-exists", no_argument, NULL, 3},
- {"synchronous", no_argument, NULL, 4},
+ {"synchronous", no_argument, NULL, 3},
{NULL, 0, NULL, 0}
};
@@ -458,9 +455,6 @@ main(int argc, char **argv)
do_drop_slot = true;
break;
case 3:
- slot_exists_ok = true;
- break;
- case 4:
synchronous = true;
break;
default:
@@ -508,7 +502,7 @@ main(int argc, char **argv)
/*
* Required arguments
*/
- if (basedir == NULL && !do_drop_slot)
+ if (basedir == NULL && !do_drop_slot && !do_create_slot)
{
fprintf(stderr, _("%s: no target directory specified\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
@@ -519,7 +513,7 @@ main(int argc, char **argv)
/*
* Check existence of destination folder.
*/
- if (!do_drop_slot)
+ if (!do_drop_slot && !do_create_slot)
{
DIR *dir = get_destination_dir(basedir);
@@ -581,9 +575,9 @@ main(int argc, char **argv)
_("%s: creating replication slot \"%s\"\n"),
progname, replication_slot);
- if (!CreateReplicationSlot(conn, replication_slot, NULL, true,
- slot_exists_ok))
+ if (!CreateReplicationSlot(conn, replication_slot, NULL, true))
disconnect_and_exit(1);
+ disconnect_and_exit(0);
}
/*
diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c
index f189f71..573fe7a 100644
--- a/src/bin/pg_basebackup/pg_recvlogical.c
+++ b/src/bin/pg_basebackup/pg_recvlogical.c
@@ -38,8 +38,6 @@ 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;
/* filled pairwise with option, value. value may be NULL */
@@ -68,15 +66,10 @@ usage(void)
progname);
printf(_("Usage:\n"));
printf(_(" %s [OPTION]...\n"), progname);
- printf(_("\nAction to be performed:\n"));
- printf(_(" --create-slot create a new replication slot (for the slot's name see --slot)\n"));
- printf(_(" --drop-slot drop the replication slot (for the slot's name see --slot)\n"));
- printf(_(" --start start streaming in a replication slot (for the slot's name see --slot)\n"));
printf(_("\nOptions:\n"));
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"
@@ -96,6 +89,9 @@ usage(void)
printf(_(" -U, --username=NAME connect as specified database user\n"));
printf(_(" -w, --no-password never prompt for password\n"));
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
+ printf(_("\nOptional actions:\n"));
+ printf(_(" --create-slot create a new replication slot (for the slot's name see --slot)\n"));
+ printf(_(" --drop-slot drop the replication slot (for the slot's name see --slot)\n"));
printf(_("\nReport bugs to .\n"));
}
@@ -633,9 +629,7 @@ main(int argc, char **argv)
{"slot", required_argument, NULL, 'S'},
/* action */
{"create-slot", no_argument, NULL, 1},
- {"start", no_argument, NULL, 2},
- {"drop-slot", no_argument, NULL, 3},
- {"if-not-exists", no_argument, NULL, 4},
+ {"drop-slot", no_argument, NULL, 2},
{NULL, 0, NULL, 0}
};
int c;
@@ -762,14 +756,8 @@ main(int argc, char **argv)
do_create_slot = true;
break;
case 2:
- do_start_slot = true;
- break;
- case 3:
do_drop_slot = true;
break;
- case 4:
- slot_exists_ok = true;
- break;
default:
@@ -806,7 +794,7 @@ main(int argc, char **argv)
exit(1);
}
- if (do_start_slot && outfile == NULL)
+ if (outfile == NULL && !do_drop_slot && !do_create_slot)
{
fprintf(stderr, _("%s: no target file specified\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
@@ -822,17 +810,9 @@ main(int argc, char **argv)
exit(1);
}
- if (!do_drop_slot && !do_create_slot && !do_start_slot)
- {
- fprintf(stderr, _("%s: at least one action needs to be specified\n"), progname);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
- exit(1);
- }
-
- if (do_drop_slot && (do_create_slot || do_start_slot))
+ if (do_drop_slot && do_create_slot)
{
- fprintf(stderr, _("%s: cannot use --create-slot or --start together with --drop-slot\n"), progname);
+ fprintf(stderr, _("%s: cannot use --create-slot together with --drop-slot\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname);
exit(1);
@@ -886,6 +866,7 @@ main(int argc, char **argv)
if (!DropReplicationSlot(conn, replication_slot))
disconnect_and_exit(1);
+ disconnect_and_exit(0);
}
/* Create a replication slot. */
@@ -896,14 +877,10 @@ main(int argc, char **argv)
_("%s: creating replication slot \"%s\"\n"),
progname, replication_slot);
- if (!CreateReplicationSlot(conn, replication_slot, plugin,
- false, slot_exists_ok))
+ if (!CreateReplicationSlot(conn, replication_slot, plugin, false))
disconnect_and_exit(1);
- startpos = InvalidXLogRecPtr;
- }
-
- if (!do_start_slot)
disconnect_and_exit(0);
+ }
/* Stream loop */
while (true)
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c
index 91f919c..d61899c 100644
--- a/src/bin/pg_basebackup/streamutil.c
+++ b/src/bin/pg_basebackup/streamutil.c
@@ -316,7 +316,7 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
*/
bool
CreateReplicationSlot(PGconn *conn, const char *slot_name, const char *plugin,
- bool is_physical, bool slot_exists_ok)
+ bool is_physical)
{
PQExpBuffer query;
PGresult *res;
@@ -340,21 +340,12 @@ CreateReplicationSlot(PGconn *conn, const char *slot_name, const char *plugin,
{
const char *sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
- if (slot_exists_ok && strcmp(sqlstate, ERRCODE_DUPLICATE_OBJECT) == 0)
- {
- destroyPQExpBuffer(query);
- PQclear(res);
- return true;
- }
- else
- {
- fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
- progname, query->data, PQerrorMessage(conn));
+ fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
+ progname, query->data, PQerrorMessage(conn));
- destroyPQExpBuffer(query);
- PQclear(res);
- return false;
- }
+ destroyPQExpBuffer(query);
+ PQclear(res);
+ return false;
}
if (PQntuples(res) != 1 || PQnfields(res) != 4)
diff --git a/src/bin/pg_basebackup/streamutil.h b/src/bin/pg_basebackup/streamutil.h
index b95f83f..6d5e88d 100644
--- a/src/bin/pg_basebackup/streamutil.h
+++ b/src/bin/pg_basebackup/streamutil.h
@@ -32,8 +32,7 @@ extern PGconn *GetConnection(void);
/* Replication commands */
extern bool CreateReplicationSlot(PGconn *conn, const char *slot_name,
- const char *plugin, bool is_physical,
- bool slot_exists_ok);
+ const char *plugin, bool is_physical);
extern bool DropReplicationSlot(PGconn *conn, const char *slot_name);
extern bool RunIdentifySystem(PGconn *conn, char **sysid,
TimeLineID *starttli,