2200M — invalid_xml_document
XML 文档解析失败,文档无效。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Data Exception
- condition name
- invalid_xml_document
- lang
- en
- sqlstate
- 2200M
版本定义 PG 18
2200M
速览 {#at-a-glance}
该目录成员表示 XML 文档无效。PostgreSQL 18.6 的核心 xml_parse 文档分支会报告 invalid XML document,而 contrib/xml2 的 XSLT 路径在源文档或样式表解析失败时也使用同一 SQLSTATE。这些发出点不同于 2200L 的文档选项包装器。
含义 {#meaning}
本成员来自具体的文档解析 guard,表示 XML 文档无效。在核心 xml_parse 中,xmlCtxtReadDoc 解析失败且原始 XML 选项为 DOCUMENT 时报告 2200M;原始选项为 CONTENT 时,同一解析失败报告 2200N。独立的 contrib/xml2 函数在把输入文档或样式表作为 XML 解析失败时使用 2200M。核心 xml_errsave 会把这些结果交给 errsave:传入 ErrorSaveContext 时保存错误并正常返回,普通上下文则抛出错误;这条软错误路径不同于 contrib/xml2 直接抛出 ERROR 的分支。
报文 {#messages}
核心分支以 ERROR 报告 primary:invalid XML document。contrib/xml2 分支以 ERROR 报告 primary:error parsing XML document 或 error parsing stylesheet as XML document。引用分支没有固定 DETAIL 或 HINT 模板;libxml2 上下文可能动态附加。不要把这些报文替换成 2200L 的 not an XML document。
诊断 {#diagnosis}
结合实际 SQLSTATE、message、detail 和 context,区分文档级失败与内容(2200N)、注释(2200S)或处理指令(2200T)错误。检查产生报文的是核心 xml_parse 还是 contrib/xml2,再修正报文指向的文档或样式表。本页已确认这些源码发出路径,但未运行自然案例。
处理 {#response}
根据实际报文和解析器上下文修正无效文档;未确认实际 SQLSTATE 前不要套用 2200L 的处理。
该分支抛出 ERROR 时,显式事务应先用 ROLLBACK 恢复,或对语句前已建立的保存点执行 ROLLBACK TO SAVEPOINT,再重试;自动提交下只在失败语句结束后重试修正后的动作。事务边界规则见事务与重试指南。
版本 {#versions}
锁定目录从 8.3.0 起记录该条件;固定源码覆盖 PostgreSQL 18.6。
相关 {#related}
来源 {#sources}
核心固定源码:src/backend/utils/adt/xml.c#L1780-1862。独立的 contrib/xml2/xslt_proc.c#L84-100 路径解析 XML 文档和样式表。共享的 xml_errsave/errsave helper定义软错误与普通抛错的行为。结构化证据记录保留两个发出点、报文角色和范围边界。核心路径依赖 USE_LIBXML;本页未运行自然 XML 案例。
比较版本
SQLSTATE 证据与已记录的运行版本
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read fixed definition.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "2200M is invalid_xml_document in SQLSTATE Class 22."
}claims · mechanism.core-xml
{
"claim_id": "mechanism.core-xml",
"limits": "The dynamic libxml diagnostic may be attached separately; no single static DETAIL template should be invented.",
"method": "Read the document parse failure branch.",
"position": 1,
"runtime": [],
"sources": [
"src.path.xml-invalid-document"
],
"statement": "The core xml_parse document branch maps a failed libxml document parse to 2200M with primary invalid XML document."
}claims · mechanism.error-save
{
"claim_id": "mechanism.error-save",
"limits": "This source distinction describes error propagation; it is not a natural runtime observation.",
"method": "Read the xml_errsave comment and errsave call.",
"position": 2,
"runtime": [],
"sources": [],
"statement": "The core xml_errsave helper passes XML errors to errsave: an ErrorSaveContext stores the error and returns, while an ordinary context throws; this soft-error path is distinct from the direct ERROR branches in contrib/xml2."
}claims · mechanism.xml2
{
"claim_id": "mechanism.xml2",
"limits": "This path requires the xml2 extension and is separate from core XML constructors.",
"method": "Read the complete xml2 error branch.",
"position": 3,
"runtime": [],
"sources": [
"src.path.xml2-document"
],
"statement": "The contrib/xml2 XSLT path also reports invalid XML document when its parser reports an error."
}claims · build-boundary
{
"claim_id": "build-boundary",
"limits": "Source confirmation is not a natural runtime observation.",
"method": "Read surrounding fixed source guards.",
"position": 4,
"runtime": [],
"sources": [
"src.path.xml-invalid-document"
],
"statement": "Core XML branches are compiled under the USE_LIBXML feature guard; availability depends on the server build."
}claims · history
{
"claim_id": "history",
"limits": "",
"method": "Use catalogue boundary.",
"position": 5,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "The locked catalogue records 2200M from 8.3.0 without proving an exact implementation introduction date."
}messages · message.core-document
{
"limits": "",
"message_id": "message.core-document",
"path": "",
"position": 0,
"raw": {
"id": "message.core-document",
"primary_template": "invalid XML document",
"severity_source": "ERROR",
"sources": [
"src.path.xml-invalid-document"
],
"sqlstate": "2200M"
},
"severity": "ERROR",
"sources": [
"src.path.xml-invalid-document"
],
"templates": [
{
"kind": "primary",
"literal": "invalid XML document",
"position": 0,
"role": "",
"template": "invalid XML document"
}
]
}messages · message.xml2-document
{
"limits": "",
"message_id": "message.xml2-document",
"path": "",
"position": 1,
"raw": {
"id": "message.xml2-document",
"primary_template": "error parsing XML document",
"severity_source": "ERROR",
"sources": [
"src.path.xml2-document"
],
"sqlstate": "2200M"
},
"severity": "ERROR",
"sources": [
"src.path.xml2-document"
],
"templates": [
{
"kind": "primary",
"literal": "error parsing XML document",
"position": 0,
"role": "",
"template": "error parsing XML document"
}
]
}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#L211"
}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.xml-invalid-document
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/xml.c",
"position": 2,
"sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
"source_id": "src.path.xml-invalid-document",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L1846-L1862"
}sources · src.path.xml2-document
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "contrib/xml2/xslt_proc.c",
"position": 3,
"sha256": "a5a76f59e851175955dfa62477fd4a7d7be3fb69b37e7a7e955ab76c8e01d0ae",
"source_id": "src.path.xml2-document",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/xml2/xslt_proc.c#L84-L100"
}sources · src.path.xml-error-save
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/xml.c",
"position": 4,
"sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
"source_id": "src.path.xml-error-save",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L2047-L2082"
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:5cf75ff3965b358c66a63b051df95fd3c7e7158d843a7e3c1a8b12d418ac641b
正文语言: zh-Hans · english-manuals:5cf75ff3965b358c66a63b051df95fd3c7e7158d843a7e3c1a8b12d418ac641b