diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 627be4d581..5cf4f41207 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.210.2.7 2008/12/13 02:00:52 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.210.2.8 2009/10/27 20:14:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3318,8 +3318,15 @@ AfterTriggerSaveEvent(ResultRelInfo *relinfo, int event, bool row_trigger, ItemPointerData oldctid; ItemPointerData newctid; + /* + * Check state. We use normal tests not Asserts because it is possible + * to reach here in the wrong state given misconfigured RI triggers, + * in particular deferring a cascade action trigger. + */ if (afterTriggers == NULL) elog(ERROR, "AfterTriggerSaveEvent() called outside of transaction"); + if (afterTriggers->query_depth < 0) + elog(ERROR, "AfterTriggerSaveEvent() called outside of query"); /* * Get the CTID's of OLD and NEW