Contents
pg_create_logical_replication_slot()
A function for creating a logical replication slot
pg_create_logical_replication_slot()
is a system function for creating a logical replication slot.
pg_create_logical_replication_slot()
was added in PostgreSQL 9.4.
Usage
pg_create_logical_replication_slot (slot_name
name
,plugin
name
[,temporary
boolean
,two_phase
boolean
] )
→ record (slot_name
name
,lsn
pg_lsn
)
PostgreSQL 10 ~ PostgreSQL 13:
pg_create_logical_replication_slot (slot_name
name
,plugin
name
[,temporary
boolean
] )
→ record (slot_name
name
,lsn
pg_lsn
)
PostgreSQL 9.4 ~ PostgreSQL 9.6:
pg_create_logical_replication_slot (slot_name
name
,plugin
name
)
→ record (slot_name
name
,lsn
pg_lsn
)
Change history
- PostgreSQL 14
- option
two_phase
added (commit 19890a06)
- option
- PostgreSQL 10
- option
temporary
added (commit a924c327)
- option
- PostgreSQL 9.4
- added (commit b89e1510)
Examples
Using pg_create_logical_replication_slot()
to create a logical replication slot with the test_decoding
sample output plugin:
postgres=# SELECT * FROM pg_create_logical_replication_slot('test_slot_1', 'test_decoding'); slot_name | lsn -------------+----------- test_slot_1 | 0/3000758 (1 row) postgres=# SELECT * FROM pg_replication_slots\gx -[ RECORD 1 ]-------+-------------- slot_name | test_slot_1 plugin | test_decoding slot_type | logical datoid | 13756 database | postgres temporary | f active | f active_pid | xmin | catalog_xmin | 722 restart_lsn | 0/3000720 confirmed_flush_lsn | 0/3000758 wal_status | reserved safe_wal_size | two_phase | f
References
- PostgreSQL documentation: Replication SQL Functions