SQLSTATE 42P22Severity lowLab verified

Incident brief

Indeterminate collation

When PostgreSQL cannot derive a collation for a string operation, it raises this error and hints to add an explicit COLLATE clause.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
Indeterminate collation
What triggers it
Perform a string comparison where no collation can be derived from the inputs.
The fix
Add an explicit COLLATE clause to set the collation for the operation.
Proof
Reproduced on PostgreSQL 18.4 → A single query reproduces SQLSTATE 42P22; without a derivable collation the comparison is rejected with a hint.

The fix

What to do right now

The immediate, application-level response to this error.

  • Add an explicit COLLATE clause to set the collation for the operation.
  • Apply the same collation to both operands so the comparison is well-defined.
Fix — SQL
-- Set the collation explicitly with COLLATE.
SELECT (label COLLATE "C") < (note COLLATE "C") FROM coll_demo2;

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 18.4
Last verified
2026-07-24 (isolated lab, PostgreSQL 18.4)
Reviewed by
Verified against PostgreSQL 18.4 in an isolated lab environment
Audit status
reviewed