↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

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

百科 / SQL 状态码 / Class 09 触发动作异常

09000 triggered_action_exception

ERROR 源码确认 参考 未实测

类别
Class 09 触发动作异常
严重等级
ERROR
条件名
triggered_action_exception
宏名称
ERRCODE_TRIGGERED_ACTION_EXCEPTION
最早已知存在
7.4
状态
有效

版本覆盖

版本条依据已采样构建显示;灰色版本可能尚未采样,悬停可查看。手册链接随版本选择,源码和运行证据保持原核验构建。

速览

SQLSTATE 09000 是 ERROR 级别的触发动作条件。在固定的 PostgreSQL 18.6 扫描中,已确认的报告路径位于 contrib/spi 触发器函数:它们检查触发器参数、目标列类型、被引用元组以及 SPI 返回码。因此该代码与这些已安装的触发器函数及其表/触发器配置有关,不能把它当成所有触发器失败的统称。

含义

已确认的路径包括 autoinc.c、insert_username.c、moddatetime.c 和 refint.c。消息变体包括 "%s" has no attribute "%s"、attribute "%s" of "%s" must be type INT4、... TEXT 以及 ... TIMESTAMP or TIMESTAMPTZ。参照完整性路径还会报告 tuple references non-existent key,并带有 Trigger "%s" found tuple referencing non-existent key in "%s". detail;SPI 失败可报告 SPI_execp returned %d,RESTRICT 动作还可报告 "%s": tuple is referenced in "%s"。这些模板中的关系、参数、属性、触发器和返回码来自具体失败路径。

消息

固定变体包括 "%s" has no attribute "%s"、attribute "%s" of "%s" must be type INT4、TEXT 或 TIMESTAMP or TIMESTAMPTZ。参照完整性路径还会报告 tuple references non-existent key,并带有 Trigger "%s" found tuple referencing non-existent key in "%s". detail;SPI 失败可报告 SPI_execp returned %d,RESTRICT 动作还可报告 "%s": tuple is referenced in "%s"。这些模板中的关系、参数、属性、触发器和返回码来自具体失败路径。

报文模板

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

主消息 "%s" has no attribute "%s"

来源: 来源:contrib/spi/autoinc.c @ REL_18_6

适用范围:Relation and attribute names are dynamic.

主消息 attribute "%s" of "%s" must be type INT4

来源: 来源:contrib/spi/autoinc.c @ REL_18_6

适用范围:Attribute and relation names are dynamic.

主消息 "%s" has no attribute "%s"

来源: 来源:contrib/spi/insert_username.c @ REL_18_6

适用范围:Relation and attribute names are dynamic.

主消息 attribute "%s" of "%s" must be type TEXT

来源: 来源:contrib/spi/insert_username.c @ REL_18_6

适用范围:Attribute and relation names are dynamic.

主消息 "%s" has no attribute "%s"

来源: 来源:contrib/spi/moddatetime.c @ REL_18_6

适用范围:Relation and attribute names are dynamic.

主消息 attribute "%s" of "%s" must be type TIMESTAMP or TIMESTAMPTZ

来源: 来源:contrib/spi/moddatetime.c @ REL_18_6

适用范围:Attribute and relation names are dynamic.

主消息 tuple references non-existent key
DETAIL Trigger "%s" found tuple referencing non-existent key in "%s".

来源: 来源:contrib/spi/refint.c @ REL_18_6

适用范围:Trigger and relation names in DETAIL are dynamic.

主消息 SPI_execp returned %d

来源: 来源:contrib/spi/refint.c @ REL_18_6

适用范围:The SPI status code is dynamic.

主消息 "%s": tuple is referenced in "%s"

来源: 来源:contrib/spi/refint.c @ REL_18_6

适用范围:Referencing relation names are dynamic; this is the restrictive action path.

诊断

先确认已安装的触发器函数和操作阶段,再把关系及触发器参数与该函数的文档契约对照。出现属性/类型消息时检查所点名的列及其类型;出现 refint 变体时检查触发器名、被引用关系以及元组或键的关系。出现 SPI_execp returned %d 时保留返回码,并检查返回该码的 SPI 调用。固定扫描没有证明所有 09000 报告都使用同一条消息。

处理

根据消息修正触发器定义、参数列表、列类型、被引用键或 SPI 侧失败原因,确认修改后再执行触发操作。不要盲目重放写入来修复它:触发器可能已经在报错前完成部分工作,正确恢复边界取决于外层事务。若函数来自扩展或本地代码,应先检查该实现及其版本,再决定应用层的重试行为。

版本

锁定目录将该条件的已知下界记为 PostgreSQL 7.4。事实块列出已发布快照;源码路径状态仅限于下方固定的 PostgreSQL 18.6 资料。

来源

证据

断言

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

同类 SQL 状态码

状态码 条件名 宏名称 严重等级 版本
Class 09 触发动作异常 Triggered Action Exception 1 个 ↗
09000 triggered_action_exception ERRCODE_TRIGGERED_ACTION_EXCEPTION ERROR 7.4 起已知
触发器动作异常,多见于 contrib/spi 触发器。 有效