SQLSTATE 42P21Severity lowLab verified

Incident brief

Collation mismatch (explicit collations)

A comparison cannot combine two different explicit COLLATE clauses; applying 'C' to one side and 'POSIX' to the other raises this collation-mismatch error.

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
Collation mismatch (explicit collations)
What triggers it
Compare two expressions where each side carries a different explicit COLLATE clause.
The fix
Use a single explicit collation for the comparison, or none and let the column defaults apply.
Proof
Reproduced on PostgreSQL 18.4 → A single query reproduces SQLSTATE 42P21; the two conflicting explicit collations cannot be combined.

The fix

What to do right now

The immediate, application-level response to this error.

  • Use a single explicit collation for the comparison, or none and let the column defaults apply.
  • Apply one COLLATE to the whole comparison rather than a different one to each side.
Fix — SQL
-- Use one collation (or the column defaults) for the comparison.
SELECT label = note FROM coll_demo;

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