Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit44956c5

Browse files
committed
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 theyare always run non-deferred, so it's possible to violate the condition ifsomeone mistakenly changes pg_trigger to mark such a trigger deferred.We don't really care about supporting that, but throwing an error insteadof crashing seems desirable. Per report from Marcelo Costa.
1 parent61e5328 commit44956c5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎src/backend/commands/trigger.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.255 2009/10/26 02:26:28 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.256 2009/10/27 20:14:27 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -3895,9 +3895,15 @@ AfterTriggerSaveEvent(ResultRelInfo *relinfo, int event, bool row_trigger,
38953895
intntriggers;
38963896
int*tgindx;
38973897

3898+
/*
3899+
* Check state. We use normal tests not Asserts because it is possible
3900+
* to reach here in the wrong state given misconfigured RI triggers,
3901+
* in particular deferring a cascade action trigger.
3902+
*/
38983903
if (afterTriggers==NULL)
38993904
elog(ERROR,"AfterTriggerSaveEvent() called outside of transaction");
3900-
Assert(afterTriggers->query_depth >=0);
3905+
if (afterTriggers->query_depth<0)
3906+
elog(ERROR,"AfterTriggerSaveEvent() called outside of query");
39013907

39023908
/*
39033909
* Validate the event code and collect the associated tuple CTIDs.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp