mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Fix portalmem.c to avoid keeping a dangling pointer to a cached plan list
after it's released its reference count for the cached plan. There are code paths that might try to examine the plan list before noticing that the portal is already in aborted state. Report and diagnosis by Tatsuo Ishii, though this isn't exactly his proposed patch.
This commit is contained in:
parent
04ef404018
commit
376c6203cc
@ -12,7 +12,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.115 2010/01/02 16:57:58 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.116 2010/01/18 02:30:25 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -328,6 +328,13 @@ PortalReleaseCachedPlan(Portal portal)
|
|||||||
{
|
{
|
||||||
ReleaseCachedPlan(portal->cplan, false);
|
ReleaseCachedPlan(portal->cplan, false);
|
||||||
portal->cplan = NULL;
|
portal->cplan = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We must also clear portal->stmts which is now a dangling
|
||||||
|
* reference to the cached plan's plan list. This protects any
|
||||||
|
* code that might try to examine the Portal later.
|
||||||
|
*/
|
||||||
|
portal->stmts = NIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +402,6 @@ PortalDrop(Portal portal, bool isTopCommit)
|
|||||||
(*portal->cleanup) (portal);
|
(*portal->cleanup) (portal);
|
||||||
|
|
||||||
/* drop cached plan reference, if any */
|
/* drop cached plan reference, if any */
|
||||||
if (portal->cplan)
|
|
||||||
PortalReleaseCachedPlan(portal);
|
PortalReleaseCachedPlan(portal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -529,7 +535,6 @@ CommitHoldablePortals(void)
|
|||||||
PersistHoldablePortal(portal);
|
PersistHoldablePortal(portal);
|
||||||
|
|
||||||
/* drop cached plan reference, if any */
|
/* drop cached plan reference, if any */
|
||||||
if (portal->cplan)
|
|
||||||
PortalReleaseCachedPlan(portal);
|
PortalReleaseCachedPlan(portal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -680,7 +685,6 @@ AtAbort_Portals(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* drop cached plan reference, if any */
|
/* drop cached plan reference, if any */
|
||||||
if (portal->cplan)
|
|
||||||
PortalReleaseCachedPlan(portal);
|
PortalReleaseCachedPlan(portal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -823,7 +827,6 @@ AtSubAbort_Portals(SubTransactionId mySubid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* drop cached plan reference, if any */
|
/* drop cached plan reference, if any */
|
||||||
if (portal->cplan)
|
|
||||||
PortalReleaseCachedPlan(portal);
|
PortalReleaseCachedPlan(portal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user