mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Improve the plan cache invalidation mechanism to make it invalidate plans
when user-defined functions used in a plan are modified. Also invalidate plans when schemas, operators, or operator classes are modified; but for these cases we just invalidate everything rather than tracking exact dependencies, since these types of objects seldom change in a production database. Tom Lane; loosely based on a patch by Martin Pihlak.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.266 2008/08/28 23:09:46 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.267 2008/09/09 18:58:08 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -50,6 +50,7 @@
|
||||
typedef struct
|
||||
{
|
||||
ParamListInfo boundParams;
|
||||
PlannerGlobal *glob;
|
||||
List *active_fns;
|
||||
Node *case_val;
|
||||
bool estimate;
|
||||
@@ -1890,9 +1891,15 @@ eval_const_expressions(PlannerInfo *root, Node *node)
|
||||
eval_const_expressions_context context;
|
||||
|
||||
if (root)
|
||||
{
|
||||
context.boundParams = root->glob->boundParams; /* bound Params */
|
||||
context.glob = root->glob; /* for inlined-function dependencies */
|
||||
}
|
||||
else
|
||||
{
|
||||
context.boundParams = NULL;
|
||||
context.glob = NULL;
|
||||
}
|
||||
context.active_fns = NIL; /* nothing being recursively simplified */
|
||||
context.case_val = NULL; /* no CASE being examined */
|
||||
context.estimate = false; /* safe transformations only */
|
||||
@@ -1921,6 +1928,8 @@ estimate_expression_value(PlannerInfo *root, Node *node)
|
||||
eval_const_expressions_context context;
|
||||
|
||||
context.boundParams = root->glob->boundParams; /* bound Params */
|
||||
/* we do not need to mark the plan as depending on inlined functions */
|
||||
context.glob = NULL;
|
||||
context.active_fns = NIL; /* nothing being recursively simplified */
|
||||
context.case_val = NULL; /* no CASE being examined */
|
||||
context.estimate = true; /* unsafe transformations OK */
|
||||
@@ -3468,6 +3477,13 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
||||
|
||||
MemoryContextDelete(mycxt);
|
||||
|
||||
/*
|
||||
* Since there is now no trace of the function in the plan tree, we
|
||||
* must explicitly record the plan's dependency on the function.
|
||||
*/
|
||||
if (context->glob)
|
||||
record_plan_function_dependency(context->glob, funcid);
|
||||
|
||||
/*
|
||||
* Recursively try to simplify the modified expression. Here we must add
|
||||
* the current function to the context list of active functions.
|
||||
@@ -3842,6 +3858,12 @@ inline_set_returning_function(PlannerInfo *root, Node *node)
|
||||
error_context_stack = sqlerrcontext.previous;
|
||||
ReleaseSysCache(func_tuple);
|
||||
|
||||
/*
|
||||
* Since there is now no trace of the function in the plan tree, we
|
||||
* must explicitly record the plan's dependency on the function.
|
||||
*/
|
||||
record_plan_function_dependency(root->glob, fexpr->funcid);
|
||||
|
||||
return querytree;
|
||||
|
||||
/* Here if func is not inlinable: release temp memory and return NULL */
|
||||
|
||||
Reference in New Issue
Block a user