提交 972dd130 编写于 作者: T Tom Lane

Fix AfterTriggerSaveEvent to use a test and elog, not just Assert, to check

that it's called within an AfterTriggerBeginQuery/AfterTriggerEndQuery pair.
The RI cascade triggers suppress that overhead on the assumption that they
are always run non-deferred, so it's possible to violate the condition if
someone mistakenly changes pg_trigger to mark such a trigger deferred.
We don't really care about supporting that, but throwing an error instead
of crashing seems desirable.  Per report from Marcelo Costa.
上级 e0066c6b
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.227.2.2 2008/12/13 02:00:29 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.227.2.3 2009/10/27 20:14:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -3606,8 +3606,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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册