|
12 | 12 | * Portions Copyright (c) 1994, Regents of the University of California
|
13 | 13 | *
|
14 | 14 | * IDENTIFICATION
|
15 |
| - * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.115 2010/01/02 16:57:58 momjian Exp $ |
| 15 | + * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.116 2010/01/18 02:30:25 tgl Exp $ |
16 | 16 | *
|
17 | 17 | *-------------------------------------------------------------------------
|
18 | 18 | */
|
@@ -328,6 +328,13 @@ PortalReleaseCachedPlan(Portal portal)
|
328 | 328 | {
|
329 | 329 | ReleaseCachedPlan(portal->cplan, false);
|
330 | 330 | portal->cplan = NULL;
|
| 331 | + |
| 332 | + /* |
| 333 | + * We must also clear portal->stmts which is now a dangling |
| 334 | + * reference to the cached plan's plan list. This protects any |
| 335 | + * code that might try to examine the Portal later. |
| 336 | + */ |
| 337 | + portal->stmts = NIL; |
331 | 338 | }
|
332 | 339 | }
|
333 | 340 |
|
@@ -395,8 +402,7 @@ PortalDrop(Portal portal, bool isTopCommit)
|
395 | 402 | (*portal->cleanup) (portal);
|
396 | 403 |
|
397 | 404 | /* drop cached plan reference, if any */
|
398 |
| - if (portal->cplan) |
399 |
| - PortalReleaseCachedPlan(portal); |
| 405 | + PortalReleaseCachedPlan(portal); |
400 | 406 |
|
401 | 407 | /*
|
402 | 408 | * Release any resources still attached to the portal. There are several
|
@@ -529,8 +535,7 @@ CommitHoldablePortals(void)
|
529 | 535 | PersistHoldablePortal(portal);
|
530 | 536 |
|
531 | 537 | /* drop cached plan reference, if any */
|
532 |
| - if (portal->cplan) |
533 |
| - PortalReleaseCachedPlan(portal); |
| 538 | + PortalReleaseCachedPlan(portal); |
534 | 539 |
|
535 | 540 | /*
|
536 | 541 | * Any resources belonging to the portal will be released in the
|
@@ -680,8 +685,7 @@ AtAbort_Portals(void)
|
680 | 685 | }
|
681 | 686 |
|
682 | 687 | /* drop cached plan reference, if any */
|
683 |
| - if (portal->cplan) |
684 |
| - PortalReleaseCachedPlan(portal); |
| 688 | + PortalReleaseCachedPlan(portal); |
685 | 689 |
|
686 | 690 | /*
|
687 | 691 | * Any resources belonging to the portal will be released in the
|
@@ -823,8 +827,7 @@ AtSubAbort_Portals(SubTransactionId mySubid,
|
823 | 827 | }
|
824 | 828 |
|
825 | 829 | /* drop cached plan reference, if any */
|
826 |
| - if (portal->cplan) |
827 |
| - PortalReleaseCachedPlan(portal); |
| 830 | + PortalReleaseCachedPlan(portal); |
828 | 831 |
|
829 | 832 | /*
|
830 | 833 | * Any resources belonging to the portal will be released in the
|
|
0 commit comments