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

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

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

22039 sql_json_array_not_found

ERROR 源码确认 参考 未实测

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

版本覆盖

速览

只接受数组的 JSON 路径访问器或项方法在没有允许自动包装或结构错误抑制时收到了非数组项。固定的通配数组、索引数组和 .size() 路径分别有数组类型首要报文;越界下标属于 22033。

报文

代表性首要报文如下:

触发条件 首要报文
通配数组访问器收到非数组 jsonpath wildcard array accessor can only be applied to an array
索引数组访问器收到非数组 jsonpath array accessor can only be applied to an array
.size() 在不允许自动包装时收到非数组 jsonpath item method .%s() can only be applied to an array

报文模板

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

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

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

主消息 jsonpath array accessor can only be applied to an array

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

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

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

含义

jpiAnyArray 通配入口、jpiIndexArray 索引入口和 .size() 项方法入口,在 lax 模式启用 jspAutoWrap(cxt) 时都可以把非数组项自动包装。未允许自动包装时,jspIgnoreStructuralErrors 可以抑制结构不匹配;两者都不适用时,相应的只接受数组分支才报告 22039。有效数组却使用越界下标会进入独立的 22033 下标检查条件,因此 22039 不表示空数组或下标越界。

诊断

根据首要报文确认具体访问器或方法,并检查它前一步收到的项。区分标量/对象输入与有效数组的越界索引,同时确认 SQL/JSON 路径模式是否启用了 lax 结构错误处理或自动包装/解包。

处理

让路径选出数组、规范化输入形状,或改用适用于标量的操作。如果文档可能同时出现标量和数组,应显式处理这两种分支,不要依赖结构不匹配变成空结果。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交可重试修正后的动作。

版本

锁定目录从 12.0 起记录该条件;固定的数组访问和 .size() 检查条件来自 PostgreSQL 18.6。本页未声称有自然运行观察。

来源

证据

断言

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

  • 22039 is sql_json_array_not_found in SQLSTATE Class 22.

    核实方式Read fixed definition.

    来源src/backend/utils/errcodes.txt

  • The fixed jpiAnyArray wildcard, jpiIndexArray indexed accessor, and .size() item-method branches can each auto-wrap a non-array item when jspAutoWrap(cxt) is enabled by lax mode. If auto-wrap is not permitted, jspIgnoreStructuralErrors can suppress the structural mismatch; when neither applies, the corresponding array-only branch reports 22039. Array index out-of-bounds is a separate 22033 guard.

    核实方式Read the complete array wildcard/index and size-method guards, including structural-error suppression and the adjacent subscript boundary.

    不覆盖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 22039 from 12.0 without proving exact implementation introduction.

    核实方式Use catalogue boundary.

    来源src/backend/utils/errcodes.txt

同类错误代码

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