↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / SQLSTATE

22019 — invalid_escape_character

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

English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

aliases
Unknown
class name
Data Exception
condition name
invalid_escape_character
lang
en
sqlstate
22019

Definition PG 18

At a glance {#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 {#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 {#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 {#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 {#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.

Related {#related}

2200C, 2200D

Sources {#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.

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read the fixed errcodes row and macro.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "22019 is invalid_escape_character in SQLSTATE Class 22."
}
claims · consumer-rules
{
  "claim_id": "consumer-rules",
  "limits": "Other consumers may impose different escape rules.",
  "method": "Read the same-tag pattern-matching documentation.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.docs-pattern-escape.18.6"
  ],
  "statement": "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."
}
claims · bounded-source-scope
{
  "claim_id": "bounded-source-scope",
  "limits": "This is not a claim that no external wrapper can report the condition.",
  "method": "Keep consumer documentation separate from an unresolved emitter search.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The bounded PostgreSQL 18.6 source scan found no resolved native occurrence of ERRCODE_INVALID_ESCAPE_CHARACTER, so no primary or severity is attached."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue presence and history boundaries.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 22019 from 7.4 without proving an exact implementation introduction date."
}
sources · src.errcodes.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L189"
}
sources · src.docs-pattern-escape.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "doc/src/sgml/func.sgml",
  "position": 1,
  "sha256": "05d03f505dc3c3b4fb2b3a6e8ed3275c425306a8ff20dd9548e838c26bbb968a",
  "source_id": "src.docs-pattern-escape.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/func.sgml#L5551-L5830"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:d748388f3c4cb7b54418476c49edaa844eeb2e3b930dbe76baaaa99b51cec55e

Text language: en · english-manuals:d748388f3c4cb7b54418476c49edaa844eeb2e3b930dbe76baaaa99b51cec55e