# 42725 — Ambiguous function

> PostgreSQL SQLSTATE 42725: Ambiguous function (ambiguous_function), source-backed diagnosis and recovery guidance.
---

# 42725 — Ambiguous function

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

`42725` is **ambiguous_function**: lookup found multiple viable candidates but no best one. The case defines `uuid` and `jsonb` overloads and passes an unknown string literal.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `42725` |
| Condition | `ambiguous_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_AMBIGUOUS_FUNCTION` |
| Aliases | `—` |

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

## Meaning {#meaning}

Overload resolution considers literal type, casts, schema visibility, and signatures. With an `unknown` literal both candidates remain viable, so the parser reports `function %s is not unique`; this differs from `42723` (definition collision) and `42883` (no candidate). Inspect visible `pg_proc` rows and argument types.

## Diagnosis {#diagnosis}

List visible candidates in pg_proc, including their identity arguments and input types, and inspect the inferred type of each literal. Schema qualification narrows visibility but does not choose between overloads.

## Response {#response}

Cast to the type that matches the business meaning or remove an unintended overload. `::uuid` selects the UUID overload here. Do not add casts merely to silence an error: they can change validation and overload behavior. In an explicit transaction, the ambiguity leaves `INERROR`; roll back or return to a suitable savepoint before retrying. The selected autocommit session remains `IDLE`.

## Observed diagnostics {#messages}

The fixed parser group is explicit `ERROR`: `function %s is not unique`, with the hint `Could not choose a best candidate function. You might need to add explicit type casts.`

## Representative case {#case}

The registry creates both overloads, triggers with the unknown literal, then repeats the call with an explicit UUID cast and asserts the result.

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

```sql
CREATE FUNCTION syntax_schema.ambiguous_function(uuid) RETURNS text LANGUAGE SQL AS 'SELECT ''uuid''';
CREATE FUNCTION syntax_schema.ambiguous_function(jsonb) RETURNS text LANGUAGE SQL AS 'SELECT ''jsonb''';
SELECT syntax_schema.ambiguous_function('123e4567-e89b-12d3-a456-426614174000');
SELECT syntax_schema.ambiguous_function('123e4567-e89b-12d3-a456-426614174000'::uuid);
```

<!-- 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/42725.json) and [`authored evidence`](../data/evidence/42725.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/)
- [`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.ambiguous-function.18.6` — `src/backend/parser/parse_func.c` lines 570–577 at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; blob SHA-256 `48314eab022297478ac4e49786afaff2621ab7b1d7b50e156668cf477961384f` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_func.c#L570-L577)).
- `src.ambiguous-function.10.23` — `src/backend/parser/parse_func.c` lines 499–506 at `02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4`; blob SHA-256 `f1b4af88565ca01dbad2b244cd26b42f34764b3f1343b22a9231e271fb0742f2` ([source](https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/parser/parse_func.c#L499-L506)).
- `src.calls.REL_18_6` / `src.calls.REL_10_23` — fixed call scans, SHA-256 `9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf` / `00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c`.
- `manifest.42725` / `snippet-registry.42725` — hashes are recorded in `evidence/42725.json` and each runtime record.
