Home Explore Blog CI



postgresql

9th chunk of `doc/src/sgml/ref/create_subscription.sgml`
abd7b6e2f447c09c64e41550d2b0fdab978007a9484210070000000100000d39
 some rows may be copied that
   would not be replicated using DML. See
   <xref linkend="logical-replication-subscription-examples"/> for examples.
  </para>

  <para>
   Subscriptions having several publications in which the same table has been
   published with different column lists are not supported.
  </para>

  <para>
   We allow non-existent publications to be specified so that users can add
   those later. This means
   <link linkend="catalog-pg-subscription"><structname>pg_subscription</structname></link>
   can have non-existent publications.
  </para>

  <para>
   When using a subscription parameter combination of
   <literal>copy_data = true</literal> and <literal>origin = NONE</literal>,
   the initial sync table data is copied directly from the publisher, meaning
   that knowledge of the true origin of that data is not possible. If the
   publisher also has subscriptions then the copied table data might have
   originated from further upstream. This scenario is detected and a WARNING is
   logged to the user, but the warning is only an indication of a potential
   problem; it is the user's responsibility to make the necessary checks to
   ensure the copied data origins are really as wanted or not.
  </para>

  <para>
   To find which tables might potentially include non-local origins (due to
   other subscriptions created on the publisher) try this SQL query:
<programlisting>
# substitute &lt;pub-names&gt; below with your publication name(s) to be queried
SELECT DISTINCT PT.schemaname, PT.tablename
FROM pg_publication_tables PT
     JOIN pg_class C ON (C.relname = PT.tablename)
     JOIN pg_namespace N ON (N.nspname = PT.schemaname),
     pg_subscription_rel PS
WHERE C.relnamespace = N.oid AND
      (PS.srrelid = C.oid OR
      C.oid IN (SELECT relid FROM pg_partition_ancestors(PS.srrelid) UNION
                SELECT relid FROM pg_partition_tree(PS.srrelid))) AND
      PT.pubname IN (&lt;pub-names&gt;);
</programlisting></para>

 </refsect1>

 <refsect1>
  <title>Examples</title>

  <para>
   Create a subscription to a remote server that replicates tables in
   the publications <literal>mypublication</literal> and
   <literal>insert_only</literal> and starts replicating immediately on
   commit:
<programlisting>
CREATE SUBSCRIPTION mysub
         CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb'
        PUBLICATION mypublication, insert_only;
</programlisting>
  </para>

  <para>
   Create a subscription to a remote server that replicates tables in
   the <literal>insert_only</literal> publication and does not start replicating
   until enabled at a later time.
<programlisting>
CREATE SUBSCRIPTION mysub
         CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb'
        PUBLICATION insert_only
               WITH (enabled = false);
</programlisting></para>
 </refsect1>

 <refsect1>
  <title>Compatibility</title>

  <para>
   <command>CREATE SUBSCRIPTION</command> is a <productname>PostgreSQL</productname>
   extension.
  </para>
 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-altersubscription"/></member>
   <member><xref linkend="sql-dropsubscription"/></member>
   <member><xref linkend="sql-createpublication"/></member>
   <member><xref linkend="sql-alterpublication"/></member>
  </simplelist>
 </refsect1>
</refentry>

Title: CREATE SUBSCRIPTION Notes (Continued): Data Origin Warning, Querying Tables with Potential Non-Local Origins, Examples, Compatibility, and See Also
Summary
This section covers a warning related to data origin when using `copy_data = true` and `origin = NONE` in `CREATE SUBSCRIPTION`, as the copied data might originate from upstream subscriptions. It provides a SQL query to identify tables with potential non-local origins. It also gives examples of creating subscriptions with different configurations. Finally, it notes that `CREATE SUBSCRIPTION` is a PostgreSQL extension and lists related commands.