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

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

Wiki / SQLSTATE

2200N — invalid_xml_content

XML 内容无效,未通过 CONTENT 模式解析。

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

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

aliases
未知
class name
Data Exception
condition name
invalid_xml_content
lang
en
sqlstate
2200N

版本定义 PG 18

2200N

速览 {#at-a-glance}

该成员表示 XML 内容无效。PostgreSQL 18.6 的核心 XML 解析器有内容模式的声明 guard 和内容解析 guard,会报告 2200N;原始 XML 选项决定文档解析失败是否改报 2200M。

含义 {#meaning}

本成员表示 CONTENT 边界上的 XML 内容无效。在内容模式中,无效 XML 声明会报告 invalid XML content: invalid XML declaration,DETAIL 由 errdetail_for_xml_code(res_code) 动态生成。平衡内容解析失败会报告 invalid XML content;CONTENT 输入含 DOCTYPE 而被按文档解析时,失败仍依据原始选项选择 2200N。同一个解析调用在原始选项为 DOCUMENT 时使用 2200M。声明分支直接使用 errsave,内容分支使用 xml_errsave;有 ErrorSaveContext 时错误被保存并返回给调用方,普通上下文则抛出 ERROR。这与动态 DETAIL 是两个层次。

报文 {#messages}

引用分支以 ERROR 报告两类 primary:声明 guard 使用 invalid XML content: invalid XML declaration,并附加由 errdetail_for_xml_code(res_code) 生成的动态 DETAIL;后续内容或文档解析失败使用 invalid XML content。声明变体的 evidence 模板是 dynamic errdetail_for_xml_code(res_code),不是固定 DETAIL 文本。不能为这些解析失败虚构一个固定通用 DETAIL 或 HINT。2200L 是外层文档选项包装器,2200S 和 2200T 分别标识注释与处理指令语法。

诊断 {#diagnosis}

阅读完整解析报文和其中指出的 XML 片段或值,检查元素名、字符数据、编码及操作要求的 XML 层级。服务器实际发出 2200L、2200M、2200S 或 2200T 时应直接按对应代码处理;不能只因报文出现“invalid”就选择 2200N。

处理 {#response}

在诊断指出的元素、字符或编码边界修正 XML 内容,并在验证修复时保留实际代码。

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

版本 {#versions}

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

相关 {#related}

2200L、2200S、2200T

来源 {#sources}

核心固定源码:src/backend/utils/adt/xml.c#L1780-1894。共享的 xml_errsave/errsave helper定义软错误与普通抛错的行为。结构化证据记录保留声明和内容解析 guard、动态 detail 边界及范围限制。核心路径依赖 USE_LIBXML;本页未运行自然 XML 案例。

比较版本

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

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "2200N is invalid_xml_content in SQLSTATE Class 22."
}
claims · mechanism.content-parse
{
  "claim_id": "mechanism.content-parse",
  "limits": "The XML declaration path adds a dynamic errdetail_for_xml_code result; do not publish a fabricated fixed DETAIL.",
  "method": "Read both content-mode branches.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.xml-invalid-content",
    "src.path.xml-content-parse"
  ],
  "statement": "The core XML parser uses 2200N for failed content parsing and for an invalid XML declaration in content mode."
}
claims · mechanism.error-save
{
  "claim_id": "mechanism.error-save",
  "limits": "The soft-error propagation distinction is separate from the dynamic DETAIL produced for XML declaration failures.",
  "method": "Read the declaration/content calls and the xml_errsave helper.",
  "position": 2,
  "runtime": [],
  "sources": [],
  "statement": "The XML declaration branch calls errsave and the content branches call xml_errsave; with an ErrorSaveContext these errors are saved and returned to the caller, while an ordinary context throws ERROR."
}
claims · build-boundary
{
  "claim_id": "build-boundary",
  "limits": "Source confirmation is not a natural runtime observation.",
  "method": "Read surrounding fixed source guards.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.path.xml-content-parse"
  ],
  "statement": "Core XML content parsing is compiled under the USE_LIBXML feature guard; build support and parser version affect availability and detail text."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 4,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 2200N from 8.3.0 without proving an exact implementation introduction date."
}
messages · message.invalid-content
{
  "limits": "",
  "message_id": "message.invalid-content",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.invalid-content",
    "primary_template": "invalid XML content",
    "severity_source": "ERROR",
    "sources": [
      "src.path.xml-content-parse"
    ],
    "sqlstate": "2200N"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.xml-content-parse"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "invalid XML content",
      "position": 0,
      "role": "",
      "template": "invalid XML content"
    }
  ]
}
messages · message.invalid-declaration
{
  "limits": "",
  "message_id": "message.invalid-declaration",
  "path": "",
  "position": 1,
  "raw": {
    "detail_template": "dynamic errdetail_for_xml_code(res_code)",
    "id": "message.invalid-declaration",
    "primary_template": "invalid XML content: invalid XML declaration",
    "severity_source": "ERROR",
    "sources": [
      "src.path.xml-invalid-content"
    ],
    "sqlstate": "2200N"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.xml-invalid-content"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "invalid XML content: invalid XML declaration",
      "position": 0,
      "role": "",
      "template": "invalid XML content: invalid XML declaration"
    },
    {
      "kind": "detail",
      "literal": "dynamic errdetail_for_xml_code(res_code)",
      "position": 1,
      "role": "",
      "template": "dynamic errdetail_for_xml_code(res_code)"
    }
  ]
}
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#L212"
}
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-content
{
  "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-content",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L1801-L1810"
}
sources · src.path.xml-content-parse
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/xml.c",
  "position": 3,
  "sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
  "source_id": "src.path.xml-content-parse",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L1851-L1894"
}
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"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:b7dd82b3579b0f5634b813729ad1b80fa1eda6c19f8690386ff7e5247e7b06a9

正文语言: zh-Hans · english-manuals:b7dd82b3579b0f5634b813729ad1b80fa1eda6c19f8690386ff7e5247e7b06a9