From d3d414696f39e2b57072fab3dd4fa11e465be4ed Mon Sep 17 00:00:00 2001
From: Robert Haas
Date: Sat, 11 Dec 2010 09:27:37 -0500
Subject: Allow bidirectional copy messages in streaming replication mode.
Fujii Masao. Review by Alvaro Herrera, Tom Lane, and myself.
---
doc/src/sgml/libpq.sgml | 10 +++++
doc/src/sgml/protocol.sgml | 98 +++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 102 insertions(+), 6 deletions(-)
(limited to 'doc')
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index c253c7c61c9..c5024393566 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -2194,6 +2194,16 @@ ExecStatusType PQresultStatus(const PGresult *res);
+
+ PGRES_COPY_BOTH
+
+
+ Copy In/Out (to and from server) data transfer started. This is
+ currently used only for streaming replication.
+
+
+
+
PGRES_BAD_RESPONSE
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 7b2482be5a4..e3d636d557f 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1033,12 +1033,25 @@
- The CopyInResponse and CopyOutResponse messages include fields that
- inform the frontend of the number of columns per row and the format
- codes being used for each column. (As of the present implementation,
- all columns in a given COPY> operation will use the same
- format, but the message design does not assume this.)
+ There is another Copy-related mode called Copy-both, which allows
+ high-speed bulk data transfer to and> from the server.
+ Copy-both mode is initiated when a backend in walsender mode
+ executes a START_REPLICATION statement. The
+ backend sends a CopyBothResponse message to the frontend. Both
+ the backend and the frontend may then send CopyData messages
+ until the connection is terminated. See see .
+
+
+ The CopyInResponse, CopyOutResponse and CopyBothResponse messages
+ include fields that inform the frontend of the number of columns
+ per row and the format codes being used for each column. (As of
+ the present implementation, all columns in a given COPY>
+ operation will use the same format, but the message design does not
+ assume this.)
+
+
@@ -1344,7 +1357,7 @@ The commands accepted in walsender mode are:
WAL position XXX>/XXX>.
The server can reply with an error, e.g. if the requested section of WAL
has already been recycled. On success, server responds with a
- CopyOutResponse message, and then starts to stream WAL to the frontend.
+ CopyBothResponse message, and then starts to stream WAL to the frontend.
WAL will continue to be streamed until the connection is broken;
no further commands will be accepted.
@@ -2694,6 +2707,79 @@ CopyOutResponse (B)
+
+
+CopyBothResponse (B)
+
+
+
+
+
+
+
+ Byte1('W')
+
+
+
+ Identifies the message as a Start Copy Both response.
+ This message is used only for Streaming Replication.
+
+
+
+
+
+ Int32
+
+
+
+ Length of message contents in bytes, including self.
+
+
+
+
+
+ Int8
+
+
+
+ 0 indicates the overall COPY format
+ is textual (rows separated by newlines, columns
+ separated by separator characters, etc). 1 indicates
+ the overall copy format is binary (similar to DataRow
+ format). See for more information.
+
+
+
+
+
+ Int16
+
+
+
+ The number of columns in the data to be copied
+ (denoted N> below).
+
+
+
+
+
+ Int16[N>]
+
+
+
+ The format codes to be used for each column.
+ Each must presently be zero (text) or one (binary).
+ All must be zero if the overall copy format is textual.
+
+
+
+
+
+
+
+
+
+
DataRow (B)
--
cgit v1.2.3