2025年9月25日: PostgreSQL 18 釋出!
支援版本: 當前 (18)
開發版本: devel

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/0
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/0
next_phase_at            | 0
committed_count          | 0
committed_xip            |
catchange_count          | 2
catchange_xip            | {751,752}

如果 filename 與快照檔案不匹配,則該函式會引發錯誤。

F.28.2. 作者 #

Bertrand Drouvot

提交更正

如果您在文件中發現任何不正確、與您對特定功能的體驗不符或需要進一步澄清的內容,請使用 此表單 報告文件問題。