diff options
Diffstat (limited to 'src/bin/pg_basebackup/receivelog.c')
-rw-r--r-- | src/bin/pg_basebackup/receivelog.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index f771c1ffdc6..55612832a62 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -455,10 +455,10 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream) * synchronous_standby_names, but we've protected them against it so * far, so let's continue to do so unless specifically requested. */ - if (replication_slot != NULL) + if (stream->replication_slot != NULL) { reportFlushPosition = true; - sprintf(slotcmd, "SLOT \"%s\" ", replication_slot); + sprintf(slotcmd, "SLOT \"%s\" ", stream->replication_slot); } else { @@ -509,6 +509,24 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream) } /* + * Create temporary replication slot if one is needed + */ + if (stream->temp_slot) + { + snprintf(query, sizeof(query), + "CREATE_REPLICATION_SLOT \"%s\" TEMPORARY PHYSICAL RESERVE_WAL", + stream->replication_slot); + res = PQexec(conn, query); + if (PQresultStatus(res) != PGRES_TUPLES_OK) + { + fprintf(stderr, _("%s: could not create temporary replication slot \"%s\": %s"), + progname, stream->replication_slot, PQerrorMessage(conn)); + PQclear(res); + return false; + } + } + + /* * initialize flush position to starting point, it's the caller's * responsibility that that's sane. */ |