选择 打开 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 错误代码 / Class 22 数据异常

2200N invalid_xml_content

ERROR 源码确认 参考 未实测

类别
Class 22 数据异常
严重等级
ERROR
条件名
invalid_xml_content
宏名称
ERRCODE_INVALID_XML_CONTENT
启用版本
8.3
状态
活跃

版本覆盖

速览

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

含义

本成员表示 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 是两个层次。

报文

引用分支以 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 分别标识注释与处理指令语法。

报文模板

源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。

主消息 invalid XML content

来源:src/backend/utils/adt/xml.c @ REL_18_6

主消息 invalid XML content: invalid XML declaration
DETAIL dynamic errdetail_for_xml_code(res_code)

来源:src/backend/utils/adt/xml.c @ REL_18_6

诊断

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

处理

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

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

版本

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

来源

证据

断言

每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。

  • 2200N is invalid_xml_content in SQLSTATE Class 22.

    核实方式Read fixed definition.

    来源src/backend/utils/errcodes.txt

  • The core XML parser uses 2200N for failed content parsing and for an invalid XML declaration in content mode.

    核实方式Read both content-mode branches.

    不覆盖The XML declaration path adds a dynamic errdetail_for_xml_code result; do not publish a fabricated fixed DETAIL.

    来源src/backend/utils/adt/xml.c · src/backend/utils/adt/xml.c

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

    核实方式Read the declaration/content calls and the xml_errsave helper.

    不覆盖The soft-error propagation distinction is separate from the dynamic DETAIL produced for XML declaration failures.

  • Core XML content parsing is compiled under the USE_LIBXML feature guard; build support and parser version affect availability and detail text.

    核实方式Read surrounding fixed source guards.

    不覆盖Source confirmation is not a natural runtime observation.

    来源src/backend/utils/adt/xml.c

  • The locked catalogue records 2200N from 8.3.0 without proving an exact implementation introduction date.

    核实方式Use catalogue boundary.

    来源src/backend/utils/errcodes.txt

同类错误代码

Class 22 数据异常 下的其他成员。