42602 — invalid_name
42602
At a glance
SQLSTATE 42602 is invalid_name in Class 42. 42602 is an invalid name. The selected enum path rejects a 64-byte label with primary invalid enum label "%s" and a length detail; a short label can be added afterwards.
| Field | Value |
|---|---|
| SQLSTATE | 42602 |
| Condition | invalid_name |
| 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_INVALID_NAME |
| Aliases | — |
Meaning
42602 is an invalid name. In AddEnumLabel, PostgreSQL checks the incoming enum label against NAMEDATALEN - 1 before changing the catalog. The selected 64-byte label therefore raises an explicit ERROR with primary invalid enum label "%s" and a length DETAIL; a short label can be added afterwards. This is the enum-label path, not a claim that every invalid object name uses the same producer.
Diagnosis
Inspect the object kind and the exact length wording in the DETAIL. This batch observes the enum-label path on 18.6 and 10.21: the 18.6 source/runtime says Labels must be 63 bytes or less., while the 10.21 source/runtime says Labels must be 63 characters or less. That wording difference alone does not establish a changed length mechanism; both fixed guards compare the label against NAMEDATALEN - 1. The failed DDL is an ERROR on autocommit and leaves the selected session IDLE.
Response
Choose a label within the server limit or store the long user value as data. Preserve the enum type and add a valid short label only after the failed statement has returned; the selected repair leaves the type with ok and short. Do not silently truncate enum labels or treat this enum-specific path as every possible naming error.
Messages
The selected source path emits an explicit ERROR with primary invalid enum label "%s". Its DETAIL is Labels must be 63 bytes or less. on 18.6 and Labels must be 63 characters or less. on 10.21; the label text is dynamic. A client exception without the server SQLSTATE, primary, and length DETAIL is not sufficient to identify this selected enum-label subpath; other fixed producers can use the same SQLSTATE with different diagnostics.
Representative case
The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.
The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42602 case JSON and authored evidence. The runner manifest is verify/cases/42602/cases.json, and the page SQL is checked against its shared registry.
Versions
The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.
Related
Sources
src.errcodes.18.6— fixederrcodes.txtdefinition at commit724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba(source).src.enum-invalid-label.18.6—src/backend/catalog/pg_enum.catREL_18_6commit724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256849793e92baf9c0e4e8950f8472e2772289c22c58a4ea93997ef0218d7e4b3fc(source).src.enum-invalid-label.10.23—src/backend/catalog/pg_enum.catREL_10_23commit02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-25608076bbd661f4c400cf9741f4cfe89c5b0daf3383e4a3e6ac10f3f8f4bec16a6(source).src.calls.REL_18_6/src.calls.REL_10_23— fixed call scans, SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf/00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.