# 42P22 — Indeterminate collation

> Source-backed reference for PostgreSQL SQLSTATE 42P22.
---

# 42P22 — Indeterminate collation

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

`42P22` (**indeterminate_collation**) An operation that needs one collation has no unambiguous collation to use.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `42P22` |
| Condition | `indeterminate_collation` |
| Status | `active` |
| Known present by | `9.1.0` |
| Locked snapshots | `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_INDETERMINATE_COLLATION` |
| Aliases | `—` |

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

## Meaning {#meaning}

`42P22` is emitted when a selected operation requires a usable collation but derivation produced none, often represented by `InvalidOid`. This is different from `42P21`: the caller-specific message names the operation that cannot proceed instead of presenting two explicit collation names. Fixed core callers include string hashing or comparison, index and partition expressions, CTAS and view output columns, regular expressions, `LIKE`/`ILIKE`, and formatting functions.

## Diagnosis {#diagnosis}

Read the operation named by the primary message and trace its string expression to the point where collation should be chosen. Hashing or comparison points to the operator or value expression; an index or partition message points to the definition expression; a CTAS or view-column message points to the output column; regex, `LIKE`, and `ILIKE` point to the pattern operands; a `%s function` message names the formatting function. The fixed callers supply the caller-specific HINT `Use the COLLATE clause to set the collation explicitly.`. Choose the expression or declared-column boundary deliberately, and distinguish this no-collation requirement from a `42P21` conflict between known choices.

## Response {#response}

Apply `COLLATE` at the expression or output-column boundary that owns the semantic choice, then recreate the affected index, partition, view, or CTAS definition when required. Verify comparison, hashing, pattern, regex, and formatting behavior under that collation; do not change the database locale globally just to silence one caller. If this `ERROR` occurs inside an explicit transaction, issue `ROLLBACK` or `ROLLBACK TO` a pre-error savepoint before retrying; autocommit can submit the corrected statement after returning to idle.

## Messages {#messages}

Representative fixed-source messages include:

- **ERROR** message: `could not determine which collation to use for string hashing`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `no collation was derived for column "%s" with collatable type %s`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `could not determine which collation to use for index expression`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `could not determine which collation to use for partition expression`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `could not determine which collation to use for view column "%s"`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `could not determine which collation to use for regular expression`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `could not determine which collation to use for %s function`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `could not determine which collation to use for LIKE`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `could not determine which collation to use for ILIKE`; HINT: `Use the COLLATE clause to set the collation explicitly.`
- **ERROR** message: `could not determine which collation to use for string comparison`; HINT: `Use the COLLATE clause to set the collation explicitly.`

Placeholders are filled by the actual object, column, or parameter.

## Versions {#versions}

The locked catalogue shows this condition by PostgreSQL 9.1.0; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

## Related {#related}

- [`42P21`](../42p21/)
- [`42P16`](../42p16/)

## Sources {#sources}

Source messages, line anchors, and evidence limits are recorded in [authored evidence](../data/evidence/42p22.json).

- `src/backend/access/hash/hashfunc.c:278-281` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/hash/hashfunc.c#L278))
- `src/backend/commands/createas.c:198-203` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/createas.c#L198))
- `src/backend/commands/indexcmds.c:2105-2108` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/indexcmds.c#L2105))
- `src/backend/commands/tablecmds.c:20041-20044` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L20041))
- `src/backend/commands/view.c:76-80` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/view.c#L76))
- `src/backend/regex/regc_pg_locale.c:239-242` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/regex/regc_pg_locale.c#L239))
- `src/backend/utils/adt/like.c:160-163` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/like.c#L160))
- `src/backend/utils/adt/like.c:191-194` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/like.c#L191))
- `src/backend/utils/adt/varchar.c:735-738` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/varchar.c#L735))
- `src/backend/utils/adt/formatting.c:1654-1658` ([fixed source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/formatting.c#L1654))
