pg_check
pg_check · Provides basic integrity checks for data files.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100125 | pg_check | pg_check | 0.1.0 | ADMIN | BSD-3-Clause | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
pg_check 0.1.0 performs basic consistency checks on heap tables and B-tree indexes. It examines page headers, overlapping items, tuple attribute bounds, and invalid varlena sizes, and can cross-check heap tuples against index entries to find missing or superfluous items.
Run a conservative check
pg_check_table(regclass,bool,bool,bigint,bigint) returns an issue count and can optionally check indexes and cross-check them against the heap. pg_check_index(regclass,bigint,bigint) checks all or a selected block range. Detail is emitted as server messages according to client_min_messages; pg_check.debug and pg_check.bitmap_format control additional cross-check diagnostics.
Locking and scope
Do not omit the Boolean arguments without understanding the defaults: both index checking and cross-checking default to true. A cross-check takes SHARE ROW EXCLUSIVE on the table, blocks data changes for the duration, and can deadlock with sessions that acquire table and index locks in another order. A non-cross-check uses ACCESS SHARE.
The extension reports problems but does not repair them, and structural index validation is limited to B-tree page/item checks. The reviewed C source predates current PostgreSQL releases and publishes no modern compatibility matrix; test it against the exact server build and take a backup before using low-level diagnostic tooling on important data.