PostgreSQL Source Code git master
|
#include "access/tupdesc.h"
#include "lib/ilist.h"
#include "nodes/params.h"
#include "tcop/cmdtag.h"
#include "utils/queryenvironment.h"
#include "utils/resowner.h"
Go to the source code of this file.
Data Structures | |
struct | CachedPlanSource |
struct | CachedPlan |
struct | CachedExpression |
Macros | |
#define | CACHEDPLANSOURCE_MAGIC 195726186 |
#define | CACHEDPLAN_MAGIC 953717834 |
#define | CACHEDEXPR_MAGIC 838275847 |
Typedefs | |
typedef struct CachedPlanSource | CachedPlanSource |
typedef struct CachedPlan | CachedPlan |
typedef struct CachedExpression | CachedExpression |
Enumerations | |
enum | PlanCacheMode { PLAN_CACHE_MODE_AUTO , PLAN_CACHE_MODE_FORCE_GENERIC_PLAN , PLAN_CACHE_MODE_FORCE_CUSTOM_PLAN } |
Variables | |
PGDLLIMPORT int | plan_cache_mode |
#define CACHEDEXPR_MAGIC 838275847 |
Definition at line 42 of file plancache.h.
#define CACHEDPLAN_MAGIC 953717834 |
Definition at line 41 of file plancache.h.
#define CACHEDPLANSOURCE_MAGIC 195726186 |
Definition at line 40 of file plancache.h.
typedef struct CachedExpression CachedExpression |
typedef struct CachedPlan CachedPlan |
typedef struct CachedPlanSource CachedPlanSource |
enum PlanCacheMode |
Enumerator | |
---|---|
PLAN_CACHE_MODE_AUTO | |
PLAN_CACHE_MODE_FORCE_GENERIC_PLAN | |
PLAN_CACHE_MODE_FORCE_CUSTOM_PLAN |
Definition at line 30 of file plancache.h.
bool CachedPlanAllowsSimpleValidityCheck | ( | CachedPlanSource * | plansource, |
CachedPlan * | plan, | ||
ResourceOwner | owner | ||
) |
Definition at line 1336 of file plancache.c.
References Assert, CACHEDPLAN_MAGIC, CACHEDPLANSOURCE_MAGIC, CMD_UTILITY, Query::commandType, PlannedStmt::commandType, Query::cteList, CachedPlanSource::dependsOnRLS, CachedPlanSource::gplan, CachedPlanSource::is_oneshot, lfirst, lfirst_node, CachedPlanSource::magic, plan, CachedPlanSource::query_list, ResourceOwnerEnlarge(), ResourceOwnerRememberPlanCacheRef(), Query::rtable, PlannedStmt::rtable, RTE_RELATION, RangeTblEntry::rtekind, CachedPlanSource::search_path, SearchPathMatchesCurrentEnvironment(), and TransactionIdIsValid.
Referenced by exec_eval_simple_expr(), and exec_simple_check_plan().
List * CachedPlanGetTargetList | ( | CachedPlanSource * | plansource, |
QueryEnvironment * | queryEnv | ||
) |
Definition at line 1640 of file plancache.c.
References Assert, CACHEDPLANSOURCE_MAGIC, FetchStatementTargetList(), CachedPlanSource::is_complete, CachedPlanSource::magic, NIL, CachedPlanSource::query_list, QueryListGetPrimaryStmt(), CachedPlanSource::resultDesc, and RevalidateCachedQuery().
Referenced by exec_describe_statement_message(), and FetchPreparedStatementTargetList().
bool CachedPlanIsSimplyValid | ( | CachedPlanSource * | plansource, |
CachedPlan * | plan, | ||
ResourceOwner | owner | ||
) |
Definition at line 1451 of file plancache.c.
References Assert, CACHEDPLAN_MAGIC, CACHEDPLANSOURCE_MAGIC, CachedPlanSource::gplan, CachedPlanSource::is_valid, CachedPlanSource::magic, plan, ResourceOwnerEnlarge(), ResourceOwnerRememberPlanCacheRef(), CachedPlanSource::search_path, and SearchPathMatchesCurrentEnvironment().
Referenced by exec_eval_simple_expr().
bool CachedPlanIsValid | ( | CachedPlanSource * | plansource | ) |
Definition at line 1627 of file plancache.c.
References Assert, CACHEDPLANSOURCE_MAGIC, CachedPlanSource::is_valid, and CachedPlanSource::magic.
Referenced by SPI_plan_is_valid().
void CachedPlanSetParentContext | ( | CachedPlanSource * | plansource, |
MemoryContext | newcontext | ||
) |
Definition at line 1498 of file plancache.c.
References Assert, CACHEDPLAN_MAGIC, CACHEDPLANSOURCE_MAGIC, CachedPlanSource::context, CachedPlan::context, elog, ERROR, CachedPlanSource::gplan, CachedPlanSource::is_complete, CachedPlanSource::is_oneshot, CachedPlanSource::is_saved, CachedPlanSource::magic, CachedPlan::magic, and MemoryContextSetParent().
Referenced by _SPI_make_plan_non_temp().
void CompleteCachedPlan | ( | CachedPlanSource * | plansource, |
List * | querytree_list, | ||
MemoryContext | querytree_context, | ||
Oid * | param_types, | ||
int | num_params, | ||
ParserSetupHook | parserSetup, | ||
void * | parserSetupArg, | ||
int | cursor_options, | ||
bool | fixed_result | ||
) |
Definition at line 366 of file plancache.c.
References ALLOCSET_START_SMALL_SIZES, AllocSetContextCreate, Assert, CACHEDPLANSOURCE_MAGIC, CachedPlanSource::context, copyObject, CurrentMemoryContext, CachedPlanSource::cursor_options, CachedPlanSource::dependsOnRLS, extract_query_dependencies(), CachedPlanSource::fixed_result, GetSearchPathMatcher(), GetUserId(), CachedPlanSource::invalItems, CachedPlanSource::is_complete, CachedPlanSource::is_oneshot, CachedPlanSource::is_valid, CachedPlanSource::magic, MemoryContextSetParent(), MemoryContextSwitchTo(), CachedPlanSource::num_params, palloc(), CachedPlanSource::param_types, CachedPlanSource::parserSetup, CachedPlanSource::parserSetupArg, PlanCacheComputeResultDesc(), CachedPlanSource::query_context, CachedPlanSource::query_list, CachedPlanSource::relationOids, CachedPlanSource::resultDesc, CachedPlanSource::rewriteRoleId, CachedPlanSource::rewriteRowSecurity, row_security, CachedPlanSource::search_path, and StmtPlanRequiresRevalidation.
Referenced by _SPI_execute_plan(), _SPI_prepare_plan(), exec_parse_message(), and PrepareQuery().
CachedPlanSource * CopyCachedPlan | ( | CachedPlanSource * | plansource | ) |
Definition at line 1536 of file plancache.c.
References ALLOCSET_START_SMALL_SIZES, AllocSetContextCreate, Assert, CACHEDPLANSOURCE_MAGIC, CachedPlanSource::commandTag, CachedPlanSource::context, copyObject, CopySearchPathMatcher(), CreateTupleDescCopy(), CurrentMemoryContext, CachedPlanSource::cursor_options, CachedPlanSource::dependsOnRLS, elog, ERROR, CachedPlanSource::fixed_result, CachedPlanSource::generation, CachedPlanSource::generic_cost, CachedPlanSource::gplan, CachedPlanSource::invalItems, CachedPlanSource::is_complete, CachedPlanSource::is_oneshot, CachedPlanSource::is_saved, CachedPlanSource::is_valid, CachedPlanSource::magic, MemoryContextSetIdentifier(), MemoryContextSwitchTo(), CachedPlanSource::num_custom_plans, CachedPlanSource::num_generic_plans, CachedPlanSource::num_params, palloc(), palloc0(), CachedPlanSource::param_types, CachedPlanSource::parserSetup, CachedPlanSource::parserSetupArg, pstrdup(), CachedPlanSource::query_context, CachedPlanSource::query_list, CachedPlanSource::query_string, CachedPlanSource::raw_parse_tree, CachedPlanSource::relationOids, CachedPlanSource::resultDesc, CachedPlanSource::rewriteRoleId, CachedPlanSource::rewriteRowSecurity, CachedPlanSource::search_path, and CachedPlanSource::total_custom_cost.
Referenced by _SPI_save_plan().
CachedPlanSource * CreateCachedPlan | ( | struct RawStmt * | raw_parse_tree, |
const char * | query_string, | ||
CommandTag | commandTag | ||
) |
Definition at line 192 of file plancache.c.
References ALLOCSET_START_SMALL_SIZES, AllocSetContextCreate, Assert, CACHEDPLANSOURCE_MAGIC, CachedPlanSource::commandTag, CachedPlanSource::context, copyObject, CurrentMemoryContext, CachedPlanSource::cursor_options, CachedPlanSource::dependsOnRLS, CachedPlanSource::fixed_result, CachedPlanSource::generation, CachedPlanSource::generic_cost, CachedPlanSource::gplan, InvalidOid, CachedPlanSource::invalItems, CachedPlanSource::is_complete, CachedPlanSource::is_oneshot, CachedPlanSource::is_saved, CachedPlanSource::is_valid, CachedPlanSource::magic, MemoryContextSetIdentifier(), MemoryContextSwitchTo(), NIL, CachedPlanSource::num_custom_plans, CachedPlanSource::num_generic_plans, CachedPlanSource::num_params, palloc0(), CachedPlanSource::param_types, CachedPlanSource::parserSetup, CachedPlanSource::parserSetupArg, pstrdup(), CachedPlanSource::query_context, CachedPlanSource::query_list, CachedPlanSource::query_string, CachedPlanSource::raw_parse_tree, CachedPlanSource::relationOids, CachedPlanSource::resultDesc, CachedPlanSource::rewriteRoleId, CachedPlanSource::rewriteRowSecurity, CachedPlanSource::search_path, and CachedPlanSource::total_custom_cost.
Referenced by _SPI_prepare_plan(), exec_parse_message(), and PrepareQuery().
CachedPlanSource * CreateOneShotCachedPlan | ( | struct RawStmt * | raw_parse_tree, |
const char * | query_string, | ||
CommandTag | commandTag | ||
) |
Definition at line 276 of file plancache.c.
References Assert, CACHEDPLANSOURCE_MAGIC, CachedPlanSource::commandTag, CachedPlanSource::context, CurrentMemoryContext, CachedPlanSource::cursor_options, CachedPlanSource::dependsOnRLS, CachedPlanSource::fixed_result, CachedPlanSource::generation, CachedPlanSource::generic_cost, CachedPlanSource::gplan, InvalidOid, CachedPlanSource::invalItems, CachedPlanSource::is_complete, CachedPlanSource::is_oneshot, CachedPlanSource::is_saved, CachedPlanSource::is_valid, CachedPlanSource::magic, NIL, CachedPlanSource::num_custom_plans, CachedPlanSource::num_generic_plans, CachedPlanSource::num_params, palloc0(), CachedPlanSource::param_types, CachedPlanSource::parserSetup, CachedPlanSource::parserSetupArg, CachedPlanSource::query_context, CachedPlanSource::query_list, CachedPlanSource::query_string, CachedPlanSource::raw_parse_tree, CachedPlanSource::relationOids, CachedPlanSource::resultDesc, CachedPlanSource::rewriteRoleId, CachedPlanSource::rewriteRowSecurity, CachedPlanSource::search_path, and CachedPlanSource::total_custom_cost.
Referenced by _SPI_prepare_oneshot_plan().
void DropCachedPlan | ( | CachedPlanSource * | plansource | ) |
Definition at line 526 of file plancache.c.
References Assert, CACHEDPLANSOURCE_MAGIC, CachedPlanSource::context, dlist_delete(), CachedPlanSource::is_oneshot, CachedPlanSource::is_saved, CachedPlanSource::magic, MemoryContextDelete(), CachedPlanSource::node, and ReleaseGenericPlan().
Referenced by drop_unnamed_stmt(), DropAllPreparedStatements(), DropPreparedStatement(), and SPI_freeplan().
void FreeCachedExpression | ( | CachedExpression * | cexpr | ) |
Definition at line 1734 of file plancache.c.
References Assert, CACHEDEXPR_MAGIC, CachedExpression::context, dlist_delete(), CachedExpression::magic, MemoryContextDelete(), and CachedExpression::node.
Referenced by get_cast_hashentry().
CachedExpression * GetCachedExpression | ( | Node * | expr | ) |
Definition at line 1677 of file plancache.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, cached_expression_list, CACHEDEXPR_MAGIC, CacheMemoryContext, CachedExpression::context, copyObject, CurrentMemoryContext, dlist_push_tail(), CachedExpression::expr, expression_planner_with_deps(), CachedExpression::invalItems, CachedExpression::is_valid, CachedExpression::magic, MemoryContextSetParent(), MemoryContextSwitchTo(), CachedExpression::node, palloc(), and CachedExpression::relationOids.
Referenced by get_cast_hashentry().
CachedPlan * GetCachedPlan | ( | CachedPlanSource * | plansource, |
ParamListInfo | boundParams, | ||
ResourceOwner | owner, | ||
QueryEnvironment * | queryEnv | ||
) |
Definition at line 1168 of file plancache.c.
References Assert, BuildCachedPlan(), cached_plan_cost(), CACHEDPLAN_MAGIC, CACHEDPLANSOURCE_MAGIC, CacheMemoryContext, CheckCachedPlan(), choose_custom_plan(), CachedPlanSource::context, elog, ERROR, CachedPlanSource::generic_cost, CachedPlanSource::gplan, CachedPlanSource::is_complete, CachedPlanSource::is_saved, CachedPlanSource::magic, MemoryContextGetParent(), MemoryContextSetParent(), NIL, CachedPlanSource::num_custom_plans, CachedPlanSource::num_generic_plans, plan, ReleaseGenericPlan(), ResourceOwnerEnlarge(), ResourceOwnerRememberPlanCacheRef(), RevalidateCachedQuery(), and CachedPlanSource::total_custom_cost.
Referenced by _SPI_execute_plan(), exec_bind_message(), ExecuteQuery(), ExplainExecuteQuery(), SPI_cursor_open_internal(), and SPI_plan_get_cached_plan().
void InitPlanCache | ( | void | ) |
Definition at line 155 of file plancache.c.
References CacheRegisterRelcacheCallback(), CacheRegisterSyscacheCallback(), PlanCacheObjectCallback(), PlanCacheRelCallback(), and PlanCacheSysCallback().
Referenced by InitPostgres().
void ReleaseAllPlanCacheRefsInOwner | ( | ResourceOwner | owner | ) |
Definition at line 2232 of file plancache.c.
References planref_resowner_desc, and ResourceOwnerReleaseAllOfKind().
Referenced by plpgsql_call_handler(), plpgsql_inline_handler(), and plpgsql_xact_cb().
void ReleaseCachedPlan | ( | CachedPlan * | plan, |
ResourceOwner | owner | ||
) |
Definition at line 1291 of file plancache.c.
References Assert, CACHEDPLAN_MAGIC, MemoryContextDelete(), plan, and ResourceOwnerForgetPlanCacheRef().
Referenced by _SPI_execute_plan(), exec_eval_simple_expr(), exec_simple_check_plan(), ExplainExecuteQuery(), make_callstmt_target(), PortalReleaseCachedPlan(), ReleaseGenericPlan(), ResOwnerReleaseCachedPlan(), and SPI_cursor_open_internal().
void ResetPlanCache | ( | void | ) |
Definition at line 2185 of file plancache.c.
References Assert, cached_expression_list, CACHEDEXPR_MAGIC, CACHEDPLANSOURCE_MAGIC, dlist_iter::cur, dlist_container, dlist_foreach, CachedPlanSource::gplan, CachedPlanSource::is_valid, CachedPlan::is_valid, CachedExpression::is_valid, CachedPlanSource::magic, CachedExpression::magic, saved_plan_list, and StmtPlanRequiresRevalidation.
Referenced by assign_session_replication_role(), DiscardAll(), DiscardCommand(), and PlanCacheSysCallback().
void SaveCachedPlan | ( | CachedPlanSource * | plansource | ) |
Definition at line 482 of file plancache.c.
References Assert, CACHEDPLANSOURCE_MAGIC, CacheMemoryContext, CachedPlanSource::context, dlist_push_tail(), elog, ERROR, CachedPlanSource::is_complete, CachedPlanSource::is_oneshot, CachedPlanSource::is_saved, CachedPlanSource::magic, MemoryContextSetParent(), CachedPlanSource::node, ReleaseGenericPlan(), and saved_plan_list.
Referenced by _SPI_save_plan(), exec_parse_message(), SPI_keepplan(), and StorePreparedStatement().
|
extern |
Definition at line 147 of file plancache.c.
Referenced by choose_custom_plan().