Skip to content

Commit d5df606

Browse files
committed
ActiveSnapshot must be set to something valid while running deferred
triggers during COMMIT. Per trouble report from Frank van Vugt.
1 parent e514da6 commit d5df606

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/backend/commands/trigger.c

Lines changed: 9 additions & 1 deletion
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-
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.175 2004/11/14 02:04:14 neilc Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.176 2004/12/06 23:57:17 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2364,6 +2364,14 @@ AfterTriggerEndXact(void)
23642364
/* ... but not inside a query */
23652365
Assert(afterTriggers->query_depth == -1);
23662366

2367+
/*
2368+
* If there are any triggers to fire, make sure we have set a snapshot
2369+
* for them to use. (Since PortalRunUtility doesn't set a snap for
2370+
* COMMIT, we can't assume ActiveSnapshot is valid on entry.)
2371+
*/
2372+
if (afterTriggers->events.head != NULL)
2373+
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
2374+
23672375
/*
23682376
* Run all the remaining triggers. Loop until they are all gone,
23692377
* just in case some trigger queues more for us to do.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy