From e4d2fae2907bd986a90b547cf02f0a3c51e6cbf5 Mon Sep 17 00:00:00 2001
From: Emre Hasegeli <emre@hasegeli.com>
Date: Mon, 20 Mar 2023 17:02:45 +0100
Subject: [PATCH v16] doc: Clarify pgoutput options

Author: Emre Hasegeli <emre@hasegeli.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 12
Discussion: https://www.postgresql.org/message-id/flat/CAE2gYzwdwtUbs-tPSV-QBwgTubiyGD2ZGsSnAVsDfAGGLDrGOA%40mail.gmail.com
---
 doc/src/sgml/logical-replication.sgml |  5 +-
 doc/src/sgml/protocol.sgml            | 85 +++++++++++++++++++++++++--
 2 files changed, 84 insertions(+), 6 deletions(-)

diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml
index c2a749d882..ca852c5506 100644
--- a/doc/src/sgml/logical-replication.sgml
+++ b/doc/src/sgml/logical-replication.sgml
@@ -525,21 +525,21 @@ test_sub=# SELECT * FROM t3;
 
   <sect2 id="logical-replication-subscription-examples-deferred-slot">
    <title>Examples: Deferred Replication Slot Creation</title>
 
    <para>
     There are some cases (e.g.
     <xref linkend="logical-replication-subscription-slot"/>) where, if the
     remote replication slot was not created automatically, the user must create
     it manually before the subscription can be activated. The steps to create
     the slot and activate the subscription are shown in the following examples.
-    These examples specify the standard logical decoding plugin
+    These examples specify the standard logical decoding output plugin
     (<literal>pgoutput</literal>), which is what the built-in logical
     replication uses.
    </para>
    <para>
     First, create a publication for the examples to use.
 <programlisting>
 test_pub=# CREATE PUBLICATION pub1 FOR ALL TABLES;
 CREATE PUBLICATION
 </programlisting></para>
    <para>
@@ -1636,21 +1636,22 @@ CONTEXT:  processing remote data for replication origin "pg_16395" during "INSER
    transactional consistency is guaranteed for the publications within any
    single subscription.
   </para>
 
   <para>
    Logical replication is built with an architecture similar to physical
    streaming replication (see <xref linkend="streaming-replication"/>).  It is
    implemented by <literal>walsender</literal> and <literal>apply</literal>
    processes.  The walsender process starts logical decoding (described
    in <xref linkend="logicaldecoding"/>) of the WAL and loads the standard
-   logical decoding plugin (pgoutput).  The plugin transforms the changes read
+   logical decoding output plugin (<literal>pgoutput</literal>).  The plugin
+   transforms the changes read
    from WAL to the logical replication protocol
    (see <xref linkend="protocol-logical-replication"/>) and filters the data
    according to the publication specification.  The data is then continuously
    transferred using the streaming replication protocol to the apply worker,
    which maps the data to local tables and applies the individual changes as
    they are received, in correct transactional order.
   </para>
 
   <para>
    The apply process on the subscriber database always runs with
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index b11d9a6ba3..5dff07110d 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -2534,21 +2534,24 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;"
          <para>
           The WAL location to begin streaming at.
          </para>
         </listitem>
        </varlistentry>
 
        <varlistentry>
         <term><replaceable class="parameter">option_name</replaceable></term>
         <listitem>
          <para>
-          The name of an option passed to the slot's logical decoding plugin.
+          The name of an option passed to the slot's logical decoding output
+          plugin.  See <xref linkend="protocol-logical-replication"/> for
+          options that are accepted by the standard (<literal>pgoutput</literal>)
+          plugin.
          </para>
         </listitem>
        </varlistentry>
 
        <varlistentry>
         <term><replaceable class="parameter">option_value</replaceable></term>
         <listitem>
          <para>
           Optional value, in the form of a string constant, associated with the
           specified option.
@@ -3071,36 +3074,43 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;"
   flow started by the <literal>START_REPLICATION</literal>
   <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable>
   <literal>LOGICAL</literal> replication command.
  </para>
 
  <para>
   The logical streaming replication protocol builds on the primitives of
   the physical streaming replication protocol.
  </para>
 
+ <para>
+  <productname>PostgreSQL</productname> logical decoding supports output
+  plugins.  <literal>pgoutput</literal> is the standard one used for
+  the built-in logical replication.
+ </para>
+
  <sect2 id="protocol-logical-replication-params">
   <title>Logical Streaming Replication Parameters</title>
 
   <para>
-   The logical replication <literal>START_REPLICATION</literal> command
-   accepts following parameters:
+   Using the <literal>START_REPLICATION</literal> command,
+   <literal>pgoutput</literal> accepts the following options:
 
    <variablelist>
     <varlistentry>
      <term>
       proto_version
      </term>
      <listitem>
       <para>
        Protocol version. Currently versions <literal>1</literal>, <literal>2</literal>,
-       <literal>3</literal>, and <literal>4</literal> are supported.
+       <literal>3</literal>, and <literal>4</literal> are supported.  A valid
+       version is required.
       </para>
       <para>
        Version <literal>2</literal> is supported only for server version 14
        and above, and it allows streaming of large in-progress transactions.
       </para>
       <para>
        Version <literal>3</literal> is supported only for server version 15
        and above, and it allows streaming of two-phase commits.
       </para>
       <para>
@@ -3113,20 +3123,87 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;"
 
     <varlistentry>
      <term>
       publication_names
      </term>
      <listitem>
       <para>
        Comma separated list of publication names for which to subscribe
        (receive changes). The individual publication names are treated
        as standard objects names and can be quoted the same as needed.
+       At least one publication name is required.
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
+     <term>
+      binary
+     </term>
+     <listitem>
+      <para>
+       Boolean option to use binary transfer mode.  Binary mode is faster
+       than the text mode but slightly less robust.
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
+     <term>
+      messages
+     </term>
+     <listitem>
+      <para>
+       Boolean option to enable sending the messages that are written
+       by <function>pg_logical_emit_message</function>.
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
+     <term>
+      streaming
+     </term>
+     <listitem>
+      <para>
+       Boolean option to enable streaming of in-progress transactions.
+       It accepts an additional value "parallel" to enable sending extra
+       information with some messages to be used for parallelisation.
+       Minimum protocol version 2 is required to turn it on.  Minimum protocol
+       version 4 is required for the "parallel" option.
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
+     <term>
+      two_phase
+     </term>
+     <listitem>
+      <para>
+       Boolean option to enable two-phase transactions.   Minimum protocol
+       version 3 is required to turn it on.
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
+     <term>
+      origin
+     </term>
+     <listitem>
+      <para>
+       Option to send changes by their origin.  Possible values are "none"
+       to only send the changes that have no origin associated, or "any"
+       to send the changes regardless of their origin.  This can be used
+       to avoid loops (infinite replication of the same data) among
+       replication nodes.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
 
   </para>
  </sect2>
 
  <sect2 id="protocol-logical-messages">
   <title>Logical Replication Protocol Messages</title>
-- 
2.39.3 (Apple Git-145)

