pg_drop_replication_slot() 是一个系统函数,用于删除物理复制槽或逻辑复制槽。
pg_drop_replication_slot() 在 PostgreSQL 9.4 中添加。
用法
pg_drop_replication_slot (slot_namename) → void
要删除的复制槽必须处于非活动状态才能被删除。无法强制删除活动的复制槽。
变更历史
- PostgreSQL 9.4
- 添加 (提交 858ec118)
示例
使用 pg_drop_replication_slot() 删除复制槽
postgres=# SELECT pg_drop_replication_slot('node2');
pg_drop_replication_slot
--------------------------
(1 row)
无法删除活动的复制槽
postgres=# SELECT slot_name, slot_type, active FROM pg_replication_slots; slot_name | slot_type | active -----------+-----------+-------- node2 | physical | t (1 row) postgres=# SELECT pg_drop_replication_slot('node2'); ERROR: replication slot "node2" is active for PID 17675
尝试删除不存在的复制槽
postgres=# SELECT pg_drop_replication_slot('foo');
ERROR: replication slot "foo" does not exist
参考资料
- PostgreSQL 文档: 复制管理函数
另请参阅
反馈
请在此处提交关于“pg_drop_replication_slot()”的任何评论、建议或更正。