Home Explore Blog CI



postgresql

6th chunk of `doc/src/sgml/ref/create_publication.sgml`
84137627b2f5fdf2522264aad263fcb7eac9530dc781e4c000000001000007e4
 <literal>publish_via_partition_root</literal> is true,
   or from the partition itself if it is false (the default).
   See <xref linkend="logical-replication-row-filter"/> for details about row
   filters.
   Similarly, for published partitioned tables, the column list for each
   partition is taken from the published partitioned table if the
   publication parameter <literal>publish_via_partition_root</literal> is true,
   or from the partition itself if it is false.
  </para>

  <para>
   For an <command>INSERT ... ON CONFLICT</command> command, the publication will
   publish the operation that results from the command.  Depending
   on the outcome, it may be published as either <command>INSERT</command> or
   <command>UPDATE</command>, or it may not be published at all.
  </para>

  <para>
   For a <command>MERGE</command> command, the publication will publish an
   <command>INSERT</command>, <command>UPDATE</command>, or <command>DELETE</command>
   for each row inserted, updated, or deleted.
  </para>

  <para>
   <command>ATTACH</command>ing a table into a partition tree whose root is
   published using a publication with <literal>publish_via_partition_root</literal>
   set to <literal>true</literal> does not result in the table's existing contents
   being replicated.
  </para>

  <para>
   <command>COPY ... FROM</command> commands are published
   as <command>INSERT</command> operations.
  </para>

  <para>
   <acronym>DDL</acronym> operations are not published.
  </para>

  <para>
   The <literal>WHERE</literal> clause expression is executed with the role used
   for the replication connection.
  </para>
 </refsect1>

 <refsect1>
  <title>Examples</title>

  <para>
   Create a publication that publishes all changes in two tables:
<programlisting>
CREATE PUBLICATION mypublication FOR TABLE users, departments;
</programlisting>
  </para>

  <para>
   Create a publication that publishes all changes from active departments:
<programlisting>
CREATE PUBLICATION active_departments

Title: CREATE PUBLICATION: More Notes, INSERT ON CONFLICT, MERGE, COPY, DDL, Examples
Summary
This section describes how INSERT ... ON CONFLICT and MERGE commands are published, as well as the effect of attaching a table to a published partition tree with publish_via_partition_root set to true. COPY ... FROM commands are published as INSERT operations, and DDL operations are not published. The WHERE clause expression is executed with the role used for the replication connection. It also includes examples of creating publications for specific tables and with a WHERE clause.