Postgres源码阅读ExecutorRun

ExecutorRun是数据库执行器模块的关键函数,它接收查询描述符并执行查询计划。如果存在ExecutorRun_hook钩子函数,则调用插件,否则执行标准流程。此函数按指定方向处理元组,并允许插件控制查询执行。count参数用于限制返回结果的数量,但不影响ModifyTable等操作的影响范围。
摘要由CSDN通过智能技术生成
//queryDesc:查询描述符,包含了查询计划和执行相关的信息。
//direction:扫描方向,指定了元组的检索顺序。
//count:要检索的元组数量,用于限制返回的结果集大小。
//execute_once:布尔值,指示是否只执行一次查询。
void
ExecutorRun(QueryDesc *queryDesc,
			ScanDirection direction, uint64 count,
			bool execute_once)
{
	// 函数首先检查是否存在 ExecutorRun_hook 钩子函数,如果存在,则调用钩子函数,将执行的控制权交给插件。
	// 否则,调用 standard_ExecutorRun 函数进行标准的执行。
	if (ExecutorRun_hook)
		(*ExecutorRun_hook) (queryDesc, direction, count, execute_once);
	else
		standard_ExecutorRun(queryDesc, direction, count, execute_once);
}
/* ----------------------------------------------------------------
 *		ExecutorRun
 *
 *		This is the main routine of the executor module. It accepts
 *		the query descriptor from the traffic cop and executes the
 *		query plan.
 *	
  	
  	这是执行器模块的主要函数。它接收来自流量控制器的查询描述符,并执行查询计划。
 *		ExecutorStart must have been called already.
 *	
	 ExecutorStart 必须已经被调用过了。
 *
 *		If direction is NoMovementScanDirection then nothing is done
 *		except to start up/shut down the destination.  Otherwise,
 *		we retrieve up to 'count' tuples in the specified direction.

	如果 direction 是 NoMovementScanDirection,则除了启动/关闭目标外,不执行任何操作。
	否则,我们按指定的方向检索最多 'count' 个元组。
 *
 *		Note: count = 0 is interpreted as no portal limit, i.e., run to
 *		completion.  Also note that the count limit is only applied to
 *		retrieved tuples, not for instance to those inserted/updated/deleted
 *		by a ModifyTable plan node.

	 注意:count = 0 被解释为没有门限限制,即运行到结束。
	 还要注意,计数限制只适用于检索到的元组,
	 不适用于例如 ModifyTable 计划节点插入/更新/删除的元组。
 *
 *		There is no return value, but output tuples (if any) are sent to
 *		the destination receiver specified in the QueryDesc; and the number
 *		of tuples processed at the top level can be found in
 *		estate->es_processed.

	该函数没有返回值,但输出的元组(如果有的话)会发送到 QueryDesc 中指定的目标接收器,
	并且顶层处理的元组数量可以在 estate->es_processed 中找到。
 *
 *		We provide a function hook variable that lets loadable plugins
 *		get control when ExecutorRun is called.  Such a plugin would
 *		normally call standard_ExecutorRun().

	我们提供了一个函数钩子变量,允许可加载插件在调用 ExecutorRun 时获得控制权。
	这样的插件通常会调用 standard_ExecutorRun()。
 *
 * ----------------------------------------------------------------
 */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值