2200C — invalid_use_of_escape_character
The SQL SIMILAR TO pattern translator rejected its escape-double-quote structure before matching. PostgreSQL 18.6 has a concrete regexp.c path that raises SQL regular expression may not contain more than two escape-double-quote separators; this is about the SQL-to-POSIX translation syntax, not generic POSIX backslash escaping.
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_use_of_escape_character
- lang
- en
- sqlstate
- 2200C
Definition PG 18
2200C
At a glance {#at-a-glance}
The SQL SIMILAR TO pattern translator rejected its escape-double-quote structure before matching. PostgreSQL 18.6 has a concrete regexp.c path that raises SQL regular expression may not contain more than two escape-double-quote separators; this is about the SQL-to-POSIX translation syntax, not generic POSIX backslash escaping.
Meaning {#meaning}
This condition belongs to the data-exception family for an escape form rejected while PostgreSQL translates a SQL SIMILAR TO pattern to its POSIX regular-expression form. In similar_escape_internal, an escaped double quote outside a bracket expression separates the three SQL SUBSTRING parts; the third separator is rejected. The same helper is used by the SQL SIMILAR TO translation path, where those separators do not change ordinary match behavior.
Messages {#messages}
The confirmed guard raises ERROR with primary SQL regular expression may not contain more than two escape-double-quote separators; this branch has no separate DETAIL or HINT. An invalid ESCAPE string is a different SQLSTATE path, so preserve the actual message and code.
Diagnosis {#diagnosis}
This is a parser/input problem, so inspect the SQL string layer, the SIMILAR TO pattern, and its ESCAPE character separately. Count escaped double-quote separators outside bracket expressions and confirm whether the operation is SIMILAR TO or SUBSTRING ... SIMILAR; do not diagnose every backslash in a POSIX regexp as 2200C.
Response {#response}
Correct the SQL pattern or its ESCAPE representation according to the intended SIMILAR TO/SUBSTRING semantics, then re-run after checking the separator count. Do not add or remove POSIX backslashes indiscriminately.
When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.
Versions {#versions}
The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6.
Related {#related}
Sources {#sources}
Fixed source: src/backend/utils/adt/regexp.c#L758-951. The structured evidence record retains the definition, message, and scope boundaries. This is PostgreSQL’s SQL SIMILAR TO translation helper; no natural runtime was run for this page. A different escape failure may use another SQLSTATE, so choose by the actual code and message.
Compare versions
SQLSTATE evidence and recorded runtime versions
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read fixed definition.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "2200C is invalid_use_of_escape_character in SQLSTATE Class 22."
}claims · mechanism.regexp-separators
{
"claim_id": "mechanism.regexp-separators",
"limits": "The rule concerns this escape-double-quote syntax, not every backslash in a regex.",
"method": "Read the afterescape/nquotes guard and surrounding parser context.",
"position": 1,
"runtime": [],
"sources": [
"src.path.regexp-escape"
],
"statement": "The SQL SIMILAR TO translation helper similar_escape_internal treats an escaped double quote outside a bracket as a separator for the SQL SUBSTRING pattern parts; the third such separator raises 2200C. This is not a generic POSIX regular-expression backslash rule."
}claims · history
{
"claim_id": "history",
"limits": "",
"method": "Use catalogue boundary.",
"position": 2,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "The locked catalogue records 2200C from 7.4 without proving an exact implementation introduction date."
}messages · message.regexp
{
"limits": "",
"message_id": "message.regexp",
"path": "",
"position": 0,
"raw": {
"id": "message.regexp",
"primary_template": "SQL regular expression may not contain more than two escape-double-quote separators",
"severity_source": "ERROR",
"sources": [
"src.path.regexp-escape"
],
"sqlstate": "2200C"
},
"severity": "ERROR",
"sources": [
"src.path.regexp-escape"
],
"templates": [
{
"kind": "primary",
"literal": "SQL regular expression may not contain more than two escape-double-quote separators",
"position": 0,
"role": "",
"template": "SQL regular expression may not contain more than two escape-double-quote separators"
}
]
}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#L193"
}sources · src.calls.REL_18_6
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 1,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6",
"tag": "",
"url": ""
}sources · src.path.regexp-escape
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/regexp.c",
"position": 2,
"sha256": "8c54fe9e937ce03111b39da7bca89b22d6cb2de6b9ce5f7caf90c76bc7218e0e",
"source_id": "src.path.regexp-escape",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/regexp.c#L758-L951"
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:85928dc2d27eb4b55d6b98a33fb47d9f52348a57338ec40d126e3d73d7a98dcf
Text language: en · english-manuals:85928dc2d27eb4b55d6b98a33fb47d9f52348a57338ec40d126e3d73d7a98dcf