Skip to content

55000 — Object not in prerequisite state

PostgreSQL SQLSTATE 55000: Object not in prerequisite state (object_not_in_prerequisite_state), source-backed diagnosis and recovery guidance.

55000 — Object not in prerequisite state

At a glance

55000 means the requested operation lacks a required object or server state. This page selects the session-local sequence prerequisite behind currval; preload, recovery, and invalid-index paths are separate mechanisms.

Field Value
SQLSTATE 55000
Condition object_not_in_prerequisite_state
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
Aliases

Meaning

currval is defined per backend session. Creating a sequence, or calling nextval in another session, does not initialize the current session. The fixed sequence template is currval of sequence "%s" is not yet defined in this session with ERROR severity.

Other fixed 55000 paths have different prerequisites. pg_stat_statements reports pg_stat_statements must be loaded via "shared_preload_libraries"; add the extension to that startup setting and restart the server through the normal configuration procedure. pg_surgery reports recovery is in progress with detail Heap surgery functions cannot be executed during recovery.; wait for recovery to finish or run the operation on the appropriate writable primary. pgstattuple reports index "%s" is not valid; inspect the index and rebuild it with the appropriate REINDEX or migration procedure before using that function. These are object or server-state checks, not permission failures and not interchangeable with the session-local sequence case.

Diagnosis

Check the exact object state and the backend session that owns it. For this path, identify the sequence and verify whether this backend has called nextval; a pooled connection that ran nextval is a different prerequisite state. In an explicit transaction, a failed currval aborts the transaction, so issue ROLLBACK or ROLLBACK TO SAVEPOINT before repairing it. For other 55000 paths inspect recovery, preload settings, index validity, or object-specific prerequisites.

Response

Call nextval in the same backend before currval, or pass an explicitly known value when that is the intended contract. In autocommit, reconnecting or issuing the next statement is possible because the failed statement’s transaction has ended; inside an explicit transaction, recover with a rollback or savepoint before calling nextval. Do not treat this as a privilege failure or assume a successful call from a pool’s different connection initializes the current one.

Observed diagnostics

The selected source group is ERROR with the dynamic sequence-name template above. Runtime diagnostics named currval_sequence; after the failure the autocommit session stayed IDLE, and the same session then returned 10 from nextval and currval.

Representative case

The selected registry creates the sequence and then, on one autocommit backend, calls currval before any nextval, initializes the sequence with nextval (returning 10), and reads currval again (returning 10). The failing call, repair, and verification are therefore one session-scoped state transition; this case does not test a connection-pool handoff.

CREATE SEQUENCE sequence_identifier START WITH 10;
SELECT currval('sequence_regclass');
SELECT nextval('sequence_regclass');
SELECT currval('sequence_regclass')

The selected PostgreSQL 18.6 and 10.21 runs passed SQLSTATE, severity, state or disconnect recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence.

Versions

The locked catalogue records 55000 from 7.4 through the listed snapshots. The sequence-session case passed on 18.6 and 10.21; these observations do not cover the other 55000 branches or infer every intermediate implementation.

Sources

  • src.errcodes.18.6src/backend/utils/errcodes.txt at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.currval.18.6src/backend/commands/sequence.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 3e5afe17d5a84862fae502a5481211220368f1d639e9d07ba6f96ee8be92a8d8 (source).
  • src.currval.10.23src/backend/commands/sequence.c at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 5510e1266e8d8c548a4318d753392e92e689d348f3353a2aa53d8dea871c44ab (source).
  • src.path.0contrib/pg_stat_statements/pg_stat_statements.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7, the shared_preload_libraries guard (source).
  • src.path.1contrib/pg_surgery/heap_surgery.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7, the recovery guard and detail (source).
  • src.path.2contrib/pgstattuple/pgstatindex.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7, the invalid-index guard (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.55000 / snippet-registry.55000 — hashes are recorded in evidence/55000.json and each selected runtime record.