42710
Read PG 18 manual ↗duplicate_object
- SQLSTATE
- 42710
- Condition name
- duplicate_object
- Class
- Syntax Error or Access Rule Violation
- Source macro
- ERRCODE_DUPLICATE_OBJECT
- Evidence
- Observed at runtime in the source evidence
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
At a glance
42710 is duplicate_object: a definition collides with an occupied object name. The selected path is a second CREATE TYPE ... AS ENUM; the same SQLSTATE is reused by other object-definition paths, so first identify the object kind and schema.
Meaning
The DefineEnum path reports type "%s" already exists; this is a catalog-definition collision, not a row-level unique violation. CREATE OR REPLACE is not a universal repair. Inspect pg_type joined to pg_namespace, ownership, and migration order. The selected autocommit error leaves IDLE; an explicit transaction must be rolled back before more commands.
Diagnosis
Inspect the exact object kind and schema first. For a type, query pg_type joined to pg_namespace; for a relation use to_regclass, and for a routine inspect pg_proc and pg_get_function_identity_arguments. Check ownership and migration order.
Response
Choose an intentionally free name, or use an object-specific alter/replace operation only when the existing owner is yours. The case repairs by creating a distinct ENUM. A preflight check does not remove a concurrent-create race, and dropping an unknown object is unsafe. In an explicit transaction, the failed definition leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit case remains IDLE.
Observed diagnostics
CREATE TYPE in this ENUM branch has explicit ERROR severity and no hint; other 42710 branches have different templates, including a heap.c relation/type hint that does not belong here.
Representative case
This disposable case creates an ENUM, repeats its definition, checks the code and state, then creates a distinct type and verifies both catalog entries.
CREATE TYPE syntax_schema.duplicate_object_type AS ENUM ('first');
CREATE TYPE syntax_schema.duplicate_object_type AS ENUM ('first');
CREATE TYPE syntax_schema.duplicate_object_type_repaired AS ENUM ('first');
SELECT count(*) FROM pg_type t JOIN pg_namespace n ON n.oid = t.typnamespace WHERE n.nspname = 'syntax_schema_name' AND t.typname IN ('duplicate_object_type', 'duplicate_object_type_repaired');
The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.
Versions
The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.
Sources
src.errcodes.REL_18_6— fixed definition at724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba(source).src.duplicate-enum.18.6—src/backend/commands/typecmds.clines 1219–1221 at724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-25660d1e9754646e100f6b74aa367ad8c2c52386c400df721707423d329209c47eb(source).src.duplicate-enum.10.23—src/backend/commands/typecmds.clines 1139–1141 at02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256fa1dfb766f7a3117eb677461ede774d5ba7c25324cbbd2a200435fa9c9c8e863(source).src.calls.REL_18_6/src.calls.REL_10_23— fixed call scans, SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf/00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.manifest.42710/snippet-registry.42710— hashes are recorded inevidence/42710.jsonand each runtime record.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
42710 is the duplicate_object condition in Class 42.
Method: Read fixed errcodes.txt and locked catalogue metadata.
Limits: Identity does not identify every backend call that can reuse this SQLSTATE.
The selected duplicate_object_type follows a resolved PostgreSQL source-call group; other branches can use different dynamic fields.
Method: Trace the REL_18_6 and REL_10_23 source-call records at the locked commits.
Limits: This is one mechanism boundary, not an exhaustive inventory of the code.
ENUM type definitions collide by name; inspect pg_type/pg_namespace and use a deliberate distinct name.
Method: Combine the selected source call, registry SQL, and passed structured assertions.
Limits: The claim describes the selected path and does not generalize to every branch sharing this SQLSTATE.
src.duplicate-enum.18.6 src.duplicate-enum.10.23 snippet-registry.42710
The selected duplicate_object_type passed on isolated PostgreSQL 18.6 and 10.21 targets.
Method: Run the shared SQL registry and inspect SQLSTATE, severity, state, repair, cleanup, and target stop.
Limits: Scope is limited to these statements, psycopg, and two versions.
The locked catalogue records 42710 from the 7.4 presence bound through the listed snapshots; runtime scope is 18.6 and 10.21.
Method: Read generated facts, fixed calls, and selected summaries.
Limits: Definition presence is not an exact behavioral introduction; two runtime versions do not prove every intermediate behavior.
src.errcodes.REL_18_6 src.calls.REL_18_6 src.calls.REL_10_23
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 raw/calls/REL_18_6.jsonl· ·raw/calls/REL_10_23.jsonl· ·- src/backend/commands/typecmds.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/commands/typecmds.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 verify/cases/42710/cases.json· ·verify/cases/42710/snippets.json· ·
Message templates
explicit ERROR · message.duplicate_object_type
Primary
type "%s" already exists
Reproduction & repair cases
duplicate_object_type · PG 10, 18
Preconditions
- A runner-owned disposable target is provisioned.
Trigger: Create the same ENUM type name twice in the runner schema.
Expected assertions
- SQLSTATE is 42710 with the duplicate type message and its naming hint
- The failed autocommit session remains IDLE
- Creating a nonconflicting type and inspecting pg_type succeeds
Repair: Use a distinct type name after confirming the existing type; do not drop an unknown owner's object.
Cleanup: Drop the runner schema and all types it owns.
Recorded runtime evidence
18.6 (Homebrew) · passed
Run: syntax2-42710-latest2
{
"diagnostic": {
"text": "type \"duplicate_object_type\" already exists",
"context": null,
"severity": "ERROR",
"sqlstate": "42710",
"table_name": null,
"column_name": null,
"schema_name": null,
"source_file": "typecmds.c",
"source_line": "1221",
"message_hint": null,
"datatype_name": null,
"exception_type": "DuplicateObject",
"internal_query": null,
"message_detail": null,
"constraint_name": null,
"message_primary": "type \"duplicate_object_type\" already exists",
"source_function": "DefineEnum",
"internal_position": null,
"statement_position": null,
"severity_nonlocalized": "ERROR"
},
"type_count": 2,
"failed_status": "IDLE",
"repair_status": "IDLE",
"connection_autocommit": true
}10.21 (Debian 10.21-1.pgdg90+1) · passed
Run: syntax2-42710-pg10
{
"diagnostic": {
"text": "type \"duplicate_object_type\" already exists",
"context": null,
"severity": "ERROR",
"sqlstate": "42710",
"table_name": null,
"column_name": null,
"schema_name": null,
"source_file": "typecmds.c",
"source_line": "1141",
"message_hint": null,
"datatype_name": null,
"exception_type": "DuplicateObject",
"internal_query": null,
"message_detail": null,
"constraint_name": null,
"message_primary": "type \"duplicate_object_type\" already exists",
"source_function": "DefineEnum",
"internal_position": null,
"statement_position": null,
"severity_nonlocalized": "ERROR"
},
"type_count": 2,
"failed_status": "IDLE",
"repair_status": "IDLE",
"connection_autocommit": true
}Definition snapshot: english-manuals:d7de67875eb151042b04f4efd17… · English manual source