mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Logical replication support for TRUNCATE
Update the built-in logical replication system to make use of the previously added logical decoding for TRUNCATE support. Add the required truncate callback to pgoutput and a new logical replication protocol message. Publications get a new attribute to determine whether to replicate truncate actions. When updating a publication via pg_dump from an older version, this is not set, thus preserving the previous behavior. Author: Simon Riggs <simon@2ndquadrant.com> Author: Marco Nenciarini <marco.nenciarini@2ndquadrant.it> Author: Peter Eisentraut <peter.eisentraut@2ndquadrant.com> Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
This commit is contained in:
@ -5518,6 +5518,14 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l
|
||||
<entry>If true, <command>DELETE</command> operations are replicated for
|
||||
tables in the publication.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><structfield>pubtruncate</structfield></entry>
|
||||
<entry><type>bool</type></entry>
|
||||
<entry></entry>
|
||||
<entry>If true, <command>TRUNCATE</command> operations are replicated for
|
||||
tables in the publication.</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
@ -108,8 +108,8 @@
|
||||
|
||||
<para>
|
||||
Publications can choose to limit the changes they produce to
|
||||
any combination of <command>INSERT</command>, <command>UPDATE</command>, and
|
||||
<command>DELETE</command>, similar to how triggers are fired by
|
||||
any combination of <command>INSERT</command>, <command>UPDATE</command>,
|
||||
<command>DELETE</command>, and <command>TRUNCATE</command>, similar to how triggers are fired by
|
||||
particular event types. By default, all operation types are replicated.
|
||||
</para>
|
||||
|
||||
@ -364,15 +364,6 @@
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<command>TRUNCATE</command> commands are not replicated. This can, of
|
||||
course, be worked around by using <command>DELETE</command> instead. To
|
||||
avoid accidental <command>TRUNCATE</command> invocations, you can revoke
|
||||
the <literal>TRUNCATE</literal> privilege from tables.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Large objects (see <xref linkend="largeobjects"/>) are not replicated.
|
||||
|
@ -6774,6 +6774,62 @@ Delete
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
Truncate
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
Byte1('T')
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Identifies the message as a truncate message.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
Int32
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Number of relations
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
Int8
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Option bits for <command>TRUNCATE</command>:
|
||||
1 for <literal>CASCADE</literal>, 2 for <literal>RESTART IDENTITY</literal>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
Int32
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
ID of the relation corresponding to the ID in the relation
|
||||
message. This field is repeated for each relation.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
<para>
|
||||
|
@ -106,10 +106,11 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
||||
This parameter determines which DML operations will be published by
|
||||
the new publication to the subscribers. The value is
|
||||
comma-separated list of operations. The allowed operations are
|
||||
<literal>insert</literal>, <literal>update</literal>, and
|
||||
<literal>delete</literal>. The default is to publish all actions,
|
||||
<literal>insert</literal>, <literal>update</literal>,
|
||||
<literal>delete</literal>, and <literal>truncate</literal>.
|
||||
The default is to publish all actions,
|
||||
and so the default value for this option is
|
||||
<literal>'insert, update, delete'</literal>.
|
||||
<literal>'insert, update, delete, truncate'</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@ -168,8 +169,7 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<command>TRUNCATE</command> and <acronym>DDL</acronym> operations
|
||||
are not published.
|
||||
<acronym>DDL</acronym> operations are not published.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
Reference in New Issue
Block a user