diff options
| author | Peter Eisentraut | 2018-04-07 15:17:56 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2018-04-07 15:34:10 +0000 |
| commit | 5dfd1e5a6696b271a2cdee54143fbc209c88c02f (patch) | |
| tree | 9654f50fe72c84d737ad8edb4cdde339a4b36dcc /src/include/replication | |
| parent | b508a56f2f3a2d850e75a14661943d6b4dde8274 (diff) | |
Logical decoding of TRUNCATE
Add a new WAL record type for TRUNCATE, which is only used when
wal_level >= logical. (For physical replication, TRUNCATE is already
replicated via SMGR records.) Add new callback for logical decoding
output plugins to receive TRUNCATE actions.
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>
Diffstat (limited to 'src/include/replication')
| -rw-r--r-- | src/include/replication/output_plugin.h | 10 | ||||
| -rw-r--r-- | src/include/replication/reorderbuffer.h | 24 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/include/replication/output_plugin.h b/src/include/replication/output_plugin.h index 82875d6b3d..1ee0a56f03 100644 --- a/src/include/replication/output_plugin.h +++ b/src/include/replication/output_plugin.h @@ -62,6 +62,15 @@ typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx, ReorderBufferChange *change); /* + * Callback for every TRUNCATE in a successful transaction. + */ +typedef void (*LogicalDecodeTruncateCB) (struct LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, + int nrelations, + Relation relations[], + ReorderBufferChange *change); + +/* * Called for every (explicit or implicit) COMMIT of a successful transaction. */ typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx, @@ -98,6 +107,7 @@ typedef struct OutputPluginCallbacks LogicalDecodeStartupCB startup_cb; LogicalDecodeBeginCB begin_cb; LogicalDecodeChangeCB change_cb; + LogicalDecodeTruncateCB truncate_cb; LogicalDecodeCommitCB commit_cb; LogicalDecodeMessageCB message_cb; LogicalDecodeFilterByOriginCB filter_by_origin_cb; diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index aa430c843c..3867ce8950 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -59,7 +59,8 @@ enum ReorderBufferChangeType REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID, REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT, - REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM + REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM, + REORDER_BUFFER_CHANGE_TRUNCATE }; /* @@ -99,6 +100,18 @@ typedef struct ReorderBufferChange ReorderBufferTupleBuf *newtuple; } tp; + /* + * Truncate data for REORDER_BUFFER_CHANGE_TRUNCATE representing + * one set of relations to be truncated. + */ + struct + { + Size nrelids; + bool cascade; + bool restart_seqs; + Oid *relids; + } truncate; + /* Message with arbitrary data. */ struct { @@ -283,6 +296,14 @@ typedef void (*ReorderBufferApplyChangeCB) ( Relation relation, ReorderBufferChange *change); +/* truncate callback signature */ +typedef void (*ReorderBufferApplyTruncateCB) ( + ReorderBuffer *rb, + ReorderBufferTXN *txn, + int nrelations, + Relation relations[], + ReorderBufferChange *change); + /* begin callback signature */ typedef void (*ReorderBufferBeginCB) ( ReorderBuffer *rb, @@ -328,6 +349,7 @@ struct ReorderBuffer */ ReorderBufferBeginCB begin; ReorderBufferApplyChangeCB apply_change; + ReorderBufferApplyTruncateCB apply_truncate; ReorderBufferCommitCB commit; ReorderBufferMessageCB message; |
