get_relation_stats_hook
表列统计信息
供插件在请求统计信息时接管处理的钩子。
当前查看 PostgreSQL 18。
中文定义与说明
供插件在请求统计信息时接管处理的钩子。
以下中文为本站依据所列 PostgreSQL 源码注释编译的说明。
接口声明
typedef bool (*get_relation_stats_hook_type) (PlannerInfo *root, RangeTblEntry *rte, AttrNumber attnum, VariableStatData *vardata); extern PGDLLIMPORT get_relation_stats_hook_type get_relation_stats_hook;
调用位置
src/backend/utils/adt/selfuncs.c:5717src/backend/utils/adt/selfuncs.c:6198src/backend/utils/adt/selfuncs.c:8752
核心调用上下文:src/backend/utils/adt/selfuncs.c:5711–5725
{
RangeTblEntry *rte = root->simple_rte_array[var->varno];
Assert(IsA(rte, RangeTblEntry));
if (get_relation_stats_hook &&
(*get_relation_stats_hook) (root, rte, var->varattno, vardata))
{
/*
* The hook took control of acquiring a stats tuple. If it did supply
* a tuple, it'd better have supplied a freefunc.
*/
if (HeapTupleIsValid(vardata->statsTuple) &&
!vardata->freefunc)
elog(ERROR, "no function provided to release variable stats with");核心调用上下文:src/backend/utils/adt/selfuncs.c:6192–6206
relid = rte->relid;
Assert(relid != InvalidOid);
colnum = index->indexkeys[indexcol];
vardata->rel = index->rel;
if (get_relation_stats_hook &&
(*get_relation_stats_hook) (root, rte, colnum, vardata))
{
/*
* The hook took control of acquiring a stats tuple. If it did
* supply a tuple, it'd better have supplied a freefunc.
*/
if (HeapTupleIsValid(vardata->statsTuple) &&
!vardata->freefunc)
elog(ERROR, "no function provided to release variable stats with");核心调用上下文:src/backend/utils/adt/selfuncs.c:8746–8760
/* attempt to lookup stats in relation for this index column */
if (attnum != 0)
{
/* Simple variable -- look to stats for the underlying table */
if (get_relation_stats_hook &&
(*get_relation_stats_hook) (root, rte, attnum, &vardata))
{
/*
* The hook took control of acquiring a stats tuple. If it
* did supply a tuple, it'd better have supplied a freefunc.
*/
if (HeapTupleIsValid(vardata.statsTuple) && !vardata.freefunc)
elog(ERROR,
"no function provided to release variable stats with");说明
供插件在请求统计信息时接管处理的钩子。
- 接口类型
- get_relation_stats_hook_type
- 声明头文件
- src/include/utils/selfuncs.h
- 调用阶段
- 统计信息与估算
- 初始值
- NULL(未安装钩子)
接口签名
typedef bool (*get_relation_stats_hook_type) (PlannerInfo *root, RangeTblEntry *rte, AttrNumber attnum, VariableStatData *vardata);
extern PGDLLIMPORT get_relation_stats_hook_type get_relation_stats_hook;调用位置
src/backend/utils/adt/selfuncs.c:5717
src/backend/utils/adt/selfuncs.c:6198
src/backend/utils/adt/selfuncs.c:8752
相关条目
文档与源码
查看来源构建
- 版本
- 18
- 构建
- REL_18_STABLE
- 来源指纹
753057e340da8f22e57c9a409ea7a235fd6a46bd
同类条目
get_attavgwidth_hook平均属性宽度get_index_stats_hook索引表达式统计信息
返回扩展钩子 · 此条目的收录范围为 PostgreSQL 10 至 20;起点不一定是实际引入版本。