7
7
* Portions Copyright (c) 1994, Regents of the University of California
8
8
*
9
9
* 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 $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
14
14
#include "postgres.h"
15
15
16
16
#include "access/genam.h"
17
17
#include "access/heapam.h"
18
+ #include "access/xact.h"
18
19
#include "catalog/catalog.h"
19
20
#include "catalog/catname.h"
20
21
#include "catalog/dependency.h"
@@ -1601,23 +1602,19 @@ ltrmark:;
1601
1602
*/
1602
1603
1603
1604
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.
1610
1609
*/
1611
- static MemoryContext deftrig_gcxt = NULL ;
1610
+
1612
1611
static MemoryContext deftrig_cxt = NULL ;
1613
1612
1614
1613
/* ----------
1615
1614
* Global data that tells which triggers are actually in
1616
1615
* state IMMEDIATE or DEFERRED.
1617
1616
* ----------
1618
1617
*/
1619
- static List * deftrig_dfl_trigstates = NIL ;
1620
-
1621
1618
static bool deftrig_all_isset = false;
1622
1619
static bool deftrig_all_isdeferred = false;
1623
1620
static List * deftrig_trigstates ;
@@ -2017,11 +2014,8 @@ deferredTriggerInvokeEvents(bool immediate_only)
2017
2014
void
2018
2015
DeferredTriggerInit (void )
2019
2016
{
2020
- deftrig_gcxt = AllocSetContextCreate (TopMemoryContext ,
2021
- "DeferredTriggerSession" ,
2022
- ALLOCSET_DEFAULT_MINSIZE ,
2023
- ALLOCSET_DEFAULT_INITSIZE ,
2024
- ALLOCSET_DEFAULT_MAXSIZE );
2017
+ /* Nothing to do */
2018
+ ;
2025
2019
}
2026
2020
2027
2021
@@ -2035,26 +2029,18 @@ DeferredTriggerInit(void)
2035
2029
void
2036
2030
DeferredTriggerBeginXact (void )
2037
2031
{
2038
- MemoryContext oldcxt ;
2039
- List * l ;
2040
- DeferredTriggerStatus dflstat ;
2041
- DeferredTriggerStatus stat ;
2042
-
2043
2032
if (deftrig_cxt != NULL )
2044
2033
elog (ERROR ,
2045
2034
"DeferredTriggerBeginXact() called while inside transaction" );
2046
2035
2047
2036
/*
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
2050
2038
*/
2051
2039
deftrig_cxt = AllocSetContextCreate (TopTransactionContext ,
2052
2040
"DeferredTriggerXact" ,
2053
2041
ALLOCSET_DEFAULT_MINSIZE ,
2054
2042
ALLOCSET_DEFAULT_INITSIZE ,
2055
2043
ALLOCSET_DEFAULT_MAXSIZE );
2056
- oldcxt = MemoryContextSwitchTo (deftrig_cxt );
2057
-
2058
2044
deftrig_all_isset = false;
2059
2045
2060
2046
/*
@@ -2063,19 +2049,6 @@ DeferredTriggerBeginXact(void)
2063
2049
deftrig_all_isdeferred = false;
2064
2050
2065
2051
deftrig_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 );
2079
2052
2080
2053
deftrig_events = NULL ;
2081
2054
deftrig_event_tail = NULL ;