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.93 2001/06/22 19:16:21 wieck Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.94 2001/08/02 15:59:28 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -1499,7 +1499,7 @@ deferredTriggerInvokeEvents(bool immediate_only)
1499
1499
per_tuple_context =
1500
1500
AllocSetContextCreate (CurrentMemoryContext ,
1501
1501
"DeferredTriggerTupleContext" ,
1502
- 0 ,
1502
+ ALLOCSET_DEFAULT_MINSIZE ,
1503
1503
ALLOCSET_DEFAULT_INITSIZE ,
1504
1504
ALLOCSET_DEFAULT_MAXSIZE );
1505
1505
@@ -1594,9 +1594,13 @@ deferredTriggerInvokeEvents(bool immediate_only)
1594
1594
void
1595
1595
DeferredTriggerInit (void )
1596
1596
{
1597
+ /*
1598
+ * Since this context will never be reset, give it a minsize of 0.
1599
+ * This avoids using any memory if the session never stores anything.
1600
+ */
1597
1601
deftrig_gcxt = AllocSetContextCreate (TopMemoryContext ,
1598
1602
"DeferredTriggerSession" ,
1599
- ALLOCSET_DEFAULT_MINSIZE ,
1603
+ 0 ,
1600
1604
ALLOCSET_DEFAULT_INITSIZE ,
1601
1605
ALLOCSET_DEFAULT_MAXSIZE );
1602
1606
}
@@ -1623,11 +1627,12 @@ DeferredTriggerBeginXact(void)
1623
1627
1624
1628
/*
1625
1629
* Create the per transaction memory context and copy all states from
1626
- * the per session context to here.
1630
+ * the per session context to here. Set the minsize to 0 to avoid
1631
+ * wasting memory if there is no deferred trigger data.
1627
1632
*/
1628
1633
deftrig_cxt = AllocSetContextCreate (TopTransactionContext ,
1629
1634
"DeferredTriggerXact" ,
1630
- ALLOCSET_DEFAULT_MINSIZE ,
1635
+ 0 ,
1631
1636
ALLOCSET_DEFAULT_INITSIZE ,
1632
1637
ALLOCSET_DEFAULT_MAXSIZE );
1633
1638
oldcxt = MemoryContextSwitchTo (deftrig_cxt );
@@ -1911,7 +1916,6 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
1911
1916
1912
1917
if (!IsTransactionBlock ())
1913
1918
{
1914
-
1915
1919
/*
1916
1920
* Outside of a transaction block set the trigger states of
1917
1921
* individual triggers on session level.
@@ -1949,7 +1953,6 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
1949
1953
}
1950
1954
else
1951
1955
{
1952
-
1953
1956
/*
1954
1957
* Inside of a transaction block set the trigger states of
1955
1958
* individual triggers on transaction level.
0 commit comments