PostgreSQL源码学习--执行器#9
短信预约 信息系统项目管理师 报名、考试、查分时间动态提醒
本节介绍ExecutePlan函数
相关数据结构
typedef enum ScanDirection
{
BackwardScanDirection = -1,
NoMovementScanDirection = 0,
ForwardScanDirection = 1
} ScanDirection;
ExecutePlan函数
static void
ExecutePlan(EState *estate,
PlanState *planstate,
bool use_parallel_mode,
CmdType operation,
bool sendTuples,
uint64 numberTuples,
ScanDirection direction,
DestReceiver *dest,
bool execute_once);
执行查询计划,直到获取到numberTuples个元组,并且处理时朝direction方向移动。
//class="lazy" data-src/backend/executor/execMain.c
current_tuple_count = 0;
estate->es_direction = direction;
if (!execute_once)
use_parallel_mode = false;
estate->es_use_parallel_mode = use_parallel_mode;
if (use_parallel_mode)
EnterParallelMode();
for (;;)
{
ResetPerTupleExprContext(estate);
slot = ExecProcNode(planstate);
if (TupIsNull(slot))
{
if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
(void) ExecShutdownNode(planstate);
break;
}
if (estate->es_junkFilter != NULL)
slot = ExecFilterJunk(estate->es_junkFilter, slot);
if (sendTuples)
{
if (!dest->receiveSlot(slot, dest))
break;
}
if (operation == CMD_SELECT)
(estate->es_processed)++;
current_tuple_count++;
if (numberTuples && numberTuples == current_tuple_count)
{
if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
(void) ExecShutdownNode(planstate);
break;
}
}
if (use_parallel_mode)
ExitParallelMode();
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341