2201G — invalid_argument_for_width_bucket_function
width_bucket 参数无效,如桶数非正。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Data Exception
- condition name
- invalid_argument_for_width_bucket_function
- lang
- en
- sqlstate
- 2201G
版本定义 PG 18
2201G
速览 {#at-a-glance}
width_bucket 会校验 bucket 数、NaN 输入、直方图边界和边界相等情况。固定 numeric 与 float8 路径分别报告 count 非正、NaN、边界非有限和上下界相等这四类 2201G 报文。
代表性报文 {#messages}
固定守卫使用以下首要文本:
| 守卫 | 首要文本 |
| --- | --- |
| 非正 count | count must be greater than zero |
| operand 或边界含 NaN | operand, lower bound, and upper bound cannot be NaN |
| 边界非有限 | lower and upper bounds must be finite |
| 边界相等 | lower bound cannot equal upper bound |
含义 {#meaning}
对于 numeric 和 float8 的 width_bucket(operand, bound1, bound2, count) 签名,count 必须大于零;operand 或任一边界不能是 NaN;两个边界都必须有限且不能相等。实现同时支持递增和递减边界,operand 为无穷值也允许,只有无穷边界被拒绝。合法端点计算若使 count + 1 溢出,源码报告的是另一个 22003。
诊断 {#diagnosis}
按函数签名和确切首要报文定位参数。区分 count、NaN 与无穷值,并区分 operand 和两个边界。不要强行要求下界小于上界:递减边界有独立的合法计算路径;只有相等边界是本码明确拒绝的排序关系。
处理 {#response}
在保留预期桶方向的前提下修正指定的 count、operand 或边界。使用正 count、有限且不相等的边界;若结果超出范围,应按独立的 22003 处理。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交可重试修正后的调用。
版本 {#versions}
锁定目录从 8.0.0 起记录该条件;本页固定源码路径为 PostgreSQL 18.6。未声称本页有自然运行观察。
相关 {#related}
来源 {#sources}
完整代表守卫位于 src/backend/utils/adt/numeric.c#L1959-2045 和 src/backend/utils/adt/float.c#L4060-4180。结构化证据记录保留四个首要模板与源码范围;本页未运行自然案例。
比较版本
SQLSTATE 证据与已记录的运行版本
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read the fixed errcodes row and macro.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "2201G is invalid_argument_for_width_bucket_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.width_bucket",
"src.float.width_bucket"
],
"statement": "Fixed PostgreSQL 18.6 numeric and float8 width_bucket paths bind count, NaN, finite-bound, unequal-bound, ascending, descending, and operand-infinity behavior."
}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 2201G from 8.0.0 without proving an exact implementation introduction date."
}claims · neighbor-22003
{
"claim_id": "neighbor-22003",
"limits": "",
"method": "Read the result conversion/overflow branch, not the 2201G guards.",
"position": 3,
"runtime": [],
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"statement": "Valid endpoint arithmetic can raise the distinct 22003 integer-out-of-range condition when count plus one exceeds int4."
}messages · message.count
{
"limits": "",
"message_id": "message.count",
"path": "",
"position": 0,
"raw": {
"id": "message.count",
"primary_template": "count must be greater than zero",
"severity_source": "ERROR",
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"sqlstate": "2201G"
},
"severity": "ERROR",
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"templates": [
{
"kind": "primary",
"literal": "count must be greater than zero",
"position": 0,
"role": "",
"template": "count must be greater than zero"
}
]
}messages · message.nan
{
"limits": "",
"message_id": "message.nan",
"path": "",
"position": 1,
"raw": {
"id": "message.nan",
"primary_template": "operand, lower bound, and upper bound cannot be NaN",
"severity_source": "ERROR",
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"sqlstate": "2201G"
},
"severity": "ERROR",
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"templates": [
{
"kind": "primary",
"literal": "operand, lower bound, and upper bound cannot be NaN",
"position": 0,
"role": "",
"template": "operand, lower bound, and upper bound cannot be NaN"
}
]
}messages · message.bounds-finite
{
"limits": "",
"message_id": "message.bounds-finite",
"path": "",
"position": 2,
"raw": {
"id": "message.bounds-finite",
"primary_template": "lower and upper bounds must be finite",
"severity_source": "ERROR",
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"sqlstate": "2201G"
},
"severity": "ERROR",
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"templates": [
{
"kind": "primary",
"literal": "lower and upper bounds must be finite",
"position": 0,
"role": "",
"template": "lower and upper bounds must be finite"
}
]
}messages · message.bounds-equal
{
"limits": "",
"message_id": "message.bounds-equal",
"path": "",
"position": 3,
"raw": {
"id": "message.bounds-equal",
"primary_template": "lower bound cannot equal upper bound",
"severity_source": "ERROR",
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"sqlstate": "2201G"
},
"severity": "ERROR",
"sources": [
"src.numeric.width_bucket",
"src.float.width_bucket"
],
"templates": [
{
"kind": "primary",
"literal": "lower bound cannot equal upper bound",
"position": 0,
"role": "",
"template": "lower bound cannot equal upper bound"
}
]
}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#L177"
}sources · src.numeric.width_bucket
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/numeric.c",
"position": 1,
"sha256": "6cde7cd60b3330b83be35d1f014045f5fb5fe737f3c5db4c8ed4080b99f2b666",
"source_id": "src.numeric.width_bucket",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/numeric.c#L1959"
}sources · src.float.width_bucket
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/float.c",
"position": 2,
"sha256": "58914ae93c06c281e581a4bb2dcf2280e4ae1619f3ceb8f801f50beca87eecd8",
"source_id": "src.float.width_bucket",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/float.c#L4060"
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:2fd7be36d15c6a7373c5bcec215a281b135b1a478b5cf7eeeca00bb15ec428ee
正文语言: zh-Hans · english-manuals:2fd7be36d15c6a7373c5bcec215a281b135b1a478b5cf7eeeca00bb15ec428ee