From 12a47c6aca43e33d42ef946761ec0406476dd1b0 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 21 Oct 2004 21:33:59 +0000 Subject: Disallow referential integrity actions from being deferred; only the NO ACTION check is deferrable. This seems to be a closer approximation to what the SQL spec says than what we were doing before, and it prevents some anomalous behaviors that are possible now that triggers can fire during the execution of PL functions. Stephan Szabo. --- src/backend/commands/trigger.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/backend/commands/trigger.c') diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 5480fce189f..7b1bdddf0ba 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.172 2004/09/10 18:39:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.173 2004/10/21 21:33:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2729,11 +2729,17 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) /* * If we found some, check that they fit the deferrability - * but skip ON RESTRICT ones, since they are + * but skip referential action ones, since they are * silently never deferrable. */ if (pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_UPD && - pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_DEL) + pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_DEL && + pg_trigger->tgfoid != F_RI_FKEY_CASCADE_UPD && + pg_trigger->tgfoid != F_RI_FKEY_CASCADE_DEL && + pg_trigger->tgfoid != F_RI_FKEY_SETNULL_UPD && + pg_trigger->tgfoid != F_RI_FKEY_SETNULL_DEL && + pg_trigger->tgfoid != F_RI_FKEY_SETDEFAULT_UPD && + pg_trigger->tgfoid != F_RI_FKEY_SETDEFAULT_DEL) { if (stmt->deferred && !pg_trigger->tgdeferrable) ereport(ERROR, -- cgit v1.2.3