1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Add facility to copy replication slots

This allows the user to create duplicates of existing replication slots,
either logical or physical, and even changing properties such as whether
they are temporary or the output plugin used.

There are multiple uses for this, such as initializing multiple replicas
using the slot for one base backup; when doing investigation of logical
replication issues; and to select a different output plugins.

Author: Masahiko Sawada
Reviewed-by: Michael Paquier, Andres Freund, Petr Jelinek
Discussion: https://postgr.es/m/CAD21AoAm7XX8y_tOPP6j4Nzzch12FvA1wPqiO690RCk+uYVstg@mail.gmail.com
This commit is contained in:
Alvaro Herrera
2019-04-05 14:52:45 -03:00
parent de2b38419c
commit 9f06d79ef8
9 changed files with 736 additions and 50 deletions

View File

@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201904031
#define CATALOG_VERSION_NO 201904051
#endif

View File

@@ -9774,6 +9774,20 @@
proargmodes => '{i,i,i,o,o}',
proargnames => '{slot_name,immediately_reserve,temporary,slot_name,lsn}',
prosrc => 'pg_create_physical_replication_slot' },
{ oid => '4220', descr => 'copy a physical replication slot, changing temporality',
proname => 'pg_copy_physical_replication_slot', provolatile => 'v',
proparallel => 'u', prorettype => 'record', proargtypes => 'name name bool',
proallargtypes => '{name,name,bool,name,pg_lsn}',
proargmodes => '{i,i,i,o,o}',
proargnames => '{src_slot_name,dst_slot_name,temporary,slot_name,lsn}',
prosrc => 'pg_copy_physical_replication_slot_a' },
{ oid => '4221', descr => 'copy a physical replication slot',
proname => 'pg_copy_physical_replication_slot', provolatile => 'v',
proparallel => 'u', prorettype => 'record', proargtypes => 'name name',
proallargtypes => '{name,name,name,pg_lsn}',
proargmodes => '{i,i,o,o}',
proargnames => '{src_slot_name,dst_slot_name,slot_name,lsn}',
prosrc => 'pg_copy_physical_replication_slot_b' },
{ oid => '3780', descr => 'drop a replication slot',
proname => 'pg_drop_replication_slot', provolatile => 'v', proparallel => 'u',
prorettype => 'void', proargtypes => 'name',
@@ -9794,6 +9808,27 @@
proargmodes => '{i,i,i,o,o}',
proargnames => '{slot_name,plugin,temporary,slot_name,lsn}',
prosrc => 'pg_create_logical_replication_slot' },
{ oid => '4222', descr => 'copy a logical replication slot, changing temporality and plugin',
proname => 'pg_copy_logical_replication_slot', provolatile => 'v',
proparallel => 'u', prorettype => 'record', proargtypes => 'name name bool name',
proallargtypes => '{name,name,bool,name,name,pg_lsn}',
proargmodes => '{i,i,i,i,o,o}',
proargnames => '{src_slot_name,dst_slot_name,temporary,plugin,slot_name,lsn}',
prosrc => 'pg_copy_logical_replication_slot_a' },
{ oid => '4223', descr => 'copy a logical replication slot, changing temporality',
proname => 'pg_copy_logical_replication_slot', provolatile => 'v',
proparallel => 'u', prorettype => 'record', proargtypes => 'name name bool',
proallargtypes => '{name,name,bool,name,pg_lsn}',
proargmodes => '{i,i,i,o,o}',
proargnames => '{src_slot_name,dst_slot_name,temporary,slot_name,lsn}',
prosrc => 'pg_copy_logical_replication_slot_b' },
{ oid => '4224', descr => 'copy a logical replication slot',
proname => 'pg_copy_logical_replication_slot', provolatile => 'v',
proparallel => 'u', prorettype => 'record', proargtypes => 'name name',
proallargtypes => '{name,name,name,pg_lsn}',
proargmodes => '{i,i,o,o}',
proargnames => '{src_slot_name,dst_slot_name,slot_name,lsn}',
prosrc => 'pg_copy_logical_replication_slot_c' },
{ oid => '3782', descr => 'get changes from replication slot',
proname => 'pg_logical_slot_get_changes', procost => '1000',
prorows => '1000', provariadic => 'text', proisstrict => 'f',

View File

@@ -97,6 +97,7 @@ extern void CheckLogicalDecodingRequirements(void);
extern LogicalDecodingContext *CreateInitDecodingContext(char *plugin,
List *output_plugin_options,
bool need_full_snapshot,
XLogRecPtr restart_lsn,
XLogPageReadCB read_page,
LogicalOutputPluginWriterPrepareWrite prepare_write,
LogicalOutputPluginWriterWrite do_write,