77 * Portions Copyright (c) 1994, Regents of the University of California
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.146 2003/03/27 14:33:11 tgl Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.147 2003/03/31 20:47:51 momjian Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
1414#include "postgres.h"
1515
1616#include "access/genam.h"
1717#include "access/heapam.h"
18+ #include "access/xact.h"
1819#include "catalog/catalog.h"
1920#include "catalog/catname.h"
2021#include "catalog/dependency.h"
@@ -1601,23 +1602,19 @@ ltrmark:;
16011602 */
16021603
16031604
1604- /* ----------
1605- * Internal data to the deferred trigger mechanism is held
1606- * during entire session in a global context created at startup and
1607- * over statements/commands in a separate context which
1608- * is created at transaction start and destroyed at transaction end.
1609- * ----------
1605+ /*
1606+ * Internal data to the deferred trigger mechanism is held over
1607+ * statements/commands in a context which is created at transaction
1608+ * start and destroyed at transaction end.
16101609 */
1611- static MemoryContext deftrig_gcxt = NULL ;
1610+
16121611static MemoryContext deftrig_cxt = NULL ;
16131612
16141613/* ----------
16151614 * Global data that tells which triggers are actually in
16161615 * state IMMEDIATE or DEFERRED.
16171616 * ----------
16181617 */
1619- static List * deftrig_dfl_trigstates = NIL ;
1620-
16211618static bool deftrig_all_isset = false;
16221619static bool deftrig_all_isdeferred = false;
16231620static List * deftrig_trigstates ;
@@ -2017,11 +2014,8 @@ deferredTriggerInvokeEvents(bool immediate_only)
20172014void
20182015DeferredTriggerInit (void )
20192016{
2020- deftrig_gcxt = AllocSetContextCreate (TopMemoryContext ,
2021- "DeferredTriggerSession" ,
2022- ALLOCSET_DEFAULT_MINSIZE ,
2023- ALLOCSET_DEFAULT_INITSIZE ,
2024- ALLOCSET_DEFAULT_MAXSIZE );
2017+ /* Nothing to do */
2018+ ;
20252019}
20262020
20272021
@@ -2035,26 +2029,18 @@ DeferredTriggerInit(void)
20352029void
20362030DeferredTriggerBeginXact (void )
20372031{
2038- MemoryContext oldcxt ;
2039- List * l ;
2040- DeferredTriggerStatus dflstat ;
2041- DeferredTriggerStatus stat ;
2042-
20432032if (deftrig_cxt != NULL )
20442033elog (ERROR ,
20452034"DeferredTriggerBeginXact() called while inside transaction" );
20462035
20472036/*
2048- * Create the per transaction memory context and copy all states from
2049- * the per session context to here.
2037+ * Create the per transaction memory context
20502038 */
20512039deftrig_cxt = AllocSetContextCreate (TopTransactionContext ,
20522040"DeferredTriggerXact" ,
20532041ALLOCSET_DEFAULT_MINSIZE ,
20542042ALLOCSET_DEFAULT_INITSIZE ,
20552043ALLOCSET_DEFAULT_MAXSIZE );
2056- oldcxt = MemoryContextSwitchTo (deftrig_cxt );
2057-
20582044deftrig_all_isset = false;
20592045
20602046/*
@@ -2063,19 +2049,6 @@ DeferredTriggerBeginXact(void)
20632049deftrig_all_isdeferred = false;
20642050
20652051deftrig_trigstates = NIL ;
2066- foreach (l ,deftrig_dfl_trigstates )
2067- {
2068- dflstat = (DeferredTriggerStatus )lfirst (l );
2069- stat = (DeferredTriggerStatus )
2070- palloc (sizeof (DeferredTriggerStatusData ));
2071-
2072- stat -> dts_tgoid = dflstat -> dts_tgoid ;
2073- stat -> dts_tgisdeferred = dflstat -> dts_tgisdeferred ;
2074-
2075- deftrig_trigstates = lappend (deftrig_trigstates ,stat );
2076- }
2077-
2078- MemoryContextSwitchTo (oldcxt );
20792052
20802053deftrig_events = NULL ;
20812054deftrig_event_tail = NULL ;