文档 / SQL 状态码 / Class 38 外部例程异常
38000 external_routine_exception
ERROR 源码确认 参考 未实测
- 条件名
external_routine_exception- 宏名称
ERRCODE_EXTERNAL_ROUTINE_EXCEPTION- 启用版本
- 7.4
- 状态
- 活跃
版本覆盖
速览
SQLSTATE 38000 是外部例程异常类别。固定的 PostgreSQL 18.6 路径覆盖外部命令、UUID 库和 PL 语言处理器;这些实现必须按各自边界分别诊断。
含义
代表性消息包括 program "%s" failed 和 shell command "%s" failed,二者都带内部 wait-status detail;UUID 路径还会报告 OSSP uuid library failure: %s、OSSP uuid library failure: error code %d、uuid library failure: %d 或 UUID 版本不匹配;PL/Perl 有 didn't get a return item from function 等报文,PL/Python 会转发带可选 detail/context/hint 的 %s,PL/Tcl 则有 could not parse function return value: %s 或带上下文的 %s。应保留动态字段和实际产生者;这个类别没有一条固定消息。
消息
代表性消息包括 program "%s" failed 和 shell command "%s" failed,二者都带内部 wait-status detail;UUID 路径还会报告 OSSP uuid library failure: %s、OSSP uuid library failure: error code %d、uuid library failure: %d 或 UUID 版本不匹配;PL/Perl 有 didn't get a return item from function 等报文,PL/Python 会转发带可选 detail/context/hint 的 %s,PL/Tcl 则有 could not parse function return value: %s 或带上下文的 %s。应保留动态字段和实际产生者;这个类别没有一条固定消息。
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
shell command "%s" failed
%s
来源:contrib/basebackup_to_shell/basebackup_to_shell.c @ REL_18_6
适用范围:The command and internal wait-status detail are dynamic.
program "%s" failed
%s
来源:src/backend/commands/copyfrom.c @ REL_18_6 · src/backend/commands/copyto.c @ REL_18_6
适用范围:The program path and internal wait-status detail are dynamic.
OSSP uuid library failure: %s
来源:contrib/uuid-ossp/uuid-ossp.c @ REL_18_6
适用范围:The external UUID library text is interpolated into the primary message.
OSSP uuid library failure: error code %d
来源:contrib/uuid-ossp/uuid-ossp.c @ REL_18_6
适用范围:The external UUID status code is dynamic.
uuid library failure: %d
来源:contrib/uuid-ossp/uuid-ossp.c @ REL_18_6
适用范围:The UUID library status value is dynamic; this branch is used by the uuid-ossp fallback path.
uuid_create() produced a version %c UUID instead of the expected version 1
来源:contrib/uuid-ossp/uuid-ossp.c @ REL_18_6
适用范围:The UUID version character is dynamic.
didn't get a return item from function
来源:src/pl/plpython/plpy_elog.c @ REL_18_6
适用范围:PL/Python forwards the underlying dynamic message and optional DETAIL, CONTEXT, and HINT; no single static primary template is asserted.
could not parse function return value: %s
来源:src/pl/tcl/pltcl.c @ REL_18_6
适用范围:The parse error text is dynamic.
%s
%s
in PL/Tcl function %s
来源:src/pl/tcl/pltcl.c @ REL_18_6
适用范围:Both error text and function name are dynamic.
诊断
根据消息和 context 确认外部边界:程序路径及等待结果、UUID 库操作,还是 PL 语言和例程。检查相关服务器配置和处理器日志,保留动态 %s 值及内部 detail。
处理
修复消息点名的外部命令、库或语言例程,并独立验证该边界。外部动作失败时可能已经产生副作用;在确认完成状态和幂等性前不要重放。
版本
锁定目录将该条件的已知下界记为 PostgreSQL 7.4;事实块列出已发布快照,源码路径状态仅限于下方固定的 PostgreSQL 18.6 资料。
来源
- 上游源码 src/backend/utils/errcodes.txt 第 300 行
- 上游源码 contrib/basebackup_to_shell/basebackup_to_shell.c 第 239 行
- 上游源码 src/backend/commands/copyfrom.c 第 1966 行
- 上游源码 contrib/uuid-ossp/uuid-ossp.c 第 387 行
- 上游源码 src/pl/plpython/plpy_elog.c 第 123 行
- 上游源码 src/backend/commands/copyto.c 第 575 行
- 上游源码 src/pl/plperl/plperl.c 第 2250 行
- 上游源码 src/pl/tcl/pltcl.c 第 1036 行
- 核验材料 raw/calls/REL_18_6.jsonl
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
38000 is external_routine_exception in SQLSTATE Class 38.
-
The fixed PostgreSQL 18.6 source contains the external-command, UUID-library, and PL/Perl, PL/Python, PL/Tcl report contexts and message variants described on the page.
-
Locked release definitions establish catalogue presence from 7.4; they do not establish a precise introducing release or runtime use.
同类 SQL 状态码
| 状态码 | 条件名 | 宏名称 | 严重等级 | 版本 |
|---|---|---|---|---|
| 38000 | external_routine_exception | ERRCODE_EXTERNAL_ROUTINE_EXCEPTION |
ERROR | 7.4 |
| 外部例程异常的类别码,覆盖外部命令与 PL 处理器。 | 活跃 | |||
| 38001 | containing_sql_not_permitted | ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED |
ERROR | 7.4 |
| 外部例程不允许包含 SQL 语句。 | 活跃 | |||
| 38002 | modifying_sql_data_not_permitted | ERRCODE_E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED |
ERROR | 7.4 |
| 外部例程不允许修改 SQL 数据,区别于 2F002。 | 活跃 | |||
| 38003 | prohibited_sql_statement_attempted | ERRCODE_E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED |
ERROR | 7.4 |
| 外部例程中尝试执行被禁止的 SQL 语句。 | 活跃 | |||
| 38004 | reading_sql_data_not_permitted | ERRCODE_E_R_E_READING_SQL_DATA_NOT_PERMITTED |
ERROR | 7.4 |
| 外部例程不允许读取 SQL 数据。 | 活跃 | |||