选择 打开 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

文档 / SQL 状态码 / Class 54 程序限制超出

54023 too_many_arguments

ERROR 源码确认 详解 未实测

类别
Class 54 程序限制超出
严重等级
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.cexecExpr.cexecSRF.cnodeWindowAgg.c 函数/SRF/window 调用 cannot pass more than %d argument to a function / cannot pass more than %d arguments to a function list_length(fargs)nargslist_length(sexpr->args)perfuncstate->numArgumentsFUNC_MAX_ARGS 比较;%d 传入 FUNC_MAX_ARGS
pg_aggregate.c 聚合定义/调用 aggregates cannot have more than %d argument / aggregates cannot have more than %d arguments numArgsFUNC_MAX_ARGS - 1 比较;%d 传入 99,为 transition/final function 预留槽位

这些是 errmsg_plural 分组,客户端应保留服务器的单复数渲染和实际上限,不要只搜索一条手写字符串。

报文模板

源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。

主消息 · singular functions cannot have more than %d argument
主消息 · plural functions cannot have more than %d arguments

来源:src/backend/catalog/pg_proc.c @ REL_18_6

主消息 · singular cannot pass more than %d argument to a procedure
主消息 · plural cannot pass more than %d arguments to a procedure

来源:src/backend/commands/functioncmds.c @ REL_18_6

主消息 · singular cannot pass more than %d argument to a function
主消息 · plural cannot pass more than %d arguments to a function

来源:src/backend/executor/execExpr.c @ REL_18_6

主消息 · singular cannot pass more than %d argument to a function
主消息 · plural cannot pass more than %d arguments to a function

来源:src/backend/executor/execSRF.c @ REL_18_6

主消息 · singular aggregates cannot have more than %d argument
主消息 · plural aggregates cannot have more than %d arguments

来源:src/backend/catalog/pg_aggregate.c @ REL_18_6

主消息 · singular cannot pass more than %d argument to a function
主消息 · plural cannot pass more than %d arguments to a function

来源:src/backend/executor/nodeWindowAgg.c @ REL_18_6

诊断

先确认是在 CREATE/定义阶段还是调用阶段,以及对象是函数、过程、聚合、SRF 还是 window aggregate。统计显式参数和 parser 展开的默认参数;聚合使用更严格的 FUNC_MAX_ARGS - 1 边界。保留消息的单复数 primary 与上限,并检查 stored view/plan 是否由不同 FUNC_MAX_ARGS 的二进制建立。

处理

减少参数,把相关值组合为复合/record 类型,或重设计函数边界。修改过程或聚合签名时同步依赖调用者;不要静默丢弃参数、把 output 参数当 input 计数,也不要假设聚合和普通函数共用同一上限。修改 FUNC_MAX_ARGS 是构建级兼容决策,不是会话参数。显式事务中若发生 ERROR,重试前执行 ROLLBACKROLLBACK TO SAVEPOINT;自动提交只有在定义或调用已改到固定计数以内后才能重试。

版本

锁定目录从 7.4 记录;引用 macro、catalog、parser、executor、aggregate 和 SRF 路径来自 PostgreSQL 18.6,未创建超大签名或调用。

来源

证据

断言

每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。

同类 SQL 状态码

状态码 条件名 宏名称 严重等级 版本
Class 54 程序限制超出 Program Limit Exceeded 4 个
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
函数或过程的参数个数超过编译时上限。 活跃