Commit dc1b8cea authored by Tom Lane's avatar Tom Lane

Fix plancache's invalidation callback to do the right thing for a SI

reset event, namely invalidate everything.  This oversight probably
explains the rare failures that some buildfarm machines have been
showing for the plancache regression test.
parent 1cc97d17
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,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/cache/plancache.c,v 1.4 2007/03/23 19:53:51 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.5 2007/03/26 00:36:19 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -812,6 +812,9 @@ PlanCacheComputeResultDesc(List *stmt_list) ...@@ -812,6 +812,9 @@ PlanCacheComputeResultDesc(List *stmt_list)
/* /*
* PlanCacheCallback * PlanCacheCallback
* Relcache inval callback function * Relcache inval callback function
*
* Invalidate all plans mentioning the given rel, or all plans mentioning
* any rel at all if relid == InvalidOid.
*/ */
static void static void
PlanCacheCallback(Datum arg, Oid relid) PlanCacheCallback(Datum arg, Oid relid)
...@@ -843,7 +846,7 @@ PlanCacheCallback(Datum arg, Oid relid) ...@@ -843,7 +846,7 @@ PlanCacheCallback(Datum arg, Oid relid)
if (rte->rtekind != RTE_RELATION) if (rte->rtekind != RTE_RELATION)
continue; continue;
if (relid == rte->relid) if (relid == rte->relid || relid == InvalidOid)
{ {
/* Invalidate the plan! */ /* Invalidate the plan! */
plan->dead = true; plan->dead = true;
...@@ -883,10 +886,11 @@ PlanCacheCallback(Datum arg, Oid relid) ...@@ -883,10 +886,11 @@ PlanCacheCallback(Datum arg, Oid relid)
static void static void
InvalRelid(Oid relid, LOCKMODE lockmode, InvalRelidContext *context) InvalRelid(Oid relid, LOCKMODE lockmode, InvalRelidContext *context)
{ {
if (relid == context->inval_relid) if (relid == context->inval_relid || context->inval_relid == InvalidOid)
context->plan->dead = true; context->plan->dead = true;
} }
/* /*
* HaveCachedPlans * HaveCachedPlans
* Check if the plancache has stored any plans at all. * Check if the plancache has stored any plans at all.
...@@ -896,4 +900,3 @@ HaveCachedPlans(void) ...@@ -896,4 +900,3 @@ HaveCachedPlans(void)
{ {
return (cached_plans_list != NIL); return (cached_plans_list != NIL);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment