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

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.cinsert_username.cmoddatetime.crefint.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 %dRESTRICT 动作还可报告 "%s": tuple is referenced in "%s"。这些模板中的关系、参数、属性、触发器和返回码来自具体失败路径。

消息

固定变体包括 "%s" has no attribute "%s"attribute "%s" of "%s" must be type INT4TEXTTIMESTAMP or TIMESTAMPTZ。参照完整性路径还会报告 tuple references non-existent key,并带有 Trigger "%s" found tuple referencing non-existent key in "%s". detail;SPI 失败可报告 SPI_execp returned %dRESTRICT 动作还可报告 "%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 资料。

来源

证据

断言

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

  • 09000 is triggered_action_exception in SQLSTATE Class 09.

    核实方式Read the fixed errcodes definition row, severity, and macro.

    来源src/backend/utils/errcodes.txt

  • The fixed PostgreSQL 18.6 source contains the report path and message context described on the page.

    核实方式Read the complete source context around the resolved report group.

    不覆盖This is source confirmation, not a runtime observation in this batch.

    来源contrib/spi/autoinc.c · contrib/spi/insert_username.c · contrib/spi/moddatetime.c · contrib/spi/refint.c

  • The locked release definitions establish catalogue presence from the known 7.4 boundary; they do not establish a precise introducing release or runtime use.

    核实方式Compare canonical release-definition facts with the available history boundary.

    不覆盖Definition presence is not an emitting-path observation.

    来源src/backend/utils/errcodes.txt

同类 SQL 状态码

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