↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / SQLSTATE

2200L — not_an_xml_document

输入不满足 XML DOCUMENT 形式要求。

英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。

当前阅读 PG 18·选择有来源记录的版本

aliases
未知
class name
Data Exception
condition name
not_an_xml_document
lang
en
sqlstate
2200L

版本定义 PG 18

2200L

速览 {#at-a-glance}

SQL/XML 的 SQLSERIALIZE DOCUMENT 操作收到的输入无法满足所要求的文档形式。PostgreSQL 18.6 会把这个公开的 DOCUMENT 路径映射到带有 XMLOPTION_DOCUMENT 的 xmltotext_with_options;失败或软错误会被映射为 not an XML document。包装器对非 DOCUMENT 且不缩进的提前绕过不属于 CONTENT 模式的 2200L 结论,本页也不涵盖所有 XML 内容或注释违规。

含义 {#meaning}

本成员是公开 SQL/XML SQLSERIALIZE DOCUMENT 形式的文档级 XML 失败。该操作把 XMLOPTION_DOCUMENT 传给 xmltotext_with_options;后者用 ErrorSaveContext 调用 xml_parse,没有返回文档或保存的解析错误被设置时,就释放部分文档并报告 2200L。它的提前 guard 会在非 DOCUMENT 且不缩进时直接返回二进制兼容的输入,因此不能把这个映射推广到 CONTENT。较低层的 xml_parse 另有 2200M/2200N 分支,因此不能把本码理解为所有解析器错误的同义词。

报文 {#messages}

SQLSERIALIZE DOCUMENT 包装器以 ERROR 严重性报告 primary:not an XML document。引用分支没有独立 DETAIL 或 HINT;解析器的具体上下文须以实际运行报文和构建为准。

诊断 {#diagnosis}

保留完整上下文和传给 SQLSERIALIZE 的表达式。先确认操作要求的是 DOCUMENT 还是 CONTENT,再检查文档边界、顶层结构和编码。2200L 诊断只绑定上述 DOCUMENT 映射;不要从 CONTENT 请求推断本码,也不要把成员码 2200M/N/S/T 与本码的文档级条件混为一谈。

处理 {#response}

按解析器指出的位置修正文档边界和结构,同时保留调用方要求“文档”还是“片段”的语义要求。

该分支抛出 ERROR 时,显式事务应先用 ROLLBACK 恢复,或对语句前已建立的保存点执行 ROLLBACK TO SAVEPOINT,再重试;自动提交下只在失败语句结束后重试修正后的动作。事务边界规则见事务与重试指南。

版本 {#versions}

锁定目录从 8.3.0 起记录该条件;固定源码覆盖 PostgreSQL 18.6。

相关 {#related}

2200M、2200N、2200S、2200T

来源 {#sources}

固定源码:src/backend/utils/adt/xml.c#L669-697。结构化证据记录保留文档选项 guard、报文和范围边界。源码确认了包装器映射;具体输入和可能的 libxml2 上下文取决于运行时。本页未运行自然 XML 案例。

比较版本

SQLSTATE 证据与已记录的运行版本

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "2200L is not_an_xml_document in SQLSTATE Class 22."
}
claims · mechanism.xml-document-option
{
  "claim_id": "mechanism.xml-document-option",
  "limits": "The wrapper returns binary-compatible input for non-DOCUMENT/no-indent before this check, so this evidence does not generalize the 2200L mapping to CONTENT; it is distinct from the 2200M invalid-document branch in xml_parse and from content/subconstruct errors.",
  "method": "Read xml.c XML option mapping.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.xml-document-option"
  ],
  "statement": "The public SQLSERIALIZE DOCUMENT operation reaches xmltotext_with_options with XMLOPTION_DOCUMENT; when xml parsing fails or records a soft error, the wrapper maps that document conformance failure to 2200L with primary not an XML document."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 2200L from 8.3.0 without proving an exact implementation introduction date."
}
messages · message.xml-document-option
{
  "limits": "",
  "message_id": "message.xml-document-option",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.xml-document-option",
    "primary_template": "not an XML document",
    "severity_source": "ERROR",
    "sources": [
      "src.path.xml-document-option"
    ],
    "sqlstate": "2200L"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.xml-document-option"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "not an XML document",
      "position": 0,
      "role": "",
      "template": "not an 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#L210"
}
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-document-option
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/xml.c",
  "position": 2,
  "sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
  "source_id": "src.path.xml-document-option",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L669-L697"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:60da6ac1b79ae99649dc75108beff9a0982f5ab42b3183ab743aedc48b874c78

正文语言: zh-Hans · english-manuals:60da6ac1b79ae99649dc75108beff9a0982f5ab42b3183ab743aedc48b874c78