mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Fix caching of foreign-key-checking queries so that when a replan is needed,
we regenerate the SQL query text not merely the plan derived from it. This is needed to handle contingencies such as renaming of a table or column used in an FK. Pre-8.3, such cases worked despite the lack of replanning (because the cached plan needn't actually change), so this is a regression. Per bug #4417 from Benjamin Bihler.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.197 2008/07/18 20:26:06 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.198 2008/09/15 23:37:39 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1367,6 +1367,36 @@ SPI_is_cursor_plan(SPIPlanPtr plan)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* SPI_plan_is_valid --- test whether a SPI plan is currently valid
|
||||
* (that is, not marked as being in need of revalidation).
|
||||
*
|
||||
* See notes for CachedPlanIsValid before using this.
|
||||
*/
|
||||
bool
|
||||
SPI_plan_is_valid(SPIPlanPtr plan)
|
||||
{
|
||||
Assert(plan->magic == _SPI_PLAN_MAGIC);
|
||||
if (plan->saved)
|
||||
{
|
||||
ListCell *lc;
|
||||
|
||||
foreach(lc, plan->plancache_list)
|
||||
{
|
||||
CachedPlanSource *plansource = (CachedPlanSource *) lfirst(lc);
|
||||
|
||||
if (!CachedPlanIsValid(plansource))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* An unsaved plan is assumed valid for its (short) lifetime */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* SPI_result_code_string --- convert any SPI return code to a string
|
||||
*
|
||||
|
Reference in New Issue
Block a user