mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Fire non-deferred AFTER triggers immediately upon query completion,
rather than when returning to the idle loop. This makes no particular difference for interactively-issued queries, but it makes a big difference for queries issued within functions: trigger execution now occurs before the calling function is allowed to proceed. This responds to numerous complaints about nonintuitive behavior of foreign key checking, such as http://archives.postgresql.org/pgsql-bugs/2004-09/msg00020.php, and appears to be required by the SQL99 spec. Also take the opportunity to simplify the data structures used for the pending-trigger list, rename them for more clarity, and squeeze out a bit of space.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/commands/trigger.h,v 1.48 2004/08/29 05:06:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/commands/trigger.h,v 1.49 2004/09/10 18:40:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -45,11 +45,12 @@ typedef struct TriggerData
|
||||
#define TRIGGER_EVENT_ROW 0x00000004
|
||||
#define TRIGGER_EVENT_BEFORE 0x00000008
|
||||
|
||||
#define TRIGGER_DEFERRED_DONE 0x00000010
|
||||
#define TRIGGER_DEFERRED_CANCELED 0x00000020
|
||||
#define TRIGGER_DEFERRED_DEFERRABLE 0x00000040
|
||||
#define TRIGGER_DEFERRED_INITDEFERRED 0x00000080
|
||||
#define TRIGGER_DEFERRED_HAS_BEFORE 0x00000100
|
||||
/* More TriggerEvent flags, used only within trigger.c */
|
||||
|
||||
#define AFTER_TRIGGER_DONE 0x00000010
|
||||
#define AFTER_TRIGGER_IN_PROGRESS 0x00000020
|
||||
#define AFTER_TRIGGER_DEFERRABLE 0x00000040
|
||||
#define AFTER_TRIGGER_INITDEFERRED 0x00000080
|
||||
|
||||
#define TRIGGER_FIRED_BY_INSERT(event) \
|
||||
(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
|
||||
@ -151,14 +152,15 @@ extern void ExecARUpdateTriggers(EState *estate,
|
||||
ItemPointer tupleid,
|
||||
HeapTuple newtuple);
|
||||
|
||||
extern void DeferredTriggerBeginXact(void);
|
||||
extern void DeferredTriggerEndQuery(void);
|
||||
extern void DeferredTriggerEndXact(void);
|
||||
extern void DeferredTriggerAbortXact(void);
|
||||
extern void DeferredTriggerBeginSubXact(void);
|
||||
extern void DeferredTriggerEndSubXact(bool isCommit);
|
||||
extern void AfterTriggerBeginXact(void);
|
||||
extern void AfterTriggerBeginQuery(void);
|
||||
extern void AfterTriggerEndQuery(void);
|
||||
extern void AfterTriggerEndXact(void);
|
||||
extern void AfterTriggerAbortXact(void);
|
||||
extern void AfterTriggerBeginSubXact(void);
|
||||
extern void AfterTriggerEndSubXact(bool isCommit);
|
||||
|
||||
extern void DeferredTriggerSetState(ConstraintsSetStmt *stmt);
|
||||
extern void AfterTriggerSetState(ConstraintsSetStmt *stmt);
|
||||
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user