SQLSTATE XX001 ERROR Class XX: Internal Error

data_corrupted catalog is missing N attribute(s) for relid N — XX001

PostgreSQL error "catalog is missing N attribute(s) for relid N" (SQLSTATE XX001): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

PostgreSQL found a relation in pg_class whose pg_attribute rows are missing or fewer than expected. The system catalogs are inconsistent, so it raises SQLSTATE XX001 (data_corrupted).

  • A relation’s column metadata is incomplete.
  • Indicates system-catalog corruption.
  • Queries touching the relation fail.

What the server log shows

ERROR:  catalog is missing 2 attribute(s) for relid 24576

Why PostgreSQL raises this — what the manual says

Section 52.7 pg_attribute:

“There will be exactly one pg_attribute row for every column in every table in the database.”

Every column of a relation must have a matching pg_attribute row. If rows are missing, the catalog cannot describe the relation’s shape — corruption — so PostgreSQL reports XX001.

Common causes

  • System-catalog corruption from hardware/storage faults.
  • Improper recovery or manual catalog tampering.
  • Crashes with disabled fsync.

How to fix it

  1. Back up the current state and treat this as serious corruption.
  2. Restore from a known-good backup.
  3. Run hardware/filesystem diagnostics; never hand-edit system catalogs to “fix” it.

Related & next steps

Reference: PostgreSQL 18 Section 53.7 “pg_attribute”.

Was this helpful?