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

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

Wiki / SQLSTATE

25000 — 事务状态无效(invalid_transaction_state)

事务状态无效的类别码,多见于内部状态检查。

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

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

aliases
未知
class name
Invalid Transaction State
condition name
invalid_transaction_state
lang
en
sqlstate
25000

版本定义 PG 18

25000 — 事务状态无效

速览 {#at-a-glance}

25000 是 Class 25 的宽泛“事务状态无效”。锁定的 18.6 源码把它用于并行操作中执行 utility、创建保存点等内部状态;本批不声称有安全的普通 SQL 复现。

含义 {#meaning}

事务状态不能简单等同于“存在一个事务”。25001 表示活动事务阻止命令,25P02 表示失败事务;18.6 调用扫描还显示堆、事务、utility、GUC 和保存点路径中的并行操作保护。

诊断 {#diagnosis}

先区分失败事务、活动事务块限制和并行操作状态,保留服务器原始 SQLSTATE 与报文。内部并行路径需要日志和上下文,不能把普通“事务已打开”误认成 25000。

处理 {#response}

遵循命令的事务/并行契约;可恢复的客户端状态按精确回滚或重试边界处理。不要用 RAISE 制造自然结果。

源码报文模板 {#messages}

  • parallel-savepoint:primary cannot define savepoints during a parallel operation(ERROR)
  • parallel-utility:primary cannot execute %s during a parallel operation(ERROR)

适用边界 {#case}

本批没有为 25000 构造自然 SQL 触发器;请把它视为源码/协议边界,而不是可直接复制的复现脚本。结构化证据 · 案例导出。

作者证据 ID:identity, core-paths, boundary。选定运行记录:—。

版本与边界 {#versions}

锁定目录在 7.4 已观察到该条件,并在列出的正式快照中均存在。18.6 源码扫描确认了本文引用的并行操作路径;由于所需内部状态不是安全的独立 SQL 前置条件,本文没有运行案例。

相关 {#related}

对比 25001 活动 SQL 事务、25P02 失败 SQL 事务 和 40001 序列化失败。

来源 {#sources}

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.xact.18.6 (SHA-256 75b012c0b047d1dc905a30975c244beec366e45eac0dbf109fd21bcd611a8e39)
  • src.utility.18.6 (SHA-256 7aae5d07628b6debf8456d1d4ea96f28912232192e56ea25773b4c4b61235a00)

比较版本

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

claims · identity
{
  "claim_id": "identity",
  "limits": "It is a family-level state; active transactions, failed transactions, and parallel-operation restrictions have separate codes.",
  "method": "Read the fixed condition row and macro.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "25000 is invalid_transaction_state, the broad Class 25 condition."
}
claims · core-paths
{
  "claim_id": "core-paths",
  "limits": "These guards depend on executor/parallel-worker state that a normal safe SQL session cannot establish directly.",
  "method": "Trace the fixed report groups and exact messages.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.xact.18.6",
    "src.utility.18.6",
    "src.calls.REL_18_6"
  ],
  "statement": "The locked PostgreSQL 18.6 source uses 25000 for internal parallel-operation guards such as defining savepoints or executing a utility during parallel operation."
}
claims · boundary
{
  "claim_id": "boundary",
  "limits": "Extensions or future code can add paths; this is a core 18.6 source boundary, not a universal impossibility theorem.",
  "method": "Compare the class mapping and exhaustive resolved-call scan.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6",
    "src.calls.REL_18_6"
  ],
  "statement": "The batch does not claim a natural SQL reproduction for 25000. Use 25001 for an active transaction blocking a utility and 25P02 for a failed transaction; do not replace this boundary with RAISE."
}
messages · parallel-savepoint
{
  "limits": "The template is guarded by internal parallel-operation state and is not a user-facing active-transaction diagnostic.",
  "message_id": "parallel-savepoint",
  "path": "",
  "position": 0,
  "raw": {
    "id": "parallel-savepoint",
    "limits": "The template is guarded by internal parallel-operation state and is not a user-facing active-transaction diagnostic.",
    "primary_template": "cannot define savepoints during a parallel operation",
    "severity_source": "ERROR",
    "sources": [
      "src.xact.18.6"
    ],
    "sqlstate": "25000"
  },
  "severity": "ERROR",
  "sources": [
    "src.xact.18.6"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "cannot define savepoints during a parallel operation",
      "position": 0,
      "role": "",
      "template": "cannot define savepoints during a parallel operation"
    }
  ]
}
messages · parallel-utility
{
  "limits": "The %s substitution is the utility command name.",
  "message_id": "parallel-utility",
  "path": "",
  "position": 1,
  "raw": {
    "id": "parallel-utility",
    "limits": "The %s substitution is the utility command name.",
    "primary_template": "cannot execute %s during a parallel operation",
    "severity_source": "ERROR",
    "sources": [
      "src.utility.18.6"
    ],
    "sqlstate": "25000"
  },
  "severity": "ERROR",
  "sources": [
    "src.utility.18.6"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "cannot execute during a parallel operation",
      "position": 0,
      "role": "",
      "template": "cannot execute %s during a parallel operation"
    }
  ]
}
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"
}
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.xact.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/access/transam/xact.c",
  "position": 2,
  "sha256": "75b012c0b047d1dc905a30975c244beec366e45eac0dbf109fd21bcd611a8e39",
  "source_id": "src.xact.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/transam/xact.c#L4385-L4387"
}
sources · src.utility.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/tcop/utility.c",
  "position": 3,
  "sha256": "7aae5d07628b6debf8456d1d4ea96f28912232192e56ea25773b4c4b61235a00",
  "source_id": "src.utility.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/utility.c#L425-L429"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:f9b97bb0346150f358b73e8571c822745aa76db203a34416cc24eed79e2b9be0

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