pg_replication_slots

列出所有复制槽的系统视图

pg_replication_slots 是一个列出所有复制槽的系统目录视图。

pg_replication_slotsPostgreSQL 9.4 中添加。

用法

底层函数 pg_replication_slots 直接读取磁盘上的复制槽结构,这意味着此视图的内容始终可见,而不管事务状态如何,并且可能在事务中发生更改。因此,在将其与其他关系(如 pg_stat_activity)结合使用时应注意,因为这些内容可能对当前事务不可见。

按 PostgreSQL 版本定义

pg_replication_slots (PostgreSQL 17)

                     View "pg_catalog.pg_replication_slots"
       Column        |           Type           | Collation | Nullable | Default 
---------------------+--------------------------+-----------+----------+---------
 slot_name           | name                     |           |          | 
 plugin              | name                     |           |          | 
 slot_type           | text                     |           |          | 
 datoid              | oid                      |           |          | 
 database            | name                     |           |          | 
 temporary           | boolean                  |           |          | 
 active              | boolean                  |           |          | 
 active_pid          | integer                  |           |          | 
 xmin                | xid                      |           |          | 
 catalog_xmin        | xid                      |           |          | 
 restart_lsn         | pg_lsn                   |           |          | 
 confirmed_flush_lsn | pg_lsn                   |           |          | 
 wal_status          | text                     |           |          | 
 safe_wal_size       | bigint                   |           |          | 
 two_phase           | boolean                  |           |          | 
 inactive_since      | timestamp with time zone |           |          | 
 conflicting         | boolean                  |           |          | 
 invalidation_reason | text                     |           |          | 
 failover            | boolean                  |           |          | 
 synced              | boolean                  |           |          |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 16)

             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          | 
 plugin              | name    |           |          | 
 slot_type           | text    |           |          | 
 datoid              | oid     |           |          | 
 database            | name    |           |          | 
 temporary           | boolean |           |          | 
 active              | boolean |           |          | 
 active_pid          | integer |           |          | 
 xmin                | xid     |           |          | 
 catalog_xmin        | xid     |           |          | 
 restart_lsn         | pg_lsn  |           |          | 
 confirmed_flush_lsn | pg_lsn  |           |          | 
 wal_status          | text    |           |          | 
 safe_wal_size       | bigint  |           |          | 
 two_phase           | boolean |           |          | 
 conflicting         | boolean |           |          |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 15)

             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          | 
 plugin              | name    |           |          | 
 slot_type           | text    |           |          | 
 datoid              | oid     |           |          | 
 database            | name    |           |          | 
 temporary           | boolean |           |          | 
 active              | boolean |           |          | 
 active_pid          | integer |           |          | 
 xmin                | xid     |           |          | 
 catalog_xmin        | xid     |           |          | 
 restart_lsn         | pg_lsn  |           |          | 
 confirmed_flush_lsn | pg_lsn  |           |          | 
 wal_status          | text    |           |          | 
 safe_wal_size       | bigint  |           |          | 
 two_phase           | boolean |           |          |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 14)

             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          | 
 plugin              | name    |           |          | 
 slot_type           | text    |           |          | 
 datoid              | oid     |           |          | 
 database            | name    |           |          | 
 temporary           | boolean |           |          | 
 active              | boolean |           |          | 
 active_pid          | integer |           |          | 
 xmin                | xid     |           |          | 
 catalog_xmin        | xid     |           |          | 
 restart_lsn         | pg_lsn  |           |          | 
 confirmed_flush_lsn | pg_lsn  |           |          | 
 wal_status          | text    |           |          | 
 safe_wal_size       | bigint  |           |          | 
 two_phase           | boolean |           |          |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 13)

             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          | 
 plugin              | name    |           |          | 
 slot_type           | text    |           |          | 
 datoid              | oid     |           |          | 
 database            | name    |           |          | 
 temporary           | boolean |           |          | 
 active              | boolean |           |          | 
 active_pid          | integer |           |          | 
 xmin                | xid     |           |          | 
 catalog_xmin        | xid     |           |          | 
 restart_lsn         | pg_lsn  |           |          | 
 confirmed_flush_lsn | pg_lsn  |           |          | 
 wal_status          | text    |           |          | 
 safe_wal_size       | bigint  |           |          |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 12)

             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          | 
 plugin              | name    |           |          | 
 slot_type           | text    |           |          | 
 datoid              | oid     |           |          | 
 database            | name    |           |          | 
 temporary           | boolean |           |          | 
 active              | boolean |           |          | 
 active_pid          | integer |           |          | 
 xmin                | xid     |           |          | 
 catalog_xmin        | xid     |           |          | 
 restart_lsn         | pg_lsn  |           |          | 
 confirmed_flush_lsn | pg_lsn  |           |          |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 11)

             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          | 
 plugin              | name    |           |          | 
 slot_type           | text    |           |          | 
 datoid              | oid     |           |          | 
 database            | name    |           |          | 
 temporary           | boolean |           |          | 
 active              | boolean |           |          | 
 active_pid          | integer |           |          | 
 xmin                | xid     |           |          | 
 catalog_xmin        | xid     |           |          | 
 restart_lsn         | pg_lsn  |           |          | 
 confirmed_flush_lsn | pg_lsn  |           |          |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 10)

             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          | 
 plugin              | name    |           |          | 
 slot_type           | text    |           |          | 
 datoid              | oid     |           |          | 
 database            | name    |           |          | 
 temporary           | boolean |           |          | 
 active              | boolean |           |          | 
 active_pid          | integer |           |          | 
 xmin                | xid     |           |          | 
 catalog_xmin        | xid     |           |          | 
 restart_lsn         | pg_lsn  |           |          | 
 confirmed_flush_lsn | pg_lsn  |           |          |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 9.6)

  View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Modifiers 
---------------------+---------+-----------
 slot_name           | name    | 
 plugin              | name    | 
 slot_type           | text    | 
 datoid              | oid     | 
 database            | name    | 
 active              | boolean | 
 active_pid          | integer | 
 xmin                | xid     | 
 catalog_xmin        | xid     | 
 restart_lsn         | pg_lsn  | 
 confirmed_flush_lsn | pg_lsn  |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 9.5)

View "pg_catalog.pg_replication_slots"
    Column    |  Type   | Modifiers 
--------------+---------+-----------
 slot_name    | name    | 
 plugin       | name    | 
 slot_type    | text    | 
 datoid       | oid     | 
 database     | name    | 
 active       | boolean | 
 active_pid   | integer | 
 xmin         | xid     | 
 catalog_xmin | xid     | 
 restart_lsn  | pg_lsn  |
    

文档: pg_replication_slots

pg_replication_slots (PostgreSQL 9.4)

View "pg_catalog.pg_replication_slots"
    Column    |  Type   | Modifiers 
--------------+---------+-----------
 slot_name    | name    | 
 plugin       | name    | 
 slot_type    | text    | 
 datoid       | oid     | 
 database     | name    | 
 active       | boolean | 
 xmin         | xid     | 
 catalog_xmin | xid     | 
 restart_lsn  | pg_lsn  |
    

文档: pg_replication_slots

更改历史记录

示例

当单个物理复制槽正在使用时,pg_replication_slots 的示例内容(截至 PostgreSQL 13

postgres=# SELECT * FROM pg_replication_slots\gx
-[ RECORD 1 ]-------+--------------
slot_name           | node2
plugin              |
slot_type           | physical
datoid              |
database            |
temporary           | f
active              | t
active_pid          | 1597000
xmin                |
catalog_xmin        |
restart_lsn         | 0/3002470
confirmed_flush_lsn |
wal_status          | reserved
safe_wal_size       |

分类

逻辑复制复制复制槽系统目录

另请参阅

pg_create_logical_replication_slot()pg_create_physical_replication_slot()pg_drop_replication_slot()

反馈

提交任何关于 "pg_replication_slots" 的评论、建议或更正 此处