# 2200C — invalid_use_of_escape_character

> Source-backed reference for PostgreSQL SQLSTATE 2200C.
---

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

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| Field | Value |
| --- | --- |
| SQLSTATE | `2200C` |
| Condition | `invalid_use_of_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_USE_OF_ESCAPE_CHARACTER` |
| Aliases | `—` |

<!-- source facts: data/errcodes/2200C.json -->
<!-- END SQLSTATE FACTS -->

## 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](../guides/) for this boundary rule.

## Versions {#versions}
The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6.

## Related {#related}
[`2200D`](../2200d/), [`22000`](../22000/)

## Sources {#sources}
Fixed source: [`src/backend/utils/adt/regexp.c#L758-951`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/regexp.c#L758-L951). The structured [evidence record](../data/evidence/2200c.json) 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.
