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

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

Wiki / SQLSTATE

2201F — invalid_argument_for_power_function

幂运算参数使实数结果无定义。

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

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

aliases
未知
class name
Data Exception
condition name
invalid_argument_for_power_function
lang
en
sqlstate
2201F

版本定义 PG 18

2201F

速览 {#at-a-glance}

幂函数会拒绝实数结果未定义的操作数。固定 numeric 路径报告 zero raised to a negative power is undefined 或 a negative number raised to a non-integer power yields a complex result。

含义 {#meaning}

2201F 覆盖两个不同的幂运算守卫:零底数配负指数,以及负底数配非整数指数。普通有限 numeric 路径和特殊值路径都存在相应检查。按 POSIX 规则,numeric 的 NaN 可能返回 NaN 或 1,若干无穷组合也有定义结果;负底数配整数指数并不自动触发本码。

诊断 {#diagnosis}

检查解析后的底数、指数类型和首要报文。非整数小数指数与负整数指数不是同一种情况,改小数位数或无关 cast 不能修复定义域。特殊值要单独判断,不要把所有 NaN 或无穷值都当成无效幂运算。

处理 {#response}

选择具有预期实数结果的底数/指数,或明确改变业务规则。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交客户端可直接重试修正后的操作。

版本 {#versions}

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

相关 {#related}

2201E、22003

来源 {#sources}

有限值和特殊值守卫位于 src/backend/utils/adt/numeric.c#L4045-4111 和 #L4208-4220;负底数非整数守卫在 #L11373-11384。结构化证据记录保留确切报文角色;本页未运行自然案例。

比较版本

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

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read the fixed errcodes row and macro.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "2201F is invalid_argument_for_power_function in SQLSTATE Class 22"
}
claims · resolved-path
{
  "claim_id": "resolved-path",
  "limits": "Source confirmation is not a natural runtime observation.",
  "method": "Read complete source contexts for the representative guards.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.numeric.power.special",
    "src.numeric.power.finite",
    "src.numeric.power.negative"
  ],
  "statement": "Fixed PostgreSQL 18.6 numeric power paths bind zero-negative-exponent and negative-base-non-integral guards, including finite and special-value branches."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue presence and history boundaries.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 2201F from 8.0.0 without proving an exact implementation introduction date."
}
messages · message.zero-negative-power
{
  "limits": "",
  "message_id": "message.zero-negative-power",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.zero-negative-power",
    "primary_template": "zero raised to a negative power is undefined",
    "severity_source": "ERROR",
    "sources": [
      "src.numeric.power.special",
      "src.numeric.power.finite"
    ],
    "sqlstate": "2201F"
  },
  "severity": "ERROR",
  "sources": [
    "src.numeric.power.special",
    "src.numeric.power.finite"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "zero raised to a negative power is undefined",
      "position": 0,
      "role": "",
      "template": "zero raised to a negative power is undefined"
    }
  ]
}
messages · message.negative-noninteger
{
  "limits": "",
  "message_id": "message.negative-noninteger",
  "path": "",
  "position": 1,
  "raw": {
    "id": "message.negative-noninteger",
    "primary_template": "a negative number raised to a non-integer power yields a complex result",
    "severity_source": "ERROR",
    "sources": [
      "src.numeric.power.special",
      "src.numeric.power.negative"
    ],
    "sqlstate": "2201F"
  },
  "severity": "ERROR",
  "sources": [
    "src.numeric.power.special",
    "src.numeric.power.negative"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "a negative number raised to a non-integer power yields a complex result",
      "position": 0,
      "role": "",
      "template": "a negative number raised to a non-integer power yields a complex result"
    }
  ]
}
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#L176"
}
sources · src.numeric.power.special
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/numeric.c",
  "position": 1,
  "sha256": "6cde7cd60b3330b83be35d1f014045f5fb5fe737f3c5db4c8ed4080b99f2b666",
  "source_id": "src.numeric.power.special",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/numeric.c#L4045"
}
sources · src.numeric.power.finite
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/numeric.c",
  "position": 2,
  "sha256": "6cde7cd60b3330b83be35d1f014045f5fb5fe737f3c5db4c8ed4080b99f2b666",
  "source_id": "src.numeric.power.finite",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/numeric.c#L4208"
}
sources · src.numeric.power.negative
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/numeric.c",
  "position": 3,
  "sha256": "6cde7cd60b3330b83be35d1f014045f5fb5fe737f3c5db4c8ed4080b99f2b666",
  "source_id": "src.numeric.power.negative",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/numeric.c#L11373"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:bf55f545f859f0e96010b2a8a1683bf09f2b9a84c9955e3bf2b27eab73499c23

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