# 42723 — Duplicate function

> PostgreSQL SQLSTATE 42723: Duplicate function (duplicate_function), source-backed diagnosis and recovery guidance.
---

# 42723 — Duplicate function

## At a glance {#at-a-glance}

`42723` is **duplicate_function**: a function definition repeats the same schema, name, and input argument types. Output types do not create another overload.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `42723` |
| Condition | `duplicate_function` |
| 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_FUNCTION` |
| Aliases | `—` |

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

## Meaning {#meaning}

The fixed catalog path reports `function "%s" already exists with same argument types`. Inspect `pg_proc`, `pg_get_function_identity_arguments`, and the result contract. This is a definition collision, unlike `42725`, which occurs when call resolution has multiple candidates; the selected autocommit error leaves `IDLE`.

## Diagnosis {#diagnosis}

Inspect pg_proc with pg_get_function_identity_arguments and make the schema explicit. Decide whether the migration intends a new input signature or replacement of an owned function; output types do not disambiguate identity.

## Response {#response}

Use a new input signature for a genuinely different API. Use `CREATE OR REPLACE FUNCTION` only when replacing the owned function is intentional and its return contract stays compatible; it is not a safe input-type migration. In an explicit transaction, the duplicate definition leaves `INERROR`; roll back or return to a suitable savepoint before retrying. The selected autocommit path returns to `IDLE`.

## Observed diagnostics {#messages}

The `pg_proc.c` group is explicit `ERROR` with the fixed primary template and no detail or hint.

## Representative case {#case}

The runner creates `duplicate_function(integer)`, repeats that signature, then deliberately uses CREATE OR REPLACE and verifies the result `2`.

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

```sql
CREATE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1';
CREATE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1';
CREATE OR REPLACE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1 + 1';
SELECT syntax_schema.duplicate_function(1);
```

<!-- 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/42723.json) and [`authored evidence`](../data/evidence/42723.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}

- [`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-function.18.6` — `src/backend/catalog/pg_proc.c` lines 400–403 at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; blob SHA-256 `77a883995e5fadf17fae68722043beb43115e685e8082b2b7256d92312528a5a` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/pg_proc.c#L400-L403)).
- `src.duplicate-function.10.23` — `src/backend/catalog/pg_proc.c` lines 398–401 at `02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4`; blob SHA-256 `96ddd186536c24018d3e29fd7e8f7384543c89ede83c81f673dc013fdd23b0fe` ([source](https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/catalog/pg_proc.c#L398-L401)).
- `src.calls.REL_18_6` / `src.calls.REL_10_23` — fixed call scans, SHA-256 `9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf` / `00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c`.
- `manifest.42723` / `snippet-registry.42723` — hashes are recorded in `evidence/42723.json` and each runtime record.
