select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 22 · DATA EXCEPTION

invalid_escape_character

SQLSTATE
22019
Condition name
invalid_escape_character
Class
Data Exception
Source macro
ERRCODE_INVALID_ESCAPE_CHARACTER
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

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.

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.

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.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

22019 is invalid_escape_character in SQLSTATE Class 22.

Method: Read the fixed errcodes row and macro.

src.errcodes.18.6

Same-tag LIKE and SIMILAR documentation describes one-character escapes, the default backslash, and PostgreSQL's ESCAPE empty-string behavior; it does not identify a 22019 emitter.

Method: Read the same-tag pattern-matching documentation.

Limits: Other consumers may impose different escape rules.

src.docs-pattern-escape.18.6

The bounded PostgreSQL 18.6 source scan found no resolved native occurrence of ERRCODE_INVALID_ESCAPE_CHARACTER, so no primary or severity is attached.

Method: Keep consumer documentation separate from an unresolved emitter search.

Limits: This is not a claim that no external wrapper can report the condition.

src.errcodes.18.6

The locked catalogue records 22019 from 7.4 without proving an exact implementation introduction date.

Method: Use catalogue presence and history boundaries.

src.errcodes.18.6

Message templates

No extracted message template is attached to this condition.

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Definition snapshot: english-manuals:0fb3c7fbb77e86aa311101b9f97… · English manual source