From 039eb6e92f20499ac36cc74f8a5cef7430b706f6 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 7 Apr 2018 11:24:53 -0400 Subject: 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 Author: Marco Nenciarini Author: Peter Eisentraut Reviewed-by: Petr Jelinek Reviewed-by: Andres Freund Reviewed-by: Alvaro Herrera --- doc/src/sgml/catalogs.sgml | 8 +++++ doc/src/sgml/logical-replication.sgml | 13 ++------ doc/src/sgml/protocol.sgml | 56 ++++++++++++++++++++++++++++++++ doc/src/sgml/ref/create_publication.sgml | 10 +++--- 4 files changed, 71 insertions(+), 16 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index d6a9d8c5808..e8efa13e8df 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -5518,6 +5518,14 @@ SCRAM-SHA-256$<iteration count>:&l If true, DELETE operations are replicated for tables in the publication. + + + pubtruncate + bool + + If true, TRUNCATE operations are replicated for + tables in the publication. + diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 75551d8ee1a..151e773fc2c 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -108,8 +108,8 @@ Publications can choose to limit the changes they produce to - any combination of INSERT, UPDATE, and - DELETE, similar to how triggers are fired by + any combination of INSERT, UPDATE, + DELETE, and TRUNCATE, similar to how triggers are fired by particular event types. By default, all operation types are replicated. @@ -364,15 +364,6 @@ - - - TRUNCATE commands are not replicated. This can, of - course, be worked around by using DELETE instead. To - avoid accidental TRUNCATE invocations, you can revoke - the TRUNCATE privilege from tables. - - - Large objects (see ) are not replicated. diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index b94dd4ac654..004b36084f1 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -6774,6 +6774,62 @@ Delete + + +Truncate + + + + + + + + Byte1('T') + + + + Identifies the message as a truncate message. + + + + + + Int32 + + + + Number of relations + + + + + + Int8 + + + + Option bits for TRUNCATE: + 1 for CASCADE, 2 for RESTART IDENTITY + + + + + + Int32 + + + + ID of the relation corresponding to the ID in the relation + message. This field is repeated for each relation. + + + + + + + + + diff --git a/doc/src/sgml/ref/create_publication.sgml b/doc/src/sgml/ref/create_publication.sgml index bfe12d5f410..99f87ca3938 100644 --- a/doc/src/sgml/ref/create_publication.sgml +++ b/doc/src/sgml/ref/create_publication.sgml @@ -106,10 +106,11 @@ CREATE PUBLICATION name 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 - insert, update, and - delete. The default is to publish all actions, + insert, update, + delete, and truncate. + The default is to publish all actions, and so the default value for this option is - 'insert, update, delete'. + 'insert, update, delete, truncate'. @@ -168,8 +169,7 @@ CREATE PUBLICATION name - TRUNCATE and DDL operations - are not published. + DDL operations are not published. -- cgit v1.2.3