# 42710 — Duplicate object

> PostgreSQL SQLSTATE 42710: Duplicate object (duplicate_object), source-backed diagnosis and recovery guidance.
---

# 42710 — Duplicate object

## At a glance {#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.

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| Field | Value |
| --- | --- |
| SQLSTATE | `42710` |
| Condition | `duplicate_object` |
| 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_DUPLICATE_OBJECT` |
| Aliases | `—` |

<!-- source facts: data/errcodes/42710.json -->
<!-- END SQLSTATE FACTS -->

## Meaning {#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 {#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 {#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 {#messages}

`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 {#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.

<!-- BEGIN SQLSTATE SNIPPET: duplicate_object_type -->

```sql
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');
```

<!-- END SQLSTATE SNIPPET -->

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See [`case JSON`](../data/cases/42710.json) and [`authored evidence`](../data/evidence/42710.json); private manifest and registry hashes are recorded there.

## Versions {#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.

## Related {#related}

- [`42723`](../42723/)
- [`42725`](../42725/)
- [`42883`](../42883/)

## Sources {#sources}

- `src.errcodes.REL_18_6` — fixed definition at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; SHA-256 `6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L1-L1)).
- `src.duplicate-enum.18.6` — `src/backend/commands/typecmds.c` lines 1219–1221 at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; blob SHA-256 `60d1e9754646e100f6b74aa367ad8c2c52386c400df721707423d329209c47eb` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/typecmds.c#L1219-L1221)).
- `src.duplicate-enum.10.23` — `src/backend/commands/typecmds.c` lines 1139–1141 at `02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4`; blob SHA-256 `fa1dfb766f7a3117eb677461ede774d5ba7c25324cbbd2a200435fa9c9c8e863` ([source](https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/commands/typecmds.c#L1139-L1141)).
- `src.calls.REL_18_6` / `src.calls.REL_10_23` — fixed call scans, SHA-256 `9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf` / `00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c`.
- `manifest.42710` / `snippet-registry.42710` — hashes are recorded in `evidence/42710.json` and each runtime record.
