Skip to content

22019 — invalid_escape_character

Source-backed reference for PostgreSQL SQLSTATE 22019.

At a glance

An operation rejected its escape argument. The fixed catalogue defines invalid_escape_character, but the bounded PostgreSQL 18.6 source scan found no native emitter to which one message or severity can safely be attached.

Field Value
SQLSTATE 22019
Condition invalid_escape_character
Status active
Known present by 7.4
Locked snapshots 9.0.23, 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_INVALID_ESCAPE_CHARACTER
Aliases

Meaning

The relevant rule belongs to the consumer of ESCAPE. PostgreSQL’s LIKE and SIMILAR documentation permits a one-character escape, allows ESCAPE '' to disable escaping, and distinguishes that behavior from the SQL standard’s zero-length rule. Another consumer may require one character, reject a character class, or apply its own empty-string rule. Therefore 22019 cannot be explained by one universal length or character check without an emitting path.

Diagnosis

Identify the consumer and read its complete diagnostic before changing the value. Check the escape expression’s resolved type and character length, whether the value is an empty string, and whether the chosen character has a special meaning in that pattern language. Keep SQL string-literal quoting separate from pattern escaping, and distinguish this bounded definition from 2200C SIMILAR separator syntax and 2200D invalid octets.

Response

Use the consumer’s documented escape representation: a valid single character where that consumer requires one, or the explicitly supported empty string (ESCAPE ‘’) where it disables escaping. Re-encode the SQL literal as needed, then validate the same consumer; do not apply a LIKE rule to an unrelated parser.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The exact implementation introduction date and native emitter remain unresolved by this bounded review.

2200C, 2200D

Sources

  • The fixed definition is confirmed in errcodes.txt; no occurrence of ERRCODE_INVALID_ESCAPE_CHARACTER was resolved in the bounded PostgreSQL 18.6 source scan.
  • Same-tag pattern-matching documentation documents LIKE’s one-character/default/empty escape behavior, and #L5724-L5830 documents the corresponding SIMILAR rules. These are consumer rules, not a claimed 22019 emitter.

Runtime verification is not_run; this page does not assert a primary template, severity, or transaction effect. The structured evidence record retains the definition, documentation scope, and bounded-emitter limitation.