Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitecaa2e0

Browse files
committed
Fix some poor decisions about sizing of trigger-related memory contexts.
1 parent84d2c51 commitecaa2e0

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

‎src/backend/commands/trigger.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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.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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1499,7 +1499,7 @@ deferredTriggerInvokeEvents(bool immediate_only)
14991499
per_tuple_context=
15001500
AllocSetContextCreate(CurrentMemoryContext,
15011501
"DeferredTriggerTupleContext",
1502-
0,
1502+
ALLOCSET_DEFAULT_MINSIZE,
15031503
ALLOCSET_DEFAULT_INITSIZE,
15041504
ALLOCSET_DEFAULT_MAXSIZE);
15051505

@@ -1594,9 +1594,13 @@ deferredTriggerInvokeEvents(bool immediate_only)
15941594
void
15951595
DeferredTriggerInit(void)
15961596
{
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+
*/
15971601
deftrig_gcxt=AllocSetContextCreate(TopMemoryContext,
15981602
"DeferredTriggerSession",
1599-
ALLOCSET_DEFAULT_MINSIZE,
1603+
0,
16001604
ALLOCSET_DEFAULT_INITSIZE,
16011605
ALLOCSET_DEFAULT_MAXSIZE);
16021606
}
@@ -1623,11 +1627,12 @@ DeferredTriggerBeginXact(void)
16231627

16241628
/*
16251629
* 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.
16271632
*/
16281633
deftrig_cxt=AllocSetContextCreate(TopTransactionContext,
16291634
"DeferredTriggerXact",
1630-
ALLOCSET_DEFAULT_MINSIZE,
1635+
0,
16311636
ALLOCSET_DEFAULT_INITSIZE,
16321637
ALLOCSET_DEFAULT_MAXSIZE);
16331638
oldcxt=MemoryContextSwitchTo(deftrig_cxt);
@@ -1911,7 +1916,6 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
19111916

19121917
if (!IsTransactionBlock())
19131918
{
1914-
19151919
/*
19161920
* Outside of a transaction block set the trigger states of
19171921
* individual triggers on session level.
@@ -1949,7 +1953,6 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
19491953
}
19501954
else
19511955
{
1952-
19531956
/*
19541957
* Inside of a transaction block set the trigger states of
19551958
* individual triggers on transaction level.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp