文档 / SQL 状态码 / Class 54 程序限制超出
54023 too_many_arguments
ERROR 源码确认 详解 未实测
- 条件名
too_many_arguments- 宏名称
ERRCODE_TOO_MANY_ARGUMENTS- 启用版本
- 7.4
- 状态
- 活跃
版本覆盖
速览
54023 是函数、过程、聚合和返回集合调用的参数数量上限。固定路径保护 catalog 数组、parser 节点和 executor FunctionCallInfo 存储,并按单复数报告编译时实际限制。
含义
固定构建在 pg_config_manual.h 中把 FUNC_MAX_ARGS 定义为 100;源码说明实际可行上限约为 600,修改它需要完整重编 backend(包括 C 函数)。函数定义统计输入参数,明确不统计 output 参数。聚合定义和聚合调用使用 FUNC_MAX_ARGS - 1,为 transition/final function 保留可表示空间。函数/过程 parser 与 executor guard 还覆盖显式参数、默认参数、SRF 和保存的 window expression。调用者和对象类型决定修复。
报文
| 源码路径 | 精确 primary 模板(单数 / 复数) | %d 的计数上限 |
|---|---|---|
pg_proc.c 函数定义 |
functions cannot have more than %d argument / functions cannot have more than %d arguments |
将 parameterCount(input 参数数组长度,不含 output 参数)与 FUNC_MAX_ARGS 比较;%d 传入 FUNC_MAX_ARGS(100) |
functioncmds.c 过程调用 |
cannot pass more than %d argument to a procedure / cannot pass more than %d arguments to a procedure |
将 nargs = list_length(fexpr->args) 与 FUNC_MAX_ARGS 比较;%d 传入 FUNC_MAX_ARGS |
parse_func.c、execExpr.c、execSRF.c、nodeWindowAgg.c 函数/SRF/window 调用 |
cannot pass more than %d argument to a function / cannot pass more than %d arguments to a function |
将 list_length(fargs)、nargs、list_length(sexpr->args) 或 perfuncstate->numArguments 与 FUNC_MAX_ARGS 比较;%d 传入 FUNC_MAX_ARGS |
pg_aggregate.c 聚合定义/调用 |
aggregates cannot have more than %d argument / aggregates cannot have more than %d arguments |
将 numArgs 与 FUNC_MAX_ARGS - 1 比较;%d 传入 99,为 transition/final function 预留槽位 |
这些是 errmsg_plural 分组,客户端应保留服务器的单复数渲染和实际上限,不要只搜索一条手写字符串。
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
functions cannot have more than %d argument
functions cannot have more than %d arguments
cannot pass more than %d argument to a procedure
cannot pass more than %d arguments to a procedure
cannot pass more than %d argument to a function
cannot pass more than %d arguments to a function
cannot pass more than %d argument to a function
cannot pass more than %d arguments to a function
aggregates cannot have more than %d argument
aggregates cannot have more than %d arguments
cannot pass more than %d argument to a function
cannot pass more than %d arguments to a function
诊断
先确认是在 CREATE/定义阶段还是调用阶段,以及对象是函数、过程、聚合、SRF 还是 window aggregate。统计显式参数和 parser 展开的默认参数;聚合使用更严格的 FUNC_MAX_ARGS - 1 边界。保留消息的单复数 primary 与上限,并检查 stored view/plan 是否由不同 FUNC_MAX_ARGS 的二进制建立。
处理
减少参数,把相关值组合为复合/record 类型,或重设计函数边界。修改过程或聚合签名时同步依赖调用者;不要静默丢弃参数、把 output 参数当 input 计数,也不要假设聚合和普通函数共用同一上限。修改 FUNC_MAX_ARGS 是构建级兼容决策,不是会话参数。显式事务中若发生 ERROR,重试前执行 ROLLBACK 或 ROLLBACK TO SAVEPOINT;自动提交只有在定义或调用已改到固定计数以内后才能重试。
版本
锁定目录从 7.4 记录;引用 macro、catalog、parser、executor、aggregate 和 SRF 路径来自 PostgreSQL 18.6,未创建超大签名或调用。
来源
- 上游源码 src/backend/utils/errcodes.txt 第 419 行
- 上游源码 src/backend/catalog/pg_proc.c 第 156 行
- 上游源码 src/backend/commands/functioncmds.c 第 2261 行
- 上游源码 src/backend/executor/execExpr.c 第 2727 行
- 上游源码 src/backend/executor/execSRF.c 第 716 行
- 上游源码 src/include/pg_config_manual.h 第 31 行
- 上游源码 src/backend/catalog/pg_aggregate.c 第 121 行
- 上游源码 src/backend/parser/parse_func.c 第 129 行
- 上游源码 src/backend/executor/nodeWindowAgg.c 第 1042 行
- 核验材料 raw/calls/REL_18_6.jsonl
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
54023 is too_many_arguments in SQLSTATE Class 54.
-
The cited PostgreSQL 18.6 source paths support the representative resource and object-state mechanisms described.
-
FUNC_MAX_ARGS is a compile-time constant of 100 in the fixed PG18.6 header; aggregate definitions/calls use one fewer argument, and parser/executor guards protect calls including stored expressions.
-
The fixed report groups use errmsg_plural with singular and plural format_raw strings and pass FUNC_MAX_ARGS (or FUNC_MAX_ARGS - 1 for aggregates); the scan preserves the macro call rather than only a flattened message.
-
The locked catalogue records 54023 from 7.4; that boundary does not prove exact implementation introduction.
同类 SQL 状态码
| 状态码 | 条件名 | 宏名称 | 严重等级 | 版本 |
|---|---|---|---|---|
| 54000 | program_limit_exceeded | ERRCODE_PROGRAM_LIMIT_EXCEEDED |
ERROR | 7.4 |
| 超出程序固定上限,如数组维度或分配大小。 | 活跃 | |||
| 54001 | statement_too_complex | ERRCODE_STATEMENT_TOO_COMPLEX |
ERROR | 7.4 |
| 语句过于复杂,超出 grouping set 或栈深度上限。 | 活跃 | |||
| 54011 | too_many_columns | ERRCODE_TOO_MANY_COLUMNS |
ERROR | 7.4 |
| 对象定义的列数超过上限,如表属性或索引键。 | 活跃 | |||
| 54023 | too_many_arguments | ERRCODE_TOO_MANY_ARGUMENTS |
ERROR | 7.4 |
| 函数或过程的参数个数超过编译时上限。 | 活跃 | |||