Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/ref/create_publication.sgml`
a755e384b811f3139f1219c9b170983793d496367b48e7e10000000100000be4
 TABLES</command> and
   <command>FOR TABLES IN SCHEMA</command> clauses require the invoking
   user to be a superuser.
  </para>

  <para>
   The tables added to a publication that publishes <command>UPDATE</command>
   and/or <command>DELETE</command> operations must have
   <literal>REPLICA IDENTITY</literal> defined.  Otherwise those operations will be
   disallowed on those tables.
  </para>

  <para>
   Any column list must include the <literal>REPLICA IDENTITY</literal> columns
   in order for <command>UPDATE</command> or <command>DELETE</command>
   operations to be published. There are no column list restrictions if the
   publication publishes only <command>INSERT</command> operations.
  </para>

  <para>
   A row filter expression (i.e., the <literal>WHERE</literal> clause) must contain only
   columns that are covered by the <literal>REPLICA IDENTITY</literal>, in
   order for <command>UPDATE</command> and <command>DELETE</command> operations
   to be published. For publication of <command>INSERT</command> operations,
   any column may be used in the <literal>WHERE</literal> expression. The
   row filter allows simple expressions that don't have
   user-defined functions, user-defined operators, user-defined types,
   user-defined collations, non-immutable built-in functions, or references to
   system columns.
  </para>

  <para>
   The generated columns that are part of <literal>REPLICA IDENTITY</literal>
   must be published explicitly either by listing them in the column list or
   by enabling the <literal>publish_generated_columns</literal> option, in
   order for <command>UPDATE</command> and <command>DELETE</command> operations
   to be published.
  </para>

  <para>
   The row filter on a table becomes redundant if
   <literal>FOR TABLES IN SCHEMA</literal> is specified and the table
   belongs to the referred schema.
  </para>

  <para>
   For published partitioned tables, the row filter 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 (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,

Title: CREATE PUBLICATION: Notes continued, REPLICA IDENTITY and Row Filters
Summary
This section continues to provide notes on the CREATE PUBLICATION command, focusing on restrictions and behaviors. It details the requirements for REPLICA IDENTITY, including its impact on UPDATE/DELETE operations and generated columns. The restrictions on row filter expressions (WHERE clauses) are outlined. The section also covers how row filters and column lists are handled for partitioned tables based on the publish_via_partition_root parameter. Finally, it explains how INSERT ... ON CONFLICT and MERGE commands are published.