PostgreSQL error code
PostgreSQL error 42P21
42P21 is the SQLSTATE PostgreSQL reports for collation mismatch, in class 42, Syntax Error or Access Rule Violation.
| SQLSTATE | 42P21 |
|---|---|
| Condition name | collation_mismatch |
| Class | 42 — Syntax Error or Access Rule Violation |
Reproduce it, then fix it
Each side of the comparison names a different collation with COLLATE, and PostgreSQL won’t choose between them. Name one; an explicit collation on either side decides the comparison. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT name COLLATE "C" < category COLLATE "POSIX" FROM products;
SELECT name COLLATE "C" < category FROM products;