2200C — invalid_use_of_escape_character
转义字符用法无效,如 SIMILAR TO 模式错误。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Data Exception
- condition name
- invalid_use_of_escape_character
- lang
- en
- sqlstate
- 2200C
版本定义 PG 18
2200C
速览 {#at-a-glance}
检查完整报文和实际 SQL SIMILAR TO 模式;18.6 的 regexp.c 路径会在翻译阶段报告 SQL regular expression may not contain more than two escape-double-quote separators。这里针对的是 SQL 到 POSIX 正则的翻译语法,不是一般 POSIX 反斜杠转义。
含义 {#meaning}
本条件属于数据异常族,表示 PostgreSQL 将 SQL SIMILAR TO 模式翻译为 POSIX 正则形式时拒绝了转义结构。similar_escape_internal 在方括号表达式之外把带转义的双引号视为 SQL SUBSTRING 三段之间的分隔符;第三个分隔符会被拒绝。同一 helper 也服务于 SIMILAR TO 翻译,在普通匹配中这些分隔符不改变匹配行为。
报文 {#messages}
已确认的 guard 以 ERROR 严重性报告 primary:SQL regular expression may not contain more than two escape-double-quote separators;该分支没有独立 DETAIL 或 HINT。无效 ESCAPE 字符串属于其他 SQLSTATE 路径,应保留实际报文和代码。
诊断 {#diagnosis}
这是解析器和输入的问题,应分别检查 SQL 字符串层、SIMILAR TO 模式和 ESCAPE 字符。统计方括号表达式之外的转义双引号分隔符,并确认操作是 SIMILAR TO 还是 SUBSTRING ... SIMILAR;不能把正则中的每个反斜杠都诊断为 2200C。
处理 {#response}
按预期的 SIMILAR TO/SUBSTRING 语义修正 SQL 模式或 ESCAPE 表示,确认分隔符数量后再执行;不要无条件增删 POSIX 反斜杠。
该分支抛出 ERROR 时,显式事务应先用 ROLLBACK 恢复,或对语句前已建立的保存点执行 ROLLBACK TO SAVEPOINT,再重试;自动提交下只在失败语句结束后重试修正后的动作。事务边界规则见事务与重试指南。
版本 {#versions}
锁定目录从 7.4 起记录该条件;固定源码覆盖 PostgreSQL 18.6。
相关 {#related}
来源 {#sources}
固定源码:src/backend/utils/adt/regexp.c#L758-951。结构化证据记录保留定义、消息和范围边界。该路径是 PostgreSQL 的 SQL SIMILAR TO 翻译 helper;本页未运行自然案例。其他转义失败应按实际 SQLSTATE 和报文判断。
比较版本
SQLSTATE 证据与已记录的运行版本
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"
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:85928dc2d27eb4b55d6b98a33fb47d9f52348a57338ec40d126e3d73d7a98dcf
正文语言: zh-Hans · english-manuals:85928dc2d27eb4b55d6b98a33fb47d9f52348a57338ec40d126e3d73d7a98dcf