22014 — invalid_argument_for_ntile_function
ntile 的桶数量必须大于零。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Data Exception
- condition name
- invalid_argument_for_ntile_function
- lang
- en
- sqlstate
- 22014
版本定义 PG 18
速览 {#at-a-glance}
ntile 收到非正的桶数量。固定窗口函数路径以 SQLSTATE 22014 报告 argument of ntile must be greater than zero。
含义 {#meaning}
当 context->ntile 仍为零、尚未成功初始化时,window_ntile 才会计算桶参数。参数为 NULL 时先返回 NULL,也不会设置这个状态,因此后续行可能再次计算参数;小于等于零时抛出 22014,正数则初始化状态并在后续行复用。空输入没有可供窗口函数计算的行,不属于这个错误。
诊断 {#diagnosis}
检查受影响分区中 ntile 参数的解析值,区分三种情况:正数、NULL 和非正数。对实际求值的行,NULL 参数会给出 NULL;空分区则完全没有结果。二者都不应归为非正参数错误。
处理 {#response}
检查提供参数的表达式后传入正整数桶数量。只有桶策略本来就允许时,才使用 COALESCE 或其他回退值。固定 guard 抛出 ERROR;显式事务需先回滚或回到已有保存点再重试,自动提交只重试修正后的语句。
报文 {#messages}
- Primary,
ERROR:argument of ntile must be greater than zero。 - 固定 guard 没有附加 DETAIL 或 HINT。
版本 {#versions}
锁定目录从 8.4.0 起记录该条件;固定源码覆盖 PostgreSQL 18.6。引用的是窗口函数实现,不是一般参数校验器。
相关 {#related}
来源 {#sources}
src/backend/utils/adt/windowfuncs.c#L411-L475 展示分区行数、NULL 提前返回、正数 guard 和桶计算。运行核验为 not_run;上述源码证据不是运行观察。结构化证据记录保留 primary 和范围。
比较版本
SQLSTATE 证据与已记录的运行版本
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read the fixed errcodes row and macro.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "22014 is invalid_argument_for_ntile_function in SQLSTATE Class 22."
}claims · resolved-path
{
"claim_id": "resolved-path",
"limits": "An empty input has no window-function row to evaluate.",
"method": "Read the complete window_ntile initialization, NULL, guard, and distribution path.",
"position": 1,
"runtime": [],
"sources": [
"src.ntile.18.6"
],
"statement": "When ntile state is still uninitialized, the function evaluates the bucket argument; NULL returns before initialization, non-positive raises 22014, and a positive count initializes and is reused for later rows."
}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 22014 from 8.4.0 without proving an exact implementation introduction date."
}messages · message.nonpositive-buckets
{
"limits": "",
"message_id": "message.nonpositive-buckets",
"path": "",
"position": 0,
"raw": {
"id": "message.nonpositive-buckets",
"primary_template": "argument of ntile must be greater than zero",
"severity_source": "ERROR",
"sources": [
"src.ntile.18.6"
],
"sqlstate": "22014"
},
"severity": "ERROR",
"sources": [
"src.ntile.18.6"
],
"templates": [
{
"kind": "primary",
"literal": "argument of ntile must be greater than zero",
"position": 0,
"role": "",
"template": "argument of ntile must be greater than 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#L184"
}sources · src.ntile.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/windowfuncs.c",
"position": 1,
"sha256": "49214f9325dcdd73728d08574b0b6843e90822a18bdaf6b0d49139b1eaae6b63",
"source_id": "src.ntile.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/windowfuncs.c#L411-475"
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:1d02a301edae7422387809250c4b141b3b301bcdd6b26136f86614db3de85d5a
正文语言: zh-Hans · english-manuals:1d02a301edae7422387809250c4b141b3b301bcdd6b26136f86614db3de85d5a