amcheck
functions for verifying relation integrity
amcheck · functions for verifying relation integrity
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 5980 | amcheck | amcheck | 1.5 | ADMIN | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | pg_checksums pg_catcheck pg_orphaned pg_pathcheck pg_isok pg_surgery pageinspect adminpack pg_repack |
PG18 SQL/control baseline 1.5; older PostgreSQL majors may differ.
Packages
| PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|
| 1.5 | 1.5 | 1.5 | 1.5 | 1.5 |
This contrib extension ships with PostgreSQL.
Install
Create this extension with:
Usage
The amcheck extension provides functions to verify the logical consistency of B-tree indexes, GIN indexes, and heap (table) data, detecting corruption without modifying data.
B-Tree Index Verification
Check All Catalog Indexes
GIN Index Verification
Heap (Table) Verification
Returns rows for each detected problem:
| Column | Type | Description |
|---|---|---|
blkno | bigint | Block number with corruption |
offnum | integer | Offset of corrupt tuple |
attnum | integer | Attribute number (if column-specific) |
msg | text | Description of the problem |
Function Summary
| Function | Lock | Use Case |
|---|---|---|
bt_index_check(index, heapallindexed, checkunique) | AccessShareLock | Routine production checks |
bt_index_parent_check(index, heapallindexed, rootdescend, checkunique) | ShareLock | Comprehensive verification |
gin_index_check(index) | AccessShareLock | GIN index verification |
verify_heapam(relation, on_error_stop, check_toast, skip, startblock, endblock) | AccessShareLock | Table/heap corruption detection |
All amcheck errors are true positives. Use REINDEX or point-in-time recovery for repair after diagnosing with pageinspect.