aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/walreceiverfuncs.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2014-01-31 22:45:17 -0500
committerRobert Haas <rhaas@postgresql.org>2014-01-31 22:45:36 -0500
commit858ec11858a914d4c380971985709b6d6b7dd6fc (patch)
tree59eb508185cd8544c3485919a25dee15f3818c21 /src/backend/replication/walreceiverfuncs.c
parent5bdef38b8917cfbe206d14969c61a5d38fc822b6 (diff)
downloadpostgresql-858ec11858a914d4c380971985709b6d6b7dd6fc.tar.gz
postgresql-858ec11858a914d4c380971985709b6d6b7dd6fc.zip
Introduce replication slots.
Replication slots are a crash-safe data structure which can be created on either a master or a standby to prevent premature removal of write-ahead log segments needed by a standby, as well as (with hot_standby_feedback=on) pruning of tuples whose removal would cause replication conflicts. Slots have some advantages over existing techniques, as explained in the documentation. In a few places, we refer to the type of replication slots introduced by this patch as "physical" slots, because forthcoming patches for logical decoding will also have slots, but with somewhat different properties. Andres Freund and Robert Haas
Diffstat (limited to 'src/backend/replication/walreceiverfuncs.c')
-rw-r--r--src/backend/replication/walreceiverfuncs.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c
index cc96d7c2f8a..acadec57f5a 100644
--- a/src/backend/replication/walreceiverfuncs.c
+++ b/src/backend/replication/walreceiverfuncs.c
@@ -219,11 +219,13 @@ ShutdownWalRcv(void)
/*
* Request postmaster to start walreceiver.
*
- * recptr indicates the position where streaming should begin, and conninfo
- * is a libpq connection string to use.
+ * recptr indicates the position where streaming should begin, conninfo
+ * is a libpq connection string to use, and slotname is, optionally, the name
+ * of a replication slot to acquire.
*/
void
-RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo)
+RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo,
+ const char *slotname)
{
/* use volatile pointer to prevent code rearrangement */
volatile WalRcvData *walrcv = WalRcv;
@@ -250,6 +252,11 @@ RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo)
else
walrcv->conninfo[0] = '\0';
+ if (slotname != NULL)
+ strlcpy((char *) walrcv->slotname, slotname, NAMEDATALEN);
+ else
+ walrcv->slotname[0] = '\0';
+
if (walrcv->walRcvState == WALRCV_STOPPED)
{
launch = true;