55P04ERRORTier 2 — Caution✅ HIGH confidenceunsafe use of new enum value
What this means
SQLSTATE 55P04 is raised when a newly added enum value (via ALTER TYPE ... ADD VALUE) is used in a query within the same transaction that added it. Postgres cannot safely use a new enum value until the transaction that added it commits.
Why it happens
- 1Using a new enum label in the same transaction that added it with ALTER TYPE ... ADD VALUE
How to reproduce
Using a new enum value in the same transaction that added it.
BEGIN;
ALTER TYPE status_enum ADD VALUE 'archived';
INSERT INTO orders (status) VALUES ('archived'); -- 55P04: value not committed yet
COMMIT;Fix 1: Commit the ALTER TYPE in a separate transaction before using the new value
When adding a new enum value and then using it.
-- Transaction 1:
ALTER TYPE status_enum ADD VALUE 'archived';
-- COMMIT;
-- Transaction 2 (after COMMIT):
INSERT INTO orders (status) VALUES ('archived');Why this works
The new enum value is not visible to catalog lookups until the adding transaction commits. Using it in two separate transactions resolves the ordering dependency.
Version notes
Postgres 9.1+ALTER TYPE ... ADD VALUE introduced in Postgres 9.1. The same-transaction restriction has applied since then.Sources
📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html
🔧 Source ref: Class 55 — Object Not in Prerequisite State (Postgres-specific)
Confidence assessment
✅ HIGH confidence
Postgres-specific. Stable since 9.1. A common migration pitfall.
See also
🔗 Related errors
📄 Reference pages