get_index_stats_hook
索引表达式统计信息
get_index_stats_hook 是在 src/include/utils/selfuncs.h 中声明的核心扩展钩子。下方保留精确接口与调用位置。
当前查看 PostgreSQL 18。
中文定义与说明
get_index_stats_hook 是在 src/include/utils/selfuncs.h 中声明的核心扩展钩子。下方保留精确接口与调用位置。
以下中文为本站依据所列 PostgreSQL 源码注释编译的说明。
接口声明
typedef bool (*get_index_stats_hook_type) (PlannerInfo *root, Oid indexOid, AttrNumber indexattnum, VariableStatData *vardata); extern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;
调用位置
src/backend/utils/adt/selfuncs.c:5488src/backend/utils/adt/selfuncs.c:6224src/backend/utils/adt/selfuncs.c:8783
核心调用上下文:src/backend/utils/adt/selfuncs.c:5482–5496
* a partial index.
*
* An index stats hook, however, must make its own
* decisions about what to do with partial indexes.
*/
if (get_index_stats_hook &&
(*get_index_stats_hook) (root, index->indexoid,
pos + 1, 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) &&核心调用上下文:src/backend/utils/adt/selfuncs.c:6218–6232
{
/* Expression --- maybe there are stats for the index itself */
relid = index->indexoid;
colnum = indexcol + 1;
if (get_index_stats_hook &&
(*get_index_stats_hook) (root, relid, 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:8777–8791
*/
/* get the attnum from the 0-based index. */
attnum = iclause->indexcol + 1;
if (get_index_stats_hook &&
(*get_index_stats_hook) (root, index->indexoid, 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_index_stats_hook 是在 src/include/utils/selfuncs.h 中声明的核心扩展钩子。下方保留精确接口与调用位置。
- 接口类型
- get_index_stats_hook_type
- 声明头文件
- src/include/utils/selfuncs.h
- 调用阶段
- 统计信息与估算
- 初始值
- NULL(未安装钩子)
接口签名
typedef bool (*get_index_stats_hook_type) (PlannerInfo *root, Oid indexOid, AttrNumber indexattnum, VariableStatData *vardata);
extern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;调用位置
src/backend/utils/adt/selfuncs.c:5488
src/backend/utils/adt/selfuncs.c:6224
src/backend/utils/adt/selfuncs.c:8783
相关条目
文档与源码
查看来源构建
- 版本
- 18
- 构建
- REL_18_STABLE
- 来源指纹
753057e340da8f22e57c9a409ea7a235fd6a46bd
同类条目
get_attavgwidth_hook平均属性宽度get_relation_stats_hook表列统计信息
返回扩展钩子 · 此条目的收录范围为 PostgreSQL 10 至 20;起点不一定是实际引入版本。