ThisTimeLineID = primary_tli;
/* Start streaming from the point requested by startup process */
- snprintf(cmd, sizeof(cmd), "START_REPLICATION %X/%X",
- startpoint.xlogid, startpoint.xrecoff);
+ snprintf(cmd, sizeof(cmd), "START_REPLICATION %X/%X MODE %s",
+ startpoint.xlogid, startpoint.xrecoff,
+ GetConfigOption("replication_mode", false));
res = libpqrcv_PQexec(cmd);
if (PQresultStatus(res) != PGRES_COPY_OUT)
{
*/
static XLogRecPtr ackdPtr = {0, 0};
+/* Replication mode requested by connected standby */
+static int rplMode = REPLICATION_MODE_ASYNC;
+
/* Flags set by signal handlers for later service in main loop */
static volatile sig_atomic_t got_SIGHUP = false;
static volatile sig_atomic_t shutdown_requested = false;
/* Handle the very limited subset of commands expected in this phase */
switch (firstchar)
{
+ char rplModeStr[6];
+
case 'Q': /* Query message */
{
const char *query_string;
ReadyForQuery(DestRemote);
/* ReadyForQuery did pq_flush for us */
}
- else if (sscanf(query_string, "START_REPLICATION %X/%X",
- &recptr.xlogid, &recptr.xrecoff) == 2)
+ else if (sscanf(query_string, "START_REPLICATION %X/%X MODE %5s",
+ &recptr.xlogid, &recptr.xrecoff, rplModeStr) == 3)
{
StringInfoData buf;
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
errmsg("standby connections not allowed because wal_level=minimal")));
+ /* Verify that the specified replication mode is valid */
+ {
+ const struct config_enum_entry *entry;
+
+ for (entry = replication_mode_options; entry && entry->name; entry++)
+ {
+ if (strcmp(rplModeStr, entry->name) == 0)
+ {
+ rplMode = entry->val;
+ break;
+ }
+ }
+ if (entry == NULL || entry->name == NULL)
+ ereport(FATAL,
+ (errcode(ERRCODE_PROTOCOL_VIOLATION),
+ errmsg("invalid replication mode: %s", rplModeStr)));
+ }
+ MyWalSnd->rplMode = rplMode;
+
/* Send a CopyXLogResponse message, and start streaming */
pq_beginmessage(&buf, 'W');
pq_endmessage(&buf);
#include "access/xlogdefs.h"
#include "lib/stringinfo.h"
#include "storage/buf.h"
+#include "utils/guc.h"
#include "utils/pg_crc.h"
#include "utils/timestamp.h"
REPLICATION_MODE_APPLY
} ReplicationMode;
extern int replication_mode;
+extern const struct config_enum_entry replication_mode_options[];
#ifdef WAL_DEBUG
extern bool XLOG_DEBUG;