↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 扩展钩子 / 查询执行

ExecutorRun_hook

执行器运行

供插件在 ExecutorRun() 中接管处理的钩子。

当前查看 PostgreSQL 18。

中文定义与说明

供插件在 ExecutorRun() 中接管处理的钩子。

以下中文为本站依据所列 PostgreSQL 源码注释编译的说明。

接口声明

typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc, ScanDirection direction, uint64 count);
extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;

调用位置

  • src/backend/executor/execMain.c:301

核心调用上下文:src/backend/executor/execMain.c:295–309

 */
void
ExecutorRun(QueryDesc *queryDesc,
			ScanDirection direction, uint64 count)
{
	if (ExecutorRun_hook)
		(*ExecutorRun_hook) (queryDesc, direction, count);
	else
		standard_ExecutorRun(queryDesc, direction, count);
}

void
standard_ExecutorRun(QueryDesc *queryDesc,
					 ScanDirection direction, uint64 count)
{

说明

供插件在 ExecutorRun() 中接管处理的钩子。

接口类型
ExecutorRun_hook_type
声明头文件
src/include/executor/executor.h
调用阶段
查询执行
初始值
NULL(未安装钩子)

接口签名

typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc, ScanDirection direction, uint64 count);
extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;

串接已有钩子

钩子变量只保存一个函数指针。扩展安装时应保存旧值;需要保留原行为时先调用旧钩子,旧值为空则调用相应的 standard_ 实现。直接再次调用同名公共入口可能重新进入自己的钩子。

版本差异

PostgreSQL 18 起的接口不再包含 execute_once 参数;跨版本扩展需要按目标版本适配。

调用位置

src/backend/executor/execMain.c:301

相关条目

文档与源码

查看来源构建
版本
18
构建
REL_18_STABLE
来源指纹
753057e340da8f22e57c9a409ea7a235fd6a46bd

同类条目

返回扩展钩子 · 此条目的收录范围为 PostgreSQL 10 至 20;起点不一定是实际引入版本。