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

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

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

2203C sql_json_object_not_found

ERROR 源码确认 参考 未实测

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

版本覆盖

速览

只接受对象的 JSON 路径访问器或 .keyvalue() 方法收到了非对象项。通配成员访问和对象键值展开使用这个结构检查条件。

报文

代表性首要报文如下:

触发条件 首要报文
通配成员访问器收到非对象 jsonpath wildcard member accessor can only be applied to an object
.keyvalue() 收到非对象 jsonpath item method .%s() can only be applied to an object

报文模板

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

主消息 jsonpath wildcard member accessor can only be applied to an object

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

主消息 jsonpath item method .%s() can only be applied to an object

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

含义

通配成员分支要求 JSON 对象;当 jspIgnoreStructuralErrors 为 true 时,非对象结构不匹配可以被忽略,lax 模式也可能先自动解包数组。.keyvalue() 同样可能先自动解包数组,但随后直接要求对象容器;它的非对象检查通过 RETURN_ERROR 执行,抛错还是返回 jperErrorjspThrowErrors 决定,而该上下文取决于调用方的 silent 或 ON ERROR 处理。lax 本身不会抑制 .keyvalue() 的直接检查。具名成员缺键属于 2203A,只接受数组的访问属于 22039。

诊断

根据首要报文确认是通配访问器还是项方法,再检查当前项类型。区分对象接收项缺少具名键,与标量/数组接收项不能进行对象展开。将 lax 自动解包和结构错误处理纳入判断,不要直接把结果归为成员缺失。

处理

让路径选出对象、规范化输入形状,或在调用只接受对象的操作前显式分支。对通配访问,只有当业务确实要丢弃非对象分支时才使用 lax 结构抑制;对 .keyvalue(),lax 只能先解包数组,剩余的非对象仍按直接的抛错/silent/ON ERROR 路径处理,不要假设 lax 会忽略它。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交可重试修正后的动作。

版本

锁定目录从 12.0 起记录该条件;固定的只接受对象的访问器和 .keyvalue() 检查条件来自 PostgreSQL 18.6。本页未声称有自然运行观察。

来源

证据

断言

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

  • 2203C is sql_json_object_not_found in SQLSTATE Class 22.

    核实方式Read fixed definition.

    来源src/backend/utils/errcodes.txt

  • The wildcard member branch requires an object, can ignore a non-object structural mismatch when jspIgnoreStructuralErrors is true, and may auto-unwrap an array in lax mode. .keyvalue() may auto-unwrap an array first, but its direct non-object guard uses RETURN_ERROR; throwing versus returning jperError follows jspThrowErrors and the caller's silent or ON ERROR context. Lax mode itself does not suppress that direct .keyvalue() guard.

    核实方式Read the complete wildcard-member and keyvalue object-type guards, including array unwrap and structural-error handling.

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

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

  • The locked catalogue records 2203C from 12.0 without proving exact implementation introduction.

    核实方式Use catalogue boundary.

    来源src/backend/utils/errcodes.txt

同类错误代码

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