SQLSTATE 22025Severity lowLab verified

Incident brief

Invalid LIKE ESCAPE string

The ESCAPE clause of LIKE accepts an empty string or exactly one character; a multi-character escape string raises this data exception.

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
Invalid LIKE ESCAPE string
What triggers it
Write a LIKE ... ESCAPE '<str>' where the escape string is longer than one character.
The fix
Use a single-character escape string, or an empty string to disable escaping.
Proof
Reproduced on PostgreSQL 18.4 → A single SELECT reproduces SQLSTATE 22025; the over-long escape string is rejected with a hint about the allowed length.

The fix

What to do right now

The immediate, application-level response to this error.

  • Use a single-character escape string, or an empty string to disable escaping.
  • If the escape value is dynamic, validate its length before building the LIKE expression.
Fix — SQL
-- ESCAPE takes one character, or '' to disable escaping.
SELECT 'x' LIKE 'x' ESCAPE '';

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