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

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

Wiki / SQLSTATE

22033 — invalid_sql_json_subscript

SQL/JSON 数组下标无效,如越界或非数值。

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

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

aliases
未知
class name
Data Exception
condition name
invalid_sql_json_subscript
lang
en
sqlstate
22033

版本定义 PG 18

22033

速览 {#at-a-glance}

SQL/JSON 数组下标无效。固定 jsonpath 路径区分越界、非单一数值和整数范围变体。

报文 {#messages}

固定下标守卫使用以下首要文本:

| 守卫 | 首要文本 | | --- | --- | | 下标不是单个数值项 | jsonpath array subscript is not a single numeric value | | 数值下标超出 int32 | jsonpath array subscript is out of integer range | | strict 数组边界失败 | jsonpath array subscript is out of bounds |

含义 {#meaning}

jsonpath 执行器把每个下标表达式求值为结果列表。getArrayIndex 要求结果恰好是一个数值标量,将其截断为整数;结果不是单个数值项或无法符合整数范围时报告 22033。随后数组边界守卫在 strict 模式下对负起点、反向范围或超过数组上界的终点报告同一码。lax 模式会忽略这种结构性越界错误,并把范围限制到现有数组;它不会把非数值或溢出的下标变成有效下标。

诊断 {#diagnosis}

先检查下标表达式的基数和类型,再检查数组长度。表达式返回多个项、非数值或整数溢出时使用转换报文;数值下标或范围违反 strict 数组边界时使用越界报文。记录 path 是 strict 还是 lax,因为 lax 的结构处理可能产生空结果或被限制的结果,而不是 ERROR。后续 SQL/JSON 操作若选择对无项抛错,则属于 22035。

处理 {#response}

使下标表达式返回整数范围内的单个有限数值,并在 strict 模式下保持目标数组边界内且范围不反向。如果有意使用 lax 的限制或空结果,应确认 path 模式和外层 SQL/JSON 行为确实表达了该意图。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交可重试修正后的表达式。

版本 {#versions}

锁定目录从 12.0 起记录该条件;本页固定 jsonpath 源码路径为 PostgreSQL 18.6。未声称本页有自然运行观察。

相关 {#related}

22034、22035

来源 {#sources}

数组边界处理见 src/backend/utils/adt/jsonpath_exec.c#L892-929。下标基数、截断和整数转换见 #L3442-3477。结构化证据记录保留三个 22033 守卫角色;本页未运行自然案例。

比较版本

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

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "22033 is invalid_sql_json_subscript in SQLSTATE Class 22."
}
claims · resolved-path
{
  "claim_id": "resolved-path",
  "limits": "Source confirmation is not a natural runtime observation.",
  "method": "Read the complete array-subscript execution and getArrayIndex conversion guards.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.jsonpath.subscript"
  ],
  "statement": "The fixed jsonpath executor evaluates each subscript to one numeric item, truncates it to int32, and raises 22033 for a non-single numeric result or integer-range overflow; strict mode also raises for invalid array bounds, while lax mode ignores structural out-of-bounds errors and clamps the range."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 22033 from 12.0 without proving exact implementation introduction."
}
messages · message.0
{
  "limits": "",
  "message_id": "message.0",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.0",
    "primary_template": "jsonpath array subscript is out of bounds",
    "severity_source": "ERROR",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "22033"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "jsonpath array subscript is out of bounds",
      "position": 0,
      "role": "",
      "template": "jsonpath array subscript is out of bounds"
    }
  ]
}
messages · message.non-single-numeric
{
  "limits": "",
  "message_id": "message.non-single-numeric",
  "path": "",
  "position": 1,
  "raw": {
    "id": "message.non-single-numeric",
    "primary_template": "jsonpath array subscript is not a single numeric value",
    "severity_source": "ERROR",
    "sources": [
      "src.jsonpath.subscript"
    ],
    "sqlstate": "22033"
  },
  "severity": "ERROR",
  "sources": [
    "src.jsonpath.subscript"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "jsonpath array subscript is not a single numeric value",
      "position": 0,
      "role": "",
      "template": "jsonpath array subscript is not a single numeric value"
    }
  ]
}
messages · message.integer-range
{
  "limits": "",
  "message_id": "message.integer-range",
  "path": "",
  "position": 2,
  "raw": {
    "id": "message.integer-range",
    "primary_template": "jsonpath array subscript is out of integer range",
    "severity_source": "ERROR",
    "sources": [
      "src.jsonpath.subscript"
    ],
    "sqlstate": "22033"
  },
  "severity": "ERROR",
  "sources": [
    "src.jsonpath.subscript"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "jsonpath array subscript is out of integer range",
      "position": 0,
      "role": "",
      "template": "jsonpath array subscript is out of integer range"
    }
  ]
}
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#L218"
}
sources · src.path.0
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/jsonpath_exec.c",
  "position": 1,
  "sha256": "678cb8947f0b5e6ad14524f1863987ab99641cfb5f81121fc5c5006af0319d02",
  "source_id": "src.path.0",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/jsonpath_exec.c#L919"
}
sources · src.jsonpath.subscript
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/jsonpath_exec.c",
  "position": 2,
  "sha256": "678cb8947f0b5e6ad14524f1863987ab99641cfb5f81121fc5c5006af0319d02",
  "source_id": "src.jsonpath.subscript",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/jsonpath_exec.c#L3442"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:62345a52ad8568970803b546a99bd80246940387fcce56bc7097f29d9aa6e7e2

正文语言: zh-Hans · english-manuals:62345a52ad8568970803b546a99bd80246940387fcce56bc7097f29d9aa6e7e2