Avoid memory leakage when a series of subtransactions invoke AFTER triggers
authorTom Lane <[email protected]>
Sun, 1 Jul 2007 17:45:49 +0000 (17:45 +0000)
committerTom Lane <[email protected]>
Sun, 1 Jul 2007 17:45:49 +0000 (17:45 +0000)
commita03f074e3bd4d712858e945be8bfb98f9ff7ae6e
tree3bd2a9f00b2ae110ab688f1156f45d80088a078d
parent7e629961615abb7190ea56db83a7d1bd0967fbf1
Avoid memory leakage when a series of subtransactions invoke AFTER triggers
that are fired at end-of-statement (as is the normal case for foreign keys,
for example).  In this situation the per-subxact deferred trigger context
is always empty when subtransaction exit is reached; so we could free it,
but were not doing so, leading to an intratransaction leak of 8K or more
per subtransaction.  Per off-list example from Viatcheslav Kalinin
subsequent to bug #3418 (his original bug report omitted a foreign key
constraint needed to cause this leak).

Back-patch to 8.2; prior versions were not using per-subxact contexts
for deferred triggers, so did not have this leak.
src/backend/commands/trigger.c