mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
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>
This commit is contained in:
@ -32,7 +32,7 @@
|
||||
#define XLOG_HEAP_INSERT 0x00
|
||||
#define XLOG_HEAP_DELETE 0x10
|
||||
#define XLOG_HEAP_UPDATE 0x20
|
||||
/* 0x030 is free, was XLOG_HEAP_MOVE */
|
||||
#define XLOG_HEAP_TRUNCATE 0x30
|
||||
#define XLOG_HEAP_HOT_UPDATE 0x40
|
||||
#define XLOG_HEAP_CONFIRM 0x50
|
||||
#define XLOG_HEAP_LOCK 0x60
|
||||
@ -109,6 +109,27 @@ typedef struct xl_heap_delete
|
||||
|
||||
#define SizeOfHeapDelete (offsetof(xl_heap_delete, flags) + sizeof(uint8))
|
||||
|
||||
/*
|
||||
* xl_heap_delete flag values, 8 bits are available.
|
||||
*/
|
||||
#define XLH_TRUNCATE_CASCADE (1<<0)
|
||||
#define XLH_TRUNCATE_RESTART_SEQS (1<<1)
|
||||
|
||||
/*
|
||||
* For truncate we list all truncated relids in an array, followed by all
|
||||
* sequence relids that need to be restarted, if any.
|
||||
* All rels are always within the same database, so we just list dbid once.
|
||||
*/
|
||||
typedef struct xl_heap_truncate
|
||||
{
|
||||
Oid dbId;
|
||||
uint32 nrelids;
|
||||
uint8 flags;
|
||||
Oid relids[FLEXIBLE_ARRAY_MEMBER];
|
||||
} xl_heap_truncate;
|
||||
|
||||
#define SizeOfHeapTruncate (offsetof(xl_heap_truncate, relids))
|
||||
|
||||
/*
|
||||
* We don't store the whole fixed part (HeapTupleHeaderData) of an inserted
|
||||
* or updated tuple in WAL; we can save a few bytes by reconstructing the
|
||||
|
Reference in New Issue
Block a user