diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-10 18:40:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-10 18:40:09 +0000 |
commit | b339d1fff6c2f14776af29a35c8550b222ca70b2 (patch) | |
tree | be0ed19fa78e35cdde627d1c6bc4c4be9f7cb44e /src/backend/executor/functions.c | |
parent | 856d1faac1024717b7c37665c46fd635dc52b1b4 (diff) | |
download | postgresql-b339d1fff6c2f14776af29a35c8550b222ca70b2.tar.gz postgresql-b339d1fff6c2f14776af29a35c8550b222ca70b2.zip |
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.
Diffstat (limited to 'src/backend/executor/functions.c')
-rw-r--r-- | src/backend/executor/functions.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 2a9e5d88a9e..3611c85a5fc 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.87 2004/09/06 18:10:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.88 2004/09/10 18:39:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,6 +17,7 @@ #include "access/heapam.h" #include "catalog/pg_proc.h" #include "catalog/pg_type.h" +#include "commands/trigger.h" #include "executor/execdefs.h" #include "executor/executor.h" #include "executor/functions.h" @@ -273,7 +274,10 @@ postquel_start(execution_state *es, SQLFunctionCachePtr fcache) /* Utility commands don't need Executor. */ if (es->qd->operation != CMD_UTILITY) + { + AfterTriggerBeginQuery(); ExecutorStart(es->qd, false, false); + } es->status = F_EXEC_RUN; } @@ -316,7 +320,10 @@ postquel_end(execution_state *es) /* Utility commands don't need Executor. */ if (es->qd->operation != CMD_UTILITY) + { ExecutorEnd(es->qd); + AfterTriggerEndQuery(); + } FreeQueryDesc(es->qd); es->qd = NULL; |