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

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

Wiki / SQLSTATE

22P01 — floating_point_exception

浮点异常,进程收到 SIGFPE 信号。

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

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

aliases
未知
class name
Data Exception
condition name
floating_point_exception
lang
en
sqlstate
22P01

版本定义 PG 18

22P01

速览 {#at-a-glance}

固定核心代码路径中的 FloatExceptionHandler 被注册为 SIGFPE 处理器。它以 ERROR 严重性发出主消息 floating-point exception,详细信息说明收到无效浮点操作信号,可能是结果越界或除零等无效操作。

含义 {#meaning}

src/backend/tcop/postgres.c 中的 FloatExceptionHandler(SIGNAL_ARGS) 把信号转成 ereport(ERROR);PostgresMain 为 SIGFPE 安装该处理器。这是浮点信号路径,不能据此说所有除法或数值越界都使用 22P01。精确数值除零和数值范围检查通常分别使用自己的 22012 和 22003 条件。

诊断 {#diagnosis}

保留完整 ErrorResponse 和服务器日志上下文,包括语句位置以及可用的 routine/context 字段。检查操作数类型和表达式路径,区分硬件或浮点无效操作与使用 22012 或 22003 的精确数值运算。固定处理器的详细信息是诊断说明,不证明具体一定是除零。

报文 {#messages}

  • ERROR 主消息:floating-point exception
  • DETAIL:An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.

处理 {#response}

修正算术或输入范围;如果需要改变数值域,要在运算前明确转换。显式事务中,ERROR 会使事务进入中止状态,重试前执行 ROLLBACK 或 ROLLBACK TO SAVEPOINT;自动提交模式下先修正表达式或数据再重新提交。引用路径是 ERROR 而非 FATAL,普通客户端后端不会仅因该条件就需要重置连接。

版本 {#versions}

锁定目录从 PostgreSQL 7.4 记录此条件。本页引用的处理器和 SIGFPE 注册来自 PostgreSQL 18.6 REL_18_6;目录边界不能证明当前消息的精确引入版本。

相关 {#related}

22012、22003、22023

来源 {#sources}

src/backend/tcop/postgres.c#L3072-L3082

src/backend/tcop/postgres.c#L4245-L4249

结构化证据记录保存精确主消息/详细信息、严重性和源码/运行边界;本次没有诱发信号。

比较版本

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

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "22P01 is floating_point_exception in SQLSTATE Class 22."
}
claims · signal-handler
{
  "claim_id": "signal-handler",
  "limits": "The source confirms the handler and message; it does not show a natural SIGFPE runtime in this review.",
  "method": "Read the complete handler and the PostgresMain SIGFPE registration.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.handler",
    "src.path.registration"
  ],
  "statement": "FloatExceptionHandler is the backend SIGFPE handler. It emits ERROR 22P01 with primary floating-point exception and detail about an invalid floating-point operation, an out-of-range result, or an invalid operation such as division by zero."
}
claims · numeric-boundary
{
  "claim_id": "numeric-boundary",
  "limits": "Related-code distinctions are diagnostic guidance, not a claim that every arithmetic operator chooses one code.",
  "method": "Compare the fixed handler with the condition-specific source boundary named in the page.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.path.handler"
  ],
  "statement": "The handler is distinct from type-specific exact-numeric errors such as division-by-zero 22012 and numeric range 22003."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 22P01 from 7.4; that boundary does not prove exact implementation introduction."
}
messages · message.handler
{
  "limits": "",
  "message_id": "message.handler",
  "path": "",
  "position": 0,
  "raw": {
    "detail_template": "An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.",
    "id": "message.handler",
    "primary_template": "floating-point exception",
    "severity_source": "ERROR",
    "sources": [
      "src.path.handler"
    ],
    "sqlstate": "22P01"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.handler"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "floating-point exception",
      "position": 0,
      "role": "",
      "template": "floating-point exception"
    },
    {
      "kind": "detail",
      "literal": "An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.",
      "position": 1,
      "role": "",
      "template": "An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero."
    }
  ]
}
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#L205"
}
sources · src.path.handler
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/tcop/postgres.c",
  "position": 1,
  "sha256": "9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061",
  "source_id": "src.path.handler",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L3072"
}
sources · src.path.registration
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/tcop/postgres.c",
  "position": 2,
  "sha256": "9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061",
  "source_id": "src.path.registration",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L4245"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:62b1c359279374e7925be6589a21b880d0df14a26afca0407fab3cccb796fd41

正文语言: zh-Hans · english-manuals:62b1c359279374e7925be6589a21b880d0df14a26afca0407fab3cccb796fd41