unsafe use of new value “…” of enum type …
Symptoms
A statement failed with SQLSTATE 55P04 (unsafe_new_enum_value_usage), reported at severity ERROR. This is a Object Not In Prerequisite State condition: PostgreSQL emits the message unsafe use of new value "…" of enum type ….
- The client receives SQLSTATE
55P04(unsafe new enum value usage). - The operation is rejected at
ERRORlevel; the statement does not complete.
What the server log shows
ERROR: unsafe use of new value "…" of enum type …
HINT: New enum values must be committed before they can be used.
Why PostgreSQL raises this
Class 55 (Object Not In Prerequisite State) is raised when an object exists but is not in a state that allows the requested operation right now.
As described in PostgreSQL’s Appendix A PostgreSQL Error Codes, SQLSTATE 55P04 carries the condition name unsafe_new_enum_value_usage in class Object Not In Prerequisite State. (Paraphrased — see the linked reference for the exact wording.)
Common causes
- The object is locked, in use, or being modified by another session.
- A required precondition (e.g. an index, a prepared state) is not met.
- The operation cannot run while the object is in its current state.
How to fix it
- Wait for the conflicting session/operation to finish, then retry.
- Establish the missing precondition before retrying.
- Check for blocking locks with
pg_locks.
Version applicability
This message is present in PostgreSQL 15, 16, 17, 18 and 19.
Related & next steps
Reference: PostgreSQL Appendix A PostgreSQL Error Codes.