//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()。
*
* ----------------------------------------------------------------
*/