SQLSTATE 42725 ERROR Class 42: Syntax Error or Access Rule Violation

ambiguous_function operator is not unique: … — 42725

PostgreSQL error "operator is not unique: …" (SQLSTATE 42725): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

An operator call matched more than one candidate operator and PostgreSQL could not choose a single best match. It refuses to guess and raises SQLSTATE 42725 (ambiguous_function).

  • Usually involves untyped literals or parameters with several plausible coercions.
  • A HINT suggests adding explicit casts.
  • Closely related to 42883 (no operator) but here there are too many.

What the server log shows

ERROR:  operator is not unique: unknown || unknown
LINE 1: SELECT $1 || $2;
                  ^
HINT:  Could not choose a best candidate operator. You might need to add explicit type casts.

Why PostgreSQL raises this — what the manual says

As Section 10.2 Operators explains:

More than one candidate operator matched the call equally well after type-conversion rules were applied, so PostgreSQL could not choose a single best match; add an explicit cast on one operand to disambiguate.

Operator resolution narrows candidates by exact and implicit-cast matches, then by preferred types. If several equally-good candidates remain — common when operands are unknown (untyped literals) or parameters — the system cannot pick one and reports 42725.

Common causes

  • Concatenating or comparing two untyped literals/parameters.
  • A user-defined operator overlapping a built-in for the same operand types.
  • Ambiguous numeric vs text coercion paths.

How to fix it

  1. Cast operands to concrete types: $1::text || $2::text.
  2. Type at least one side so preferred-type rules can resolve the rest.
  3. Avoid defining overlapping custom operators, or schema-qualify the intended one.

Related & next steps

Reference: PostgreSQL 18 Section 10.2 “Operators”.

Was this helpful?