↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

支持中的版本: 当前版本 (18)
开发中的版本: 19 / 20devel
开发快照。 PostgreSQL 20devel 尚未正式发布,内容仍可能变化。

F.28. pg_logicalinspect — 逻辑解码组件检查 #

pg_logicalinspect 模块提供 SQL 函数,允许你检查逻辑解码组件的内容。它还允许检查运行中的 PostgreSQL 数据库集簇的序列化逻辑快照,这对调试或教学用途很有帮助。

默认情况下,这些函数仅允许超级用户和 pg_read_server_files 角色成员使用。超级用户可通过 GRANT 向其他用户授予访问权限。

F.28.1. 函数 #

pg_get_logical_snapshot_meta(filename text) returns record #

获取位于服务器 pg_logical/snapshots 目录中的快照文件的逻辑快照元数据。filename 参数表示快照文件名。例如:

postgres=# SELECT * FROM pg_ls_logicalsnapdir();
-[ RECORD 1 ]+-----------------------
name         | 0-40796E18.snap
size         | 152
modification | 2024-08-14 16:36:32+00

postgres=# SELECT * FROM pg_get_logical_snapshot_meta('0-40796E18.snap');
-[ RECORD 1 ]--------
magic    | 1369563137
checksum | 1028045905
version  | 6

postgres=# SELECT ss.name, meta.* FROM pg_ls_logicalsnapdir() AS ss,
pg_get_logical_snapshot_meta(ss.name) AS meta;
-[ RECORD 1 ]-------------
name     | 0-40796E18.snap
magic    | 1369563137
checksum | 1028045905
version  | 6

如果 filename 不是某个快照文件名,则函数报错。

pg_get_logical_snapshot_info(filename text) returns record #

获取位于服务器 pg_logical/snapshots 目录中的快照文件的逻辑快照信息。filename 参数表示快照文件名。例如:

postgres=# SELECT * FROM pg_ls_logicalsnapdir();
-[ RECORD 1 ]+-----------------------
name         | 0-40796E18.snap
size         | 152
modification | 2024-08-14 16:36:32+00

postgres=# SELECT * FROM pg_get_logical_snapshot_info('0-40796E18.snap');
-[ RECORD 1 ]------------+-----------
state                    | consistent
xmin                     | 751
xmax                     | 751
start_decoding_at        | 0/40796AF8
two_phase_at             | 0/40796AF8
initial_xmin_horizon     | 0
building_full_snapshot   | f
in_slot_creation         | f
last_serialized_snapshot | 0/00000000
next_phase_at            | 0
committed_count          | 0
committed_xip            |
catchange_count          | 2
catchange_xip            | {751,752}

postgres=# SELECT ss.name, info.* FROM pg_ls_logicalsnapdir() AS ss,
pg_get_logical_snapshot_info(ss.name) AS info;
-[ RECORD 1 ]------------+----------------
name                     | 0-40796E18.snap
state                    | consistent
xmin                     | 751
xmax                     | 751
start_decoding_at        | 0/40796AF8
two_phase_at             | 0/40796AF8
initial_xmin_horizon     | 0
building_full_snapshot   | f
in_slot_creation         | f
last_serialized_snapshot | 0/00000000
next_phase_at            | 0
committed_count          | 0
committed_xip            |
catchange_count          | 2
catchange_xip            | {751,752}

如果 filename 不是某个快照文件名,则函数报错。

F.28.2. 作者 #

Bertrand Drouvot

报告文档问题

阅读 上游文档. 反馈更正前请先核对 当前版本手册.