From: MasaoFujii Date: Mon, 13 Dec 2010 09:12:21 +0000 (+0900) Subject: Merge branch 'pgrex90-base' into pgrex90 X-Git-Tag: pgrex902-1.0~8 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=01ad6c4ddeec357decfb3fa9929bfca158f859f4;p=pg-rex%2Fsyncrep.git Merge branch 'pgrex90-base' into pgrex90 Conflicts: doc/src/sgml/protocol.sgml src/backend/replication/walsender.c src/interfaces/libpq/fe-exec.c src/interfaces/libpq/fe-protocol2.c src/interfaces/libpq/fe-protocol3.c src/interfaces/libpq/libpq-int.h --- 01ad6c4ddeec357decfb3fa9929bfca158f859f4 diff --cc src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index e4cee68cfe,6b477fd3af..0d8c278d1b --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@@ -156,11 -156,10 +156,11 @@@ libpqrcv_connect(char *conninfo, XLogRe 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) + if (PQresultStatus(res) != PGRES_COPY_BOTH) { PQclear(res); ereport(ERROR, diff --cc src/backend/replication/walsender.c index fa96810dc3,66f08e1ec6..a41365f34e --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@@ -323,37 -287,10 +323,39 @@@ WalSndHandshake(void (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(modestr, entry->name) == 0) + { + mode = entry->val; + break; + } + } + if (entry == NULL || entry->name == NULL) + ereport(FATAL, + (errcode(ERRCODE_PROTOCOL_VIOLATION), + errmsg("invalid replication mode: %s", modestr))); + } + + /* Change the state according to replication mode specified by standby */ + { + /* use volatile pointer to prevent code rearrangement */ + volatile WalSnd *walsnd = MyWalSnd; + + SpinLockAcquire(&walsnd->mutex); + walsnd->walSndState = (mode == REPLICATION_MODE_ASYNC) ? + WALSND_ASYNC : WALSND_CATCHUP; + SpinLockRelease(&walsnd->mutex); + } + - /* Send a CopyXLogResponse message, and start streaming */ + /* Send a CopyBothResponse message, and start streaming */ pq_beginmessage(&buf, 'W'); + pq_sendbyte(&buf, 0); + pq_sendint(&buf, 0, 2); pq_endmessage(&buf); pq_flush();